mirror of
https://github.com/Cian-H/am-d-model.eu.git
synced 2025-12-22 21:41:57 +00:00
Plugin fix attempt
This commit is contained in:
@@ -1,14 +1,32 @@
|
|||||||
from flask import Blueprint
|
|
||||||
|
|
||||||
|
|
||||||
def init_app(app):
|
def init_app(app):
|
||||||
"""Initialize application."""
|
"""Initialize application."""
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
app.register_blueprint(views.blueprint)
|
|
||||||
|
|
||||||
@app.before_first_request
|
@app.before_first_request
|
||||||
def init_menus():
|
def init_menus():
|
||||||
views.init_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,41 +1,10 @@
|
|||||||
from flask import Blueprint
|
def init_main_menu():
|
||||||
|
"""Add custom items to main menu."""
|
||||||
from flask_menu import current_menu
|
from flask_menu import current_menu
|
||||||
|
|
||||||
blueprint = Blueprint(
|
|
||||||
"custom_menu",
|
|
||||||
__name__,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def init_menu():
|
|
||||||
"""Add custom items to main menu."""
|
|
||||||
current_menu.submenu("main").register(
|
current_menu.submenu("main").register(
|
||||||
id="amdmodel",
|
id="amdmodel",
|
||||||
text="About AM-D-Model",
|
text="About AM-D-Model",
|
||||||
external_url="https://am-d-model.eu",
|
external_url="https://am-d-model.eu",
|
||||||
order=0,
|
order=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@blueprint.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>"
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ setup(
|
|||||||
packages=["custom_invenio_plugin"],
|
packages=["custom_invenio_plugin"],
|
||||||
entry_points={
|
entry_points={
|
||||||
"invenio_base.apps": [
|
"invenio_base.apps": [
|
||||||
"custom_menu = custom_invenio_plugin:init_app",
|
"custom_invenio_plugin = custom_invenio_plugin:init_app",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user