Compare commits

...

12 Commits

Author SHA1 Message Date
ab8a357137 Added logger output on error 500
Cherry picked and tweaked from
fdec916528
2025-06-06 16:34:32 +01:00
6cba9a6d2b Patch: revert static routes from package level to relative 2025-06-06 14:51:59 +01:00
b66f7a75df Version bump 2025-06-06 14:13:54 +01:00
b02b7aca14 Revert "Removed lom to fix py3.13 issues"
This reverts commit 926196b30f.
2025-06-06 14:13:26 +01:00
56d5d223f3 Version bump 2025-06-06 13:56:11 +01:00
c14168c194 Lock bump 2025-06-06 13:55:22 +01:00
5b71404fda removed depedency on i18n 2025-06-06 13:54:32 +01:00
926196b30f Removed lom to fix py3.13 issues 2025-06-06 13:54:14 +01:00
e74d2017fc Version bump 2025-06-06 13:15:29 +01:00
ef1f268298 Template reference fixes 2025-06-06 13:14:58 +01:00
af61f927f1 Removed translations entrypoint as was unused 2025-06-06 12:51:57 +01:00
d5b9686302 Switched blueprint creation to newer flask style
Noticed and cherry picked from tugraz theme during debugging of plugin
build issues. See:
62c572e483
2025-06-06 12:51:17 +01:00
10 changed files with 45 additions and 44 deletions

View File

@@ -8,4 +8,4 @@
"""Metadata for this python module."""
__version__ = "2025.6.3"
__version__ = "2025.6.6.4"

View File

@@ -106,7 +106,9 @@ DEPOSITS_HEADER_TEMPLATE = "invenio_theme_iform/header.html"
# SEARCH_UI_SEARCH_TEMPLATE = "invenio_theme_iform/search.html"
# """override the default search page"""
IFORM_ROUTES = {
THEME_IFORM_ROUTES = {
"index": "/",
"comingsoon": "/comingsoon",
"records-search": "/records/search",
"overview": "/me/overview",
}

View File

@@ -42,12 +42,12 @@
{%- if config.INVENIO_CONFIG_IFORM_SHIBBOLETH %}
<div class="ui divider"></div>
<a
href="{{ url_for("sso_saml.sso", idp="idp") }}"
href="{{ url_for('sso_saml.sso', idp='idp') }}"
class="login-page-button ui fluid large button"
>
<span style="font-size: 18px;">Sign up with I-Form</span>
<img
src="{{ url_for("static", filename=config.INVENIO_THEME_IFORM_ICON) }}"
src="{{ url_for('static', filename=config.INVENIO_THEME_IFORM_ICON) }}"
height="20px"
/>
</a>
@@ -73,7 +73,7 @@
<div class="content {{ accordion_active }}">
<form
class="ui large form"
action="{{ url_for_security("register") }}"
action="{{ url_for_security('register') }}"
method="POST"
name="register_user_form"
>

View File

@@ -36,7 +36,7 @@
{%- endblock head_title %}
{%- block head_links %}
<link rel="shortcut icon" href="{{ url_for("static", filename="favicon.ico") }}" />
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}" />
{%- if keywords %}
<link rel="canonical" href="{{ canonical_url }}" />

View File

@@ -132,7 +132,7 @@
title="invenioRDM"
>
<img
src="{{ url_for("static", filename="images/inveniordm-tail.svg") }}"
src="{{ url_for('static', filename='images/inveniordm-tail.svg') }}"
alt="InvenioRDM logo"
style="display: block; height: 90px; margin-top: 8px;"
/>
@@ -148,7 +148,7 @@
title="Science Foundation Ireland"
>
<img
src="{{ url_for("static", filename="images/SFI_logo.png") }}"
src="{{ url_for('static', filename='images/SFI_logo.png') }}"
alt="Science Foundation Ireland"
style="display: block; height: auto; margin-top: 15px; width: 230px;"
/>

View File

