-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs/user/aws/images: Dia source for UPI arch diagram #1525
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
AWS-Architecture-Icons_SVG* | ||
__MACOSX |
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 $@ $< | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you think will be worth it to add a note somewhere to say There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Won't folks without it get a useful "command not found" error already? And I'd be surprised if all that many people were bumping the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. happy to add some notes (but will be in a week time once i'm back online) |
||
./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 |
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we document how to build it / or a small script rather than add make for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but it's going to take more space than the
Makefile
(e.g. we'd have to write our own code or text about checking for a pre-existing icon zip, unpacking the zip, etc. I don't expect a huge contributor base feeding diagram changes (although I guess you never know), so I'm ok with it how it stands, but am also happy to add docs (CONTRIBUTING.md
?docs/user/aws/images/README.md
? AMakefile
header comment?) that say: