diff --git a/src/ui/main.py b/src/ui/main.py index 4aef20f70..87f781bea 100755 --- a/src/ui/main.py +++ b/src/ui/main.py @@ -1260,7 +1260,7 @@ def upload_plugin(): @app.route("/plugins/", methods=["GET", "POST"]) @login_required -def custom_plugin(plugin): +def custom_plugin(plugin: str): message = "" if not plugin_id_rx.match(plugin): message = f'Invalid plugin id, "{plugin}" (must be between 1 and 64 characters, only letters, numbers, underscores and hyphens)' @@ -1270,14 +1270,14 @@ def custom_plugin(plugin): return {"message": f'Invalid plugin id, "{plugin}" (must be between 1 and 64 characters, only letters, numbers, underscores and hyphens)'}, 400 if request.method == "GET": - plugin_id = request.args.get("plugin_id") - page = db.get_plugin_template(plugin_id) + page = db.get_plugin_template(plugin) if page: return render_template( Environment(loader=FileSystemLoader(join(sep, "usr", "share", "bunkerweb", "ui", "templates") + "/")).from_string(page.decode("utf-8")), dark_mode=app.config["DARK_MODE"], username=current_user.get_id(), + current_endpoint=plugin, **app.jinja_env.globals, ) diff --git a/src/ui/templates/head.html b/src/ui/templates/head.html index ff82f492d..2711b86e6 100644 --- a/src/ui/templates/head.html +++ b/src/ui/templates/head.html @@ -1,4 +1,4 @@ -{% set current_endpoint = url_for(request.endpoint)[1:].split("/")[-1].strip() +{% set current_endpoint = current_endpoint or url_for(request.endpoint)[1:].split("/")[-1].strip() %} diff --git a/src/ui/templates/header.html b/src/ui/templates/header.html index dc0feebdf..df34ee04a 100644 --- a/src/ui/templates/header.html +++ b/src/ui/templates/header.html @@ -1,4 +1,4 @@ -{% set current_endpoint = url_for(request.endpoint)[1:].split("/")[-1].strip().replace('_', ' ').replace('-', ' ') +{% set current_endpoint = current_endpoint or url_for(request.endpoint)[1:].split("/")[-1].strip().replace('_', ' ').replace('-', ' ') %} diff --git a/src/ui/templates/menu.html b/src/ui/templates/menu.html index a4973626b..07cfa90c2 100644 --- a/src/ui/templates/menu.html +++ b/src/ui/templates/menu.html @@ -1,6 +1,3 @@ -{% set current_endpoint = url_for(request.endpoint)[1:].split("/")[-1].strip() -%} -