@@ -64,7 +64,7 @@
<div class="affiliation-text">
<a
title="Home"
href="{{ url_for("invenio_theme_iform.index") }}"
href="{{ url_for('invenio_theme_iform.index') }}"
class="no-decoration"
>
I-FORM

View File

@@ -129,7 +129,7 @@
<img
width="400px"
alt="Publications"
src="{{ url_for('static', filename='images/library-book-svgrepo-com.svg') }}"
src="{{ url_for('invenio_theme_iform.static', filename='images/library-book-svgrepo-com.svg') }}"
/>
</a>
<div>Overview: Description for publications</div>

View File

@@ -8,10 +8,11 @@
"""invenio module for I-Form theme."""
import traceback
from functools import wraps
from typing import Dict
from flask import Blueprint, current_app, g, redirect, render_template, url_for
from flask import Blueprint, Flask, current_app, g, redirect, render_template, url_for
from flask_login import current_user, login_required
from invenio_rdm_records.proxies import current_rdm_records
from invenio_records_global_search.resources.serializers import (
@@ -22,15 +23,30 @@ from opensearch_dsl.utils import AttrDict
from .search import FrontpageRecordsSearch
blueprint = Blueprint(
"invenio_theme_iform",
__name__,
template_folder="templates",
static_folder="static",
)
def create_blueprint(app: Flask) -> Blueprint:
"""Create blueprint."""
blueprint = Blueprint(
"invenio_theme_iform",
__name__,
template_folder="templates",
static_folder="static",
)
routes = app.config.get("THEME_IFORM_ROUTES")
blueprint.add_url_rule(routes["records-search"], view_func=records_search)
blueprint.add_url_rule(routes["index"], view_func=index)
blueprint.add_url_rule(routes["overview"], view_func=overview)
# base case for any otherwise unhandled exception
app.register_error_handler(Exception, default_error_handler)
blueprint.add_app_template_filter(make_dict_like)
blueprint.add_app_template_filter(cast_to_dict)
return blueprint
@blueprint.route("/records/search")
def records_search():
"""Search page ui.
@@ -70,7 +86,6 @@ def require_iform_authenticated(view_func):
return decorated_view
@blueprint.route("/me/overview")
@login_required
def overview():
"""Overview."""
@@ -85,7 +100,6 @@ def overview():
)
@blueprint.app_template_filter("make_dict_like")
def make_dict_like(value: str, key: str) -> Dict[str, str]:
"""Convert the value to a dict like structure.
@@ -94,7 +108,6 @@ def make_dict_like(value: str, key: str) -> Dict[str, str]:
return {key: value}
@blueprint.app_template_filter("cast_to_dict")
def cast_to_dict(attr_dict):
"""Return the dict structure of AttrDict variable."""
return AttrDict.to_dict(attr_dict)
@@ -109,21 +122,13 @@ def default_error_handler(e: Exception):
# - `e`, the passed-in exception
# to get proxied-to objects: `flask.request._get_current_object()`
msg = f"default_error_handler of invenio-theme-iform captured following error type: {
type(e)
} with message {e} and stack trace {traceback.format_exc()}"
current_app.logger.error(msg)
return render_template(current_app.config["THEME_500_TEMPLATE"]), 500
def ui_blueprint(app):
"""Blueprint for the routes and resources provided by invenio-theme-iform."""
routes = app.config.get("IFORM_ROUTES")
blueprint.add_url_rule(routes["index"], view_func=index)
# base case for any otherwise unhandled exception
app.register_error_handler(Exception, default_error_handler)
return blueprint
def records_serializer(records=None):
"""Serialize list of records."""
serializer = GlobalSearchJSONSerializer()

View File

