state sync, many changes:
* separated css/js/rule files to pak file (glorified zip) to reduce full rebuilds * implemented build cache * some frontend UI spiffing up
This commit is contained in:
@@ -18,7 +18,9 @@ log.critical(path_appdir)
|
||||
|
||||
desktop_mode = False
|
||||
|
||||
app = flask.Flask("seagull-game", root_path=path_appdir)
|
||||
from . import gamedata
|
||||
|
||||
app = flask.Flask("seagull-game", root_path=path_appdir, template_folder="templates", static_folder="static")
|
||||
orig_url_for = app.url_for
|
||||
|
||||
xml_namespaces = {
|
||||
@@ -34,12 +36,15 @@ xml_namespaces = {
|
||||
|
||||
def url_for_override(endpoint, *posargs, _anchor=None, _method=None, _scheme=None, _external=None, self=app, **values):
|
||||
if endpoint == "static":
|
||||
# bandaid for #1
|
||||
if not os.path.exists(path_appdir / "static" / values["filename"]):
|
||||
if not gamedata.vfs.exists(f"static/{values["filename"]}"):
|
||||
log.warning("requested {0} from local file, but it doesn't exist in this container. Redirecting to CDN...\n".format(values["filename"]))
|
||||
return "https://cdn.otl-hga.net/seagull/" + values["filename"]
|
||||
|
||||
return orig_url_for(endpoint, *posargs, _anchor=_anchor, _method=_method, _scheme=_scheme, _external=_external, **values)
|
||||
else:
|
||||
gamedata.vfs.copy_out(f"static/{values["filename"]}", dest=path_appdir.as_posix())
|
||||
return orig_url_for(endpoint, *posargs, _anchor=_anchor, _method=_method, _scheme=_scheme, _external=_external, **values)
|
||||
else:
|
||||
print(endpoint)
|
||||
return orig_url_for(endpoint, *posargs, _anchor=_anchor, _method=_method, _scheme=_scheme, _external=_external, **values)
|
||||
|
||||
app.url_for = url_for_override
|
||||
|
||||
@@ -48,7 +53,8 @@ base_context_live = False
|
||||
|
||||
@app.route("/dialog/<dialog>")
|
||||
def render_dialog(dialog):
|
||||
if os.path.exists(path_appdir / f"templates/{dialog}.j2"):
|
||||
if gamedata.vfs.exists(f"templates/{dialog}.j2"):
|
||||
gamedata.vfs.copy_out(f"templates/{dialog}.j2", dest=path_appdir.as_posix())
|
||||
return flask.render_template(f"{dialog}.j2")
|
||||
else:
|
||||
return "", 404
|
||||
|
Reference in New Issue
Block a user