def bake_js(source_dir="js5", dest_file="script5.js"): create_baked_directory() fn = os.path.join( os.path.dirname(__file__), "..", "static", "baked", str(get_build_number()), dest_file, ) if not os.path.exists(fn): js_content = "" for sfn in get_js_file_list(source_dir): jsfile = open(os.path.join(os.path.dirname(__file__), "..", sfn)) js_content += jsfile.read() + "\n" jsfile.close() o = open(fn, "w") # Pylint disabled for next line because pylint is buggy about the es5 function o.write(minify_print(es5(js_content))) # pylint: disable=not-callable if config.has("sentry_frontend_dsn"): sentry_frontend_dsn = config.get("sentry_frontend_dsn") o.write( 'if (window.Sentry) {' 'window.Sentry.init({' f'dsn: "{ sentry_frontend_dsn }",' 'tunnel: "/sentry_tunnel",' '});' '}' ) o.close()
def create_baked_directory(): d = os.path.join( os.path.dirname(__file__), "../static/baked/", str(get_build_number()) ) if not os.path.exists(d): os.makedirs(d) return False
def copy_woff(): d = os.path.join(os.path.dirname(__file__), "../static/baked/", str(get_build_number())) # Copying the minimized font files has to go somewhere. for fontfile in glob.glob( os.path.join(os.path.dirname(__file__), "../static/fonts/*.min.woff")): shutil.copy(fontfile, d)
def bake_beta_css(): create_baked_directory() wfn = os.path.join(os.path.dirname(__file__), "..", "static", "baked", str(get_build_number()), "style5b.css") incl_path = Path( os.path.join(os.path.dirname(__file__), "..", "static", "style5")).resolve() _bake_css_file("r5.scss", wfn, incl_path)
def create_baked_directory(): d = os.path.join(os.path.dirname(__file__), "../static/baked/", str(get_build_number())) if not os.path.exists(d): os.makedirs(d) if os.name != "nt" and os.getuid() == 0: #pylint: disable=E1101 subprocess.call(["chown", "-R", "%s:%s" % (config.get("api_user"), config.get("api_group")), d ]) return True return False
def create_baked_directory(): d = os.path.join(os.path.dirname(__file__), "../static/baked/", str(get_build_number())) if not os.path.exists(d): os.makedirs(d) if os.name != "nt" and os.getuid() == 0: #pylint: disable=E1101 subprocess.call([ "chown", "-R", "%s:%s" % (config.get("api_user"), config.get("api_group")), d ]) return True return False
def create_baked_directory(): d = os.path.join(os.path.dirname(__file__), "../static/baked/", str(get_build_number())) if not os.path.exists(d): os.makedirs(d) subprocess.call([ "chown", "-R", "%s:%s" % (config.get("api_user"), config.get("api_group")), d, ]) return True return False
def bake_js(source_dir="js5", dest_file="script5.js"): create_baked_directory() fn = os.path.join(os.path.dirname(__file__), "..", "static", "baked", str(get_build_number()), dest_file) if not os.path.exists(fn): js_content = "" for sfn in get_js_file_list(source_dir): jsfile = open(os.path.join(os.path.dirname(__file__), "..", sfn)) js_content += minify(jsfile.read()) + "\n" jsfile.close() o = open(fn, "w") o.write(minify(js_content, mangle=True, mangle_toplevel=False)) o.close()
def bake_css(): create_baked_directory() wfn = os.path.join( os.path.dirname(__file__), "..", "static", "baked", str(get_build_number()), "style5.css", ) incl_path = str( Path(os.path.join(os.path.dirname(__file__), "..", "static", "style5")).resolve()) if not os.path.exists(wfn): _bake_css_file("r5.scss", wfn, incl_path)
def bake_templates(source_dir="templates5", dest_file="templates5.js", always_write=False, **kwargs): create_baked_directory() source_dir = os.path.join(os.path.dirname(__file__), "..", "static", source_dir) dest_file = os.path.join(os.path.dirname(__file__), "..", "static", "baked", str(get_build_number()), dest_file) if not os.path.exists(dest_file) or always_write: RWTemplates.compile_templates(source_dir, dest_file, helpers=False, inline_templates=('fave', 'rating', 'rating_album'), **kwargs)
def bake_js(source_dir="js5", dest_file="script5.js"): create_baked_directory() fn = os.path.join( os.path.dirname(__file__), "..", "static", "baked", str(get_build_number()), dest_file, ) if not os.path.exists(fn): js_content = "" for sfn in get_js_file_list(source_dir): jsfile = open(os.path.join(os.path.dirname(__file__), "..", sfn)) js_content += jsfile.read() + "\n" jsfile.close() o = open(fn, "w") # Pylint disabled for next line because pylint is buggy about the es5 function o.write(minify_print(es5(js_content), obfuscate=True)) # pylint: disable=not-callable o.close()
def bake_beta_css(): create_baked_directory() wfn = os.path.join(os.path.dirname(__file__), "..", "static", "baked", str(get_build_number()), "style4b.css") _bake_css_file(os.path.join(os.path.dirname(__file__), "..", "static", "style4", "_sass.scss"), wfn)
def increment_build_number(): bn = get_build_number() + 1 bnf = open(os.path.join(os.path.dirname(__file__), "../etc/buildnum"), 'w') bnf.write(bn) bnf.close() return bn
def bake_beta_css(): create_baked_directory() wfn = os.path.join(os.path.dirname(__file__), "..", "static", "baked", str(get_build_number()), "style5b.css") incl_path = Path(os.path.join(os.path.dirname(__file__), "..", "static", "style5")).resolve() _bake_css_file("r5.scss", wfn, incl_path)
def copy_woff(): d = os.path.join(os.path.dirname(__file__), "../static/baked/", str(get_build_number())) # Copying the minimized font files has to go somewhere. for fontfile in glob.glob(os.path.join(os.path.dirname(__file__), "../static/fonts/*.min.woff")): shutil.copy(fontfile, d)