@@ -24,7 +24,6 @@ classifiers = [
requires-python = ">=3.10,<3.14"
dependencies = [
"invenio-assets>=2.0.0",
"invenio-i18n>=1.3.1",
"invenio-config-iform>=2025.5.20.1",
"invenio_records_global_search>=0.0.1",
"invenio_records_marc21>=0.21.0",
@@ -44,10 +43,7 @@ test = "scripts.test:main"
invenio_theme_iform = "invenio_theme_iform:InvenioThemeIform"
[project.entry-points."invenio_base.blueprints"]
invenio_theme_iform = "invenio_theme_iform.views:ui_blueprint"
[project.entry-points."invenio_i18n.translations"]
messages = "invenio_theme_iform"
invenio_theme_iform = "invenio_theme_iform.views:create_blueprint"
[project.entry-points."invenio_assets.webpack"]
invenio_theme_iform_theme = "invenio_theme_iform.webpack:theme"

10
uv.lock generated
View File

@@ -2153,7 +2153,7 @@ wheels = [
[[package]]
name = "invenio-records-lom"
version = "0.18.2"
version = "0.18.4"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
"python_full_version >= '3.12'",
@@ -2164,9 +2164,9 @@ dependencies = [
{ name = "invenio-stats", marker = "python_full_version >= '3.12'" },
{ name = "marshmallow", marker = "python_full_version >= '3.12'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/82/44/c99c74bc4ca3f77540a2cbe3f0a125507be71a58ebafae1b6476a469b159/invenio_records_lom-0.18.2.tar.gz", hash = "sha256:ae0d25e3fb9b34c7bee5515511f03855984eef32796f044e2696c0b5839f4415", size = 180140, upload_time = "2025-05-22T22:21:15.199Z" }
sdist = { url = "https://files.pythonhosted.org/packages/f8/e2/34683c23ce657b7df4aea1ad2be50d8565aa3407dd00f4227e773c7f1948/invenio_records_lom-0.18.4.tar.gz", hash = "sha256:87949eacf32f7917055e46debe39fb46f85b442da11f89435f45a361f694f650", size = 180272, upload_time = "2025-06-06T09:22:37.648Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/4e/44/314094313db0a002e1f781b3a1b93cd88d7379129a192371b364eab12e45/invenio_records_lom-0.18.2-py2.py3-none-any.whl", hash = "sha256:bf3d5e30226980c241fdfcdb32598c89c8d281f565432ffbe43d7ab1f5b6d265", size = 237712, upload_time = "2025-05-22T22:21:13.247Z" },
{ url = "https://files.pythonhosted.org/packages/15/07/3ee50b4c0b48e597615cb6416cae95f5f58f26c89c73a7736d14a104ba8c/invenio_records_lom-0.18.4-py2.py3-none-any.whl", hash = "sha256:eb8922fbde403b8125d8b9c793343931573d05a3c1b5e7a5e401e7d7f788dd55", size = 237734, upload_time = "2025-06-06T09:22:35.957Z" },
]
[[package]]
@@ -2391,11 +2391,10 @@ source = { editable = "." }
dependencies = [
{ name = "invenio-assets" },
{ name = "invenio-config-iform" },
{ name = "invenio-i18n" },
{ name = "invenio-records-global-search", version = "0.2.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" },
{ name = "invenio-records-global-search", version = "0.3.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
{ name = "invenio-records-lom", version = "0.16.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" },
{ name = "invenio-records-lom", version = "0.18.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
{ name = "invenio-records-lom", version = "0.18.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
{ name = "invenio-records-marc21", version = "0.22.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" },
{ name = "invenio-records-marc21", version = "0.24.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
]
@@ -2428,7 +2427,6 @@ tests = [
requires-dist = [
{ name = "invenio-assets", specifier = ">=2.0.0" },
{ name = "invenio-config-iform", specifier = ">=2025.5.20.1" },
{ name = "invenio-i18n", specifier = ">=1.3.1" },
{ name = "invenio-records-global-search", specifier = ">=0.0.1" },
{ name = "invenio-records-lom", specifier = ">=0.16.0" },
{ name = "invenio-records-marc21", specifier = ">=0.21.0" },