forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs/user/aws/images: Dia source for UPI arch diagram
Dia is from Stephen Cuppett, replacing the PNG he'd submitted via 39a926a (Adding initial user doc/guide & materials for UPI AWS installation, 2019-03-12, openshift#1408). We aren't using the full file with all the layers yet, but I'm building it anyway because folks without Dia may still want to look at it ;). SVGs generated with: $ dia --version Dia version 0.97.3, compiled 18:02:21 Feb 11 2017 relink-dia.py embeds the referenced icons in the SVG with def and use [1,2] to avoid icon URIs like: file:///.../openshift/installer/docs/user/aws/images/./AWS-Architecture-Icons_SVG/Light-BG/_General%20AWS/AWS-General_AWS-Cloud_light-bg.svg Ideally Dia would have a way to do this sort of thing automatically with a command-line switch, but if it does, I can't find it. [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/def [2]: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use
- Loading branch information
Showing
8 changed files
with
596 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
AWS-Architecture-Icons_SVG* | ||
__MACOSX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
all: install_upi.svg install_upi_vpc.svg | ||
|
||
install_upi.svg: install_upi.dia relink-dia.py AWS-Architecture-Icons_SVG/.touch | ||
dia --export $@ $< | ||
./relink-dia.py $@ | ||
|
||
install_upi_vpc.svg: install_upi.dia relink-dia.py AWS-Architecture-Icons_SVG/.touch | ||
dia -L 'Availability Zones,VPC,Subnets,Route53 (Private)' --export $@ $< | ||
./relink-dia.py $@ | ||
|
||
# URI from https://aws.amazon.com/architecture/icons/ | ||
AWS-Architecture-Icons_SVG.zip: | ||
curl https://d1.awsstatic.com/webteam/architecture-icons/AWS-Architecture-Icons_SVG_20190131.f8dacae00681382ab91d59994de429d6e9a680bc.zip >$@ | ||
|
||
AWS-Architecture-Icons_SVG/.touch: AWS-Architecture-Icons_SVG.zip | ||
unzip -o $< | ||
touch $@ | ||
|
||
clean: | ||
rm -rf install_upi*.svg AWS-Architecture-Icons_SVG* __MACOSX |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Replace file:///... references with relative links and add the targets to Git. | ||
|
||
import base64 | ||
import os | ||
import sys | ||
import urllib.parse | ||
import xml.etree.ElementTree | ||
|
||
|
||
def slug(uri): | ||
return os.path.basename(uri) | ||
|
||
|
||
def get_def(path): | ||
tree = xml.etree.ElementTree.parse(path) | ||
root = tree.getroot() | ||
root.set('id', slug(path)) | ||
return root | ||
|
||
|
||
def relink(path): | ||
images = set() | ||
tree = xml.etree.ElementTree.parse(path) | ||
root = tree.getroot() | ||
parents = {c: p for p in tree.getiterator() for c in p} | ||
defs = xml.etree.ElementTree.Element('{http://www.w3.org/2000/svg}defs') | ||
root.insert(0, defs) | ||
for image in list(root.findall('{http://www.w3.org/2000/svg}image')): | ||
uri = urllib.parse.unquote(image.get('{http://www.w3.org/1999/xlink}href')).split('/./', 1)[-1] | ||
if uri not in images: | ||
defs.append(get_def(path=uri)) | ||
images.add(uri) | ||
parent = parents[image] | ||
parent_index = list(parent).index(image) | ||
parent.remove(image) | ||
attrib = dict(image.items()) | ||
attrib['{http://www.w3.org/1999/xlink}href'] = '#' + slug(uri) | ||
parent.insert( | ||
parent_index, | ||
xml.etree.ElementTree.Element('{http://www.w3.org/2000/svg}use', attrib=attrib)) | ||
tree.write(path) | ||
|
||
|
||
for path in sys.argv[1:]: | ||
relink(path=path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters