mirror of
https://github.com/Cian-H/am-d-model.eu.git
synced 2025-12-22 13:41:56 +00:00
Plugin debugging
This commit is contained in:
@@ -2,31 +2,7 @@ def init_app(app):
|
|||||||
"""Initialize application."""
|
"""Initialize application."""
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
@app.before_first_request
|
app.register_blueprint(views.blueprint)
|
||||||
def init_menus():
|
app.before_first_request(views.init_main_menu)
|
||||||
views.init_main_menu()
|
|
||||||
|
|
||||||
@app.route("/debug-menu")
|
|
||||||
def debug_menu():
|
|
||||||
"""Debug endpoint to view menu structure."""
|
|
||||||
result = []
|
|
||||||
|
|
||||||
def inspect_menu(menu_node, level=0):
|
|
||||||
indent = " " * level
|
|
||||||
for child in menu_node.children:
|
|
||||||
item_info = {
|
|
||||||
"name": child.name,
|
|
||||||
"endpoint": getattr(child, "_endpoint", None),
|
|
||||||
"url": getattr(child, "url", None),
|
|
||||||
"text": getattr(child, "_text", None),
|
|
||||||
"order": child.order,
|
|
||||||
"has_children": bool(child.children),
|
|
||||||
}
|
|
||||||
result.append(f"{indent}{item_info}")
|
|
||||||
if child.children:
|
|
||||||
inspect_menu(child, level + 1)
|
|
||||||
|
|
||||||
inspect_menu(current_menu.submenu("main"))
|
|
||||||
return "<pre>" + "\n".join(result) + "</pre>"
|
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|||||||
@@ -1,10 +1,22 @@
|
|||||||
|
from flask import Blueprint, redirect
|
||||||
|
|
||||||
|
blueprint = Blueprint(
|
||||||
|
"custom_invenio_plugin",
|
||||||
|
__name__,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def init_main_menu():
|
def init_main_menu():
|
||||||
"""Add custom items to main menu."""
|
|
||||||
from flask_menu import current_menu
|
from flask_menu import current_menu
|
||||||
|
|
||||||
current_menu.submenu("main").register(
|
current_menu.submenu("main").register(
|
||||||
id="amdmodel",
|
"custom_invenio_plugin.redirect_to_amdmodel",
|
||||||
text="About AM-D-Model",
|
text="About AM-D-Model",
|
||||||
external_url="https://am-d-model.eu",
|
|
||||||
order=0,
|
order=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@blueprint.route("/redirect-to-amdmodel")
|
||||||
|
def redirect_to_amdmodel():
|
||||||
|
"""Redirect to the AM-D-Model website."""
|
||||||
|
return redirect("https://am-d-model.eu")
|
||||||
|
|||||||
Reference in New Issue
Block a user