mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-15 06:28:14 +08:00
pack js and css
This commit is contained in:
@@ -11,8 +11,7 @@ try:
|
|||||||
except:
|
except:
|
||||||
io = __import__("StringIO").StringIO
|
io = __import__("StringIO").StringIO
|
||||||
|
|
||||||
def gen(fn):
|
def gen(s, fn):
|
||||||
s = open(fn, 'rb').read()
|
|
||||||
dat = io()
|
dat = io()
|
||||||
with gzip.GzipFile(fileobj=dat, mode="w") as f:
|
with gzip.GzipFile(fileobj=dat, mode="w") as f:
|
||||||
f.write(s)
|
f.write(s)
|
||||||
@@ -27,11 +26,15 @@ def gen(fn):
|
|||||||
fn = re.sub(r"[^\w]", "_", fn)
|
fn = re.sub(r"[^\w]", "_", fn)
|
||||||
print("const unsigned char %s[0x%x] = {\n%s};" % (fn, len(dat), s))
|
print("const unsigned char %s[0x%x] = {\n%s};" % (fn, len(dat), s))
|
||||||
|
|
||||||
|
def pack(path, name):
|
||||||
|
s = b''
|
||||||
|
for fn in glob.glob(path):
|
||||||
|
s += ("/*%s*/\n" % fn).encode('utf-8')
|
||||||
|
s += open(fn, 'rb').read()
|
||||||
|
gen(s, name)
|
||||||
|
|
||||||
|
pack('web/*.js', 'js_pack')
|
||||||
|
pack('web/*.css', 'css_pack')
|
||||||
|
|
||||||
for fn in glob.glob('web/*.html'):
|
for fn in glob.glob('web/*.html'):
|
||||||
gen(fn)
|
gen(open(fn, 'rb').read(), fn)
|
||||||
|
|
||||||
for fn in glob.glob('web/*.js'):
|
|
||||||
gen(fn)
|
|
||||||
|
|
||||||
for fn in glob.glob('web/*.css'):
|
|
||||||
gen(fn)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user