Plugin debugging

This commit is contained in:
2025-05-08 11:45:04 +01:00
parent cad2355350
commit fa2e727811
2 changed files with 17 additions and 29 deletions

View File

@@ -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

View File

@@ -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")