diff --git a/invenio/plugin/custom_invenio_plugin/__init__.py b/invenio/plugin/custom_invenio_plugin/__init__.py index 1d5bbf3..c291e4e 100644 --- a/invenio/plugin/custom_invenio_plugin/__init__.py +++ b/invenio/plugin/custom_invenio_plugin/__init__.py @@ -2,31 +2,7 @@ def init_app(app): """Initialize application.""" from . import views - @app.before_first_request - def init_menus(): - 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 "
" + "\n".join(result) + "" + app.register_blueprint(views.blueprint) + app.before_first_request(views.init_main_menu) return app diff --git a/invenio/plugin/custom_invenio_plugin/views.py b/invenio/plugin/custom_invenio_plugin/views.py index c6ff0b1..ff25494 100644 --- a/invenio/plugin/custom_invenio_plugin/views.py +++ b/invenio/plugin/custom_invenio_plugin/views.py @@ -1,10 +1,22 @@ +from flask import Blueprint, redirect + +blueprint = Blueprint( + "custom_invenio_plugin", + __name__, +) + + def init_main_menu(): - """Add custom items to main menu.""" from flask_menu import current_menu current_menu.submenu("main").register( - id="amdmodel", + "custom_invenio_plugin.redirect_to_amdmodel", text="About AM-D-Model", - external_url="https://am-d-model.eu", 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")