forked from 0x2620/oxjs
modularize oxui
This commit is contained in:
parent
2e3292e9ce
commit
0024af978c
106 changed files with 16127 additions and 47034 deletions
|
|
@ -1,26 +1,33 @@
|
|||
import json
|
||||
import os
|
||||
import re
|
||||
|
||||
def read_file(file):
|
||||
print 'reading', file
|
||||
#print 'reading', file
|
||||
f = open(file)
|
||||
data = f.read()
|
||||
f.close()
|
||||
return data
|
||||
|
||||
def write_file(file, data):
|
||||
print 'writing', file
|
||||
#print 'writing', file
|
||||
write_path(file)
|
||||
f = open(file, 'w')
|
||||
f.write(data)
|
||||
f.close()
|
||||
return len(data)
|
||||
|
||||
def write_link(source, target):
|
||||
if os.path.exists(target):
|
||||
os.unlink(target)
|
||||
os.symlink(source, target)
|
||||
|
||||
def write_path(file):
|
||||
path = os.path.split(file)[0]
|
||||
if path and not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
|
||||
source_path = '../../source/'
|
||||
build_path = '../../build/'
|
||||
|
||||
# SVG
|
||||
|
|
@ -36,16 +43,26 @@ for dirname, dirnames, filenames in os.walk(path):
|
|||
|
||||
# JSON
|
||||
|
||||
images = []
|
||||
files = []
|
||||
|
||||
for dirname, dirnames, filenames in os.walk(source_path + 'js/'):
|
||||
for filename in filenames:
|
||||
if filename[:1] != '.':
|
||||
jquery = re.compile('jquery-[\d\.]+\.js').findall(filename)
|
||||
if jquery or filename in ['Ox.js', 'OxUI.js']:
|
||||
target = 'jquery.js' if jquery else filename
|
||||
write_link(os.path.join(dirname, filename), build_path + 'js/' + target)
|
||||
elif not '_' in dirname and not filename.endswith('.min.js'):
|
||||
files.append(os.path.join(dirname.replace(source_path , '../source/'), filename))
|
||||
|
||||
for dirname, dirnames, filenames in os.walk(build_path + 'png'):
|
||||
for filename in filenames:
|
||||
if filename[:1] != '.':
|
||||
images.append(os.path.join(dirname.replace(build_path, ''), filename))
|
||||
files.append(os.path.join(dirname.replace(build_path, ''), filename))
|
||||
|
||||
for dirname, dirnames, filenames in os.walk(build_path + 'svg'):
|
||||
for filename in filenames:
|
||||
if filename[:1] != '.':
|
||||
images.append(os.path.join(dirname.replace(build_path, ''), filename))
|
||||
files.append(os.path.join(dirname.replace(build_path, ''), filename))
|
||||
|
||||
write_file(build_path + 'json/ox.ui.images.json', json.dumps(images, indent=4, sort_keys=True))
|
||||
write_file(build_path + 'json/OxUI.json', json.dumps(files, indent=4, sort_keys=True))
|
||||
Loading…
Add table
Add a link
Reference in a new issue