don't call external build script for own js files
This commit is contained in:
parent
a3f6e3da3a
commit
5bbb5849cb
3 changed files with 22 additions and 21 deletions
|
@ -116,6 +116,7 @@ def command_update_static(*args):
|
|||
Update static files
|
||||
"""
|
||||
import setup
|
||||
import utils
|
||||
setup.create_db()
|
||||
old_oxjs = os.path.join(settings.static_path, 'oxjs')
|
||||
oxjs = os.path.join(settings.base_dir, '..', 'oxjs')
|
||||
|
@ -126,7 +127,7 @@ def command_update_static(*args):
|
|||
elif os.path.exists(os.path.join(oxjs, '.git')):
|
||||
os.system('cd "%s" && git pull' % oxjs)
|
||||
r('python3', os.path.join(oxjs, 'tools', 'build', 'build.py'), '-nogeo')
|
||||
r('python3', os.path.join(settings.static_path, 'py', 'build.py'))
|
||||
utils.update_static()
|
||||
reader = os.path.join(settings.base_dir, '..', 'reader')
|
||||
if not os.path.exists(reader):
|
||||
r('git', 'clone', 'https://git.0x2620.org/openmedialibrary_reader.git', reader)
|
||||
|
|
20
oml/utils.py
20
oml/utils.py
|
@ -403,3 +403,23 @@ def get_meta_hash(data):
|
|||
del data[key]
|
||||
return hashlib.sha1(json.dumps(data,
|
||||
ensure_ascii=False, sort_keys=True).encode()).hexdigest()
|
||||
|
||||
|
||||
def update_static():
|
||||
import settings
|
||||
import os
|
||||
import ox
|
||||
path = os.path.join(settings.static_path, 'js')
|
||||
files = sorted([
|
||||
file for file in os.listdir(path)
|
||||
if not file.startswith('.')
|
||||
and not file.startswith('oml.')
|
||||
])
|
||||
ox.file.write_json(os.path.join(settings.static_path, 'json', 'js.json'), files, indent=4)
|
||||
ox.file.write_file(
|
||||
os.path.join(path, 'oml.min.js'),
|
||||
'\n'.join([
|
||||
ox.js.minify(ox.file.read_file(os.path.join(path, file)).decode('utf-8'))
|
||||
for file in files
|
||||
])
|
||||
)
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
import os
|
||||
import ox
|
||||
|
||||
root_dir = os.path.normpath(os.path.abspath(os.path.dirname(__file__)))
|
||||
os.chdir(root_dir)
|
||||
|
||||
path = '../js/'
|
||||
files = sorted([
|
||||
file for file in os.listdir(path)
|
||||
if not file.startswith('.')
|
||||
and not file.startswith('oml.')
|
||||
])
|
||||
ox.file.write_json('../json/js.json', files, indent=4)
|
||||
ox.file.write_file(
|
||||
'%soml.min.js' % path,
|
||||
'\n'.join([
|
||||
ox.js.minify(ox.file.read_file('%s%s' % (path, file)).decode('utf-8'))
|
||||
for file in files
|
||||
])
|
||||
)
|
Loading…
Reference in a new issue