From 83131b2163b0ae63cd3a67310ccf3779cd790666 Mon Sep 17 00:00:00 2001 From: Cian Hughes Date: Fri, 2 May 2025 11:50:34 +0100 Subject: [PATCH] Added customisation plugin to invenio instance --- docker-compose.yaml | 9 +++++---- invenio/Dockerfile | 5 +++++ .../assets}/ESAFORM_AM-D-Model_logo.webp | Bin invenio/plugin/__init__.py | 10 ++++++++++ invenio/plugin/setup.py | 12 ++++++++++++ invenio/plugin/views.py | 17 +++++++++++++++++ Dockerfile => src/Dockerfile | 0 7 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 invenio/Dockerfile rename {invenio_assets => invenio/assets}/ESAFORM_AM-D-Model_logo.webp (100%) create mode 100644 invenio/plugin/__init__.py create mode 100644 invenio/plugin/setup.py create mode 100644 invenio/plugin/views.py rename Dockerfile => src/Dockerfile (100%) diff --git a/docker-compose.yaml b/docker-compose.yaml index 52d5c98..33decc3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,7 +1,7 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json services: site: - build: . + build: src networks: - am-d-model-network expose: @@ -41,14 +41,15 @@ services: awslogs-stream: caddy awslogs-create-group: "true" invenio-rdm: - image: ghcr.io/front-matter/invenio-rdm-starter:v12.0.13.4 + image: invenio networks: - am-d-model-network pull_policy: if_not_present volumes: - uploaded_data:/opt/invenio/var/instance/data - archived_data:/opt/invenio/var/instance/archive - - ./invenio_assets:/opt/invenio/var/instance/static/custom_assets # Add static assets for theming + - ./invenio/assets:/opt/invenio/var/instance/static/custom_assets # Add static assets for theming + - ./invenio/plugin:/opt/invenio/var/instance/static/plugin # Add plugin for customisations - ./invenio.cfg:/opt/invenio/var/instance/invenio.cfg # Override the config with our custom one environment: # Production mode @@ -154,10 +155,10 @@ services: awslogs-stream: invenio-rdm awslogs-create-group: "true" worker: + image: invenio command: "celery -A invenio_app.celery worker --beat --events --loglevel=WARNING" networks: - am-d-model-network - image: ghcr.io/front-matter/invenio-rdm-starter:v12.0.13.4 pull_policy: if_not_present volumes: - uploaded_data:/opt/invenio/var/instance/data diff --git a/invenio/Dockerfile b/invenio/Dockerfile new file mode 100644 index 0000000..ac12f1e --- /dev/null +++ b/invenio/Dockerfile @@ -0,0 +1,5 @@ +FROM ghcr.io/front-matter/invenio-rdm-starter:v12.0.13.4 + +RUN /opt/invenio/.venv/bin/python -m ensurepip +RUN /opt/invenio/.venv/bin/python -m pip install -e /opt/invenio/var/instance/static/plugin +RUN /opt/invenio/.venv/bin/python -m pip uninstall -e pip diff --git a/invenio_assets/ESAFORM_AM-D-Model_logo.webp b/invenio/assets/ESAFORM_AM-D-Model_logo.webp similarity index 100% rename from invenio_assets/ESAFORM_AM-D-Model_logo.webp rename to invenio/assets/ESAFORM_AM-D-Model_logo.webp diff --git a/invenio/plugin/__init__.py b/invenio/plugin/__init__.py new file mode 100644 index 0000000..350c22f --- /dev/null +++ b/invenio/plugin/__init__.py @@ -0,0 +1,10 @@ +from flask import Blueprint + + +def init_app(app): + """Initialize application.""" + app.register_blueprint(views.blueprint) + return app + + +from . import views diff --git a/invenio/plugin/setup.py b/invenio/plugin/setup.py new file mode 100644 index 0000000..dea7384 --- /dev/null +++ b/invenio/plugin/setup.py @@ -0,0 +1,12 @@ +from setuptools import setup + +setup( + name="custom_invenio_plugin", + version="0.1.0", + packages=["custom_invenio_plugin"], + entry_points={ + "invenio_base.apps": [ + "custom_menu = custom_invenio_plugin:init_app", + ], + }, +) diff --git a/invenio/plugin/views.py b/invenio/plugin/views.py new file mode 100644 index 0000000..84fc16b --- /dev/null +++ b/invenio/plugin/views.py @@ -0,0 +1,17 @@ +from flask import Blueprint +from flask_menu import current_menu + +blueprint = Blueprint( + "custom_menu", + __name__, +) + + +@blueprint.before_app_first_request +def init_menu(): + """Add custom items to main menu.""" + current_menu.submenu("main").register( + "About AM-D-Model", + "https://am-d-model.eu", + order=0, + ) diff --git a/Dockerfile b/src/Dockerfile similarity index 100% rename from Dockerfile rename to src/Dockerfile