forked from S3-working-group/s3-illustrations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_galleries.py
45 lines (30 loc) · 1.32 KB
/
make_galleries.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""Build gallery pages to browse illustrations."""
import os
INDEX_TEMPLATE = """---
title: The Sociocracy 3.0 Illustration Repository
---
# Browse Illustrations
![](/img/%(lang)s-48px.png)
"""
GALLERY_TEMPLATE = """---
title: The Sociocracy 3.0 Illustration Repository
---
# Browse %(dir)s (%(lang)s)
![](/img/%(lang)s-48px.png)
[Back](index-%(lang)s.html)
"""
def make_galleries():
for language in os.listdir('png'):
with (file('docs/gallery/index-%s.md' % language, 'w')) as index:
index.write(INDEX_TEMPLATE % dict(lang=language))
for d in sorted(os.listdir(os.path.join('png', language))):
index.write("- [%s](/gallery/index-%s-%s.html)\n" % (d, language, d))
with (file("docs/gallery/index-%s-%s.md" % (language, d), 'w+')) as gallery:
gallery.write(GALLERY_TEMPLATE % dict(dir=d, lang=language))
for i in sorted(os.listdir(os.path.join('png', language, d))):
gallery.write("## %s\n\n" % i)
gallery.write("[![](/img/%(lang)s/%(dir)s/%(img)s)](/img/%(lang)s/%(dir)s/%(img)s)\n\n" % dict(lang=language, dir=d, img=i))
gallery.write("----")
gallery.write("[Back](index-%s.html)\n" % language)
if __name__ == "__main__":
make_galleries()