load svg images inline

This commit is contained in:
rolux 2011-08-09 19:00:39 +02:00
commit dd7191e8d4
12 changed files with 78 additions and 59 deletions

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python
#vim: et:ts=4:sw=4:sts=4
import base64
import json
import os
import re
@ -51,6 +52,19 @@ for filename in os.listdir(path):
svg = svg.replace('#404040', '#FFFFFF').replace('#000000', '#FFFFFF')
write_file(path.replace('/classic/', '/modern/') + filename, svg)
imageURLs = {}
imageDataURLs = {}
for theme in ['classic', 'modern']:
path = source_path + 'Ox.UI/themes/' + theme + '/svg/'
for filename in os.listdir(path):
if not filename[0] in '._':
key = theme + '/' + filename[:-4]
imageURLs[key] = os.path.join(path, filename).replace(source_path, '')
data = re.sub('\n\s+', '', read_file(path + filename))
imageDataURLs[key] = 'data:image/svg+xml;base64,' + base64.b64encode(data)
write_file(build_path + 'Ox.UI/json/Ox.UI.imageURLs.json', json.dumps(imageURLs, indent=4, sort_keys=True))
write_file(build_path + 'Ox.UI/json/Ox.UI.imageDataURLs.json', json.dumps(imageDataURLs, indent=4, sort_keys=True))
# symlinks
for path, dirnames, filenames in os.walk(source_path):
for filename in filenames:
@ -80,7 +94,7 @@ root = source_path + 'Ox.UI/'
for path, dirnames, filenames in os.walk(root):
for filename in filenames:
# theme css files get included by main css
if path != root and not '_' in path and not filename[0] in '._' and filename[-4:] != '.css':
if path != root and not '_' in path and not filename[0] in '._' and filename[-4:] != '.css' and filename[-4:] != '.svg':
files.append(os.path.join(path.replace(source_path, ''), filename))
if filename[-3:] == '.js':
folder = os.path.split(path)[-1]
@ -92,4 +106,4 @@ for path, dirnames, filenames in os.walk(root):
write_file(build_path + 'Ox.UI/js/Ox.UI.js', js)
files = json.dumps(sorted(files), indent=4, sort_keys=True)
write_file(build_path + 'Ox.UI/json/Ox.UI.json', files)
write_file(build_path + 'Ox.UI/json/Ox.UI.files.json', files)