themes: properly link themes with their archives
[fbsplash.git] / themes / gengallery.py
blobebb5d925081f9022bf6d2821435969b65c28064b
1 #!/usr/bin/python
3 # Generate a static fbsplash theme gallery. Run as:
4 # ./gengallery.py > index.html
6 import os
7 import xml.etree.ElementTree as et
9 size = '1024x768'
10 tsize = '300x225'
12 print '<table>'
14 for theme in sorted(os.listdir('unpacked')):
15 if not os.path.isdir('unpacked/' + theme):
16 continue
18 # Only themes with valid metadata are considered.
19 try:
20 f = open('unpacked/' + theme + '/metadata.xml', 'r')
21 meta = et.parse(f)
22 except Exception:
23 continue
25 url = None
26 name = meta.find('name').text
27 ver = meta.find('version').text
28 author = meta.find('author/name').text
29 email = meta.find('author/email').text
30 desc = meta.find('description').text
31 lic = meta.find('license').text
33 t = meta.find('url')
34 if t is not None:
35 url = t.text
37 shot = '../themes/shots/%s-%s.png' % (size, theme)
38 shott = '../themes/shots/thumbs/%s-%s.jpg' % (tsize, theme)
40 print '<tr><td><a href="%s"><img src="%s" alt="%s" /></a>' % (shot, shott, name)
42 fbcd = '../themes/shots/%s-%s-fbcondecor.png' % (size, theme)
43 fbcdt = '../themes/shots/thumbs/%s-%s-fbcondecor.jpg' % (tsize, theme)
45 if os.path.exists(fbcd):
46 print '<a href="%s"><img src="%s" alt="%s fbcondecor" /></a>' % (fbcd, fbcdt, name)
48 print '<br /><span class="theme">'
49 if url is not None:
50 print '<a href="%s">%s v. %s</a>,' % (url, name, ver)
51 else:
52 print '%s v. %s,' % (name, ver)
54 f1 = open(os.path.join('unpacked', theme, '.origin'), 'r')
55 filename = f1.readlines()[0][:-1]
56 f1.close()
58 print '<b><a href="../themes/%s">download</a></b>' % filename
60 print '</span><br /><span class="desc">%s</span><br /><br />' % desc
62 print '</td></tr>'
64 f.close()
66 print '</table>'