1
0
Fork 0
forked from 0x2620/oxjs

better filesystem structure for modules and themes; 'minified' ui if debug option not set; dynamially generated map markers

This commit is contained in:
rolux 2011-04-27 21:24:33 +02:00
commit 4489e88f44
596 changed files with 115093 additions and 17682 deletions

View file

@ -5,13 +5,6 @@ import os
import re
import shutil
def append_file(file):
split = file.split('/')[1].split('.')
module = '.'.join([split[0], split[1]])
if not module in files:
files[module] = []
files[module].append(file)
def copy_file(source, target):
print 'copying', source, 'to', target
write_file(target, read_file(source))
@ -43,76 +36,60 @@ def write_path(file):
if path and not os.path.exists(path):
os.makedirs(path)
# doesn't work here
base_path = os.path.dirname(__file__)
if base_path:
os.chdir(base_path)
source_path = '../../source/'
build_path = '../../build/'
files = {}
files = ['Ox.UI/css/Ox.UI.css']
# css
for path, dirnames, filenames in os.walk(source_path + 'css/'):
# SVGs
path = source_path + 'Ox.UI/themes/classic/svg/'
for filename in os.listdir(path):
svg = read_file(path + filename)
svg = svg.replace('#404040', '#FFFFFF').replace('#000000', '#FFFFFF')
write_file(path.replace('/classic/', '/modern/') + filename, svg)
# symlinks
for path, dirnames, filenames in os.walk(source_path):
for filename in filenames:
source = os.path.join(path, filename)
target = source.replace(source_path, build_path)
write_link(source, target)
if filename == 'Ox.UI.css':
append_file(target.replace(build_path, ''))
if not '_' in path and not filename[0] in '._':
parts = os.path.join(path.replace(source_path, ''), filename).split('/')
for i, part in enumerate(parts):
if i < len(parts) - 1:
parts[i] = '..'
source = '/'.join(parts).replace(filename, os.path.join(path, filename))[3:]
is_jquery = re.compile('^jquery-[\d\.]+\.js$').findall(filename)
is_jquery_min = re.compile('^jquery-[\d\.]+\.min\.js$').findall(filename)
is_jquery_plugin = re.compile('^jquery\..*?\.js$').findall(filename)
if is_jquery:
target = os.path.join(path.replace(source_path, build_path), 'jquery.js')
elif is_jquery_min:
target = os.path.join(path.replace(source_path, build_path), 'jquery.min.js')
else:
target = os.path.join(path.replace(source_path, build_path), filename)
if is_jquery_plugin:
files.append(target.replace(build_path, ''))
write_link(source, target)
# js
filename = 'js/Ox.js'
write_link(source_path + filename, build_path + filename)
root = source_path + 'js/'
# Ox.UI
js = ''
section = ''
root = source_path + 'Ox.UI/'
for path, dirnames, filenames in os.walk(root):
for dirname in dirnames:
if dirname[0] != '_':
if path == root and dirname != 'jquery':
source = os.path.join(path, dirname)
target = source.replace(source_path, build_path)
write_link(source, target)
for filename in filenames:
if filename[0] != '.' and filename[0] != '_':
if 'jquery' in path:
is_jquery = re.compile('jquery-[\d\.]+\.js').findall(filename)
is_jquery_min = re.compile('jquery-[\d\.]+\.min\.js').findall(filename)
source = os.path.join(path, filename)
if is_jquery:
target = os.path.join(path.replace(source_path, build_path), 'jquery.js')
elif is_jquery_min:
target = os.path.join(path.replace(source_path, build_path), 'jquery.min.js')
else:
target = source.replace(source_path, build_path)
copy_file(source, target)
if not is_jquery and not is_jquery_min:
files['Ox.UI'].append(target.replace(build_path, ''))
elif path != root and not '_' in path:
append_file(os.path.join(path, filename).replace(source_path, ''))
# theme css files get included by main css
if path != root and not '_' in path and not filename[0] in '._' and filename[-4:] != '.css':
files.append(os.path.join(path.replace(source_path, ''), filename))
if filename[-3:] == '.js':
folder = os.path.split(path)[-1]
if section != folder:
section = folder
js += '/*\n' + '=' * 80 + '\n' + section + '\n' + '=' * 80 + '\n*/\n\n'
js += '/*\n' + '-' * 80 + '\n' + filename[:-3] + '\n' + '-' * 80 + '\n*/\n\n'
js += read_file(os.path.join(path, filename)) + '\n\n'
# png
for path, dirnames, filenames in os.walk(source_path + 'png/'):
for filename in filenames:
if filename[:1] != '.':
source = os.path.join(path, filename)
target = source.replace(source_path, build_path)
copy_file(source, target)
append_file(target.replace(build_path, ''))
# svg
for path, dirnames, filenames in os.walk(source_path + 'svg/'):
for filename in filenames:
if filename[0] != '.' and filename[0] != '_':
source = os.path.join(path, filename)
target = source.replace(source_path, build_path)
copy_file(source, target)
append_file(target.replace(build_path, ''))
if 'Ox.UI.classic' in source:
svg = read_file(source).replace('#404040', '#FFFFFF').replace('#000000', '#FFFFFF')
target = target.replace('Ox.UI.classic', 'Ox.UI.modern')
write_file(target, svg)
append_file(target.replace(build_path, ''))
for module in files:
file = build_path + 'json/' + module + '.json'
write_file(file, json.dumps(sorted(files[module]), indent=4, sort_keys=True))
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)