diff options
| -rw-r--r-- | .env.template | 1 | ||||
| -rw-r--r-- | src/__init__.py | 5 | ||||
| -rw-r--r-- | src/templates/base.html | 2 |
3 files changed, 6 insertions, 2 deletions
diff --git a/.env.template b/.env.template index 24cfd32..bef02e6 100644 --- a/.env.template +++ b/.env.template @@ -1,4 +1,5 @@ STAGE= DATABASE= +ADMIN_ENABLED= ADMIN_PASSWORD= SECRET_KEY= diff --git a/src/__init__.py b/src/__init__.py index f6ad74a..9e66fc8 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -6,12 +6,15 @@ from . import admin, blog, website app = q.Quart(__name__) app.config.from_mapping(dotenv_values()) +app.config["admin_enabled"] = app.config.get("ADMIN_ENABLED") == "true" + app.debug = app.config["STAGE"] == "debug" app.permanent_session_lifetime = admin.MAX_LOGIN_TIME app.register_blueprint(blog.blueprint) app.register_blueprint(website.blueprint) -app.register_blueprint(admin.blueprint) +if app.config["admin_enabled"]: + app.register_blueprint(admin.blueprint) @app.while_serving diff --git a/src/templates/base.html b/src/templates/base.html index 935ab5e..ff1f3c6 100644 --- a/src/templates/base.html +++ b/src/templates/base.html @@ -2,7 +2,7 @@ <a class="label" {{ "active" if label_active(path) else "" }} href="{{ path }}">{{ name or path }}</a> {%- endmacro %} -{% set adminmode = request.path.startswith("/admin") %} +{% set adminmode = request.path.startswith("/admin") and config["admin_enabled"] and request.path != "/admin/login" %} <!DOCTYPE html> <html> |
