From a1a09f2329ce00b1996bf2ac106986d36bd5b5cc Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Sat, 30 Nov 2024 20:32:19 +0100 Subject: [PATCH 1/3] setup: bump major dependencies --- setup.cfg | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/setup.cfg b/setup.cfg index 5a68d78..644fdd3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,16 +28,16 @@ python_requires = >=3.7 zip_safe = False install_requires = Babel>=2.8 - invenio-assets>=2.0.0,<4.0.0 - invenio-base>=1.2.11,<2.0.0 - invenio-i18n>=2.0.0,<3.0.0 + invenio-assets>=4.0.0,<5.0.0 + invenio-base>=2.0.0,<3.0.0 + invenio-i18n>=3.0.0,<4.0.0 [options.extras_require] tests = - pytest-black>=0.3.0 - invenio-db>=1.0.8,<2.0.0 - invenio-records>=1.0.0,<3.0.0 - pytest-invenio>=1.4.11,<3.0.0 + pytest-black-ng>=0.4.0 + invenio-db>=2.0.0,<3.0.0 + invenio-records>=3.0.0,<4.0.0 + pytest-invenio>=3.0.0,<4.0.0 sphinx>=4.5 [options.entry_points] From 36b7b5b094ce942508dc9d624b9b466724ae4cd2 Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Fri, 6 Dec 2024 09:16:48 +0100 Subject: [PATCH 2/3] refactor: blueprint creation to new style --- invenio_search_ui/ext.py | 5 +---- invenio_search_ui/views.py | 45 +++++++++++++++++++++++--------------- setup.cfg | 2 +- tests/conftest.py | 7 +++--- 4 files changed, 33 insertions(+), 26 deletions(-) diff --git a/invenio_search_ui/ext.py b/invenio_search_ui/ext.py index 26bd9c2..a01e073 100644 --- a/invenio_search_ui/ext.py +++ b/invenio_search_ui/ext.py @@ -2,6 +2,7 @@ # # This file is part of Invenio. # Copyright (C) 2015-2022 CERN. +# Copyright (C) 2024 Graz University of Technology. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. @@ -9,7 +10,6 @@ """UI for Invenio-Search.""" from . import config -from .views import blueprint, search class InvenioSearchUI(object): @@ -31,9 +31,6 @@ def init_app(self, app): self.init_config(app) app.extensions["invenio-search-ui"] = self - search_view = app.config.get("SEARCH_UI_SEARCH_VIEW", search) - blueprint.add_url_rule("/search", "search", view_func=search_view) - def init_config(self, app): """Initialize configuration. diff --git a/invenio_search_ui/views.py b/invenio_search_ui/views.py index 8ec218d..c59487a 100644 --- a/invenio_search_ui/views.py +++ b/invenio_search_ui/views.py @@ -2,6 +2,7 @@ # # This file is part of Invenio. # Copyright (C) 2015-2022 CERN. +# Copyright (C) 2024 Graz University of Technology. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. @@ -12,12 +13,32 @@ from flask import Blueprint, current_app, json, render_template -blueprint = Blueprint( - "invenio_search_ui", - __name__, - template_folder="templates", - static_folder="static", -) + +def create_blueprint(app): + """Create blueprint.""" + blueprint = Blueprint( + "invenio_search_ui", + __name__, + template_folder="templates", + static_folder="static", + ) + + search_view = app.config.get("SEARCH_UI_SEARCH_VIEW", search) + blueprint.add_url_rule("/search", "search", view_func=search_view) + + blueprint.add_app_template_filter(format_sortoptions, name="format_sortoptions") + + @blueprint.app_context_processor + def search_app_helpers(): + """Makes Invenio-Search-JS config generation available for Jinja.""" + return {"search_app_helpers": current_app.config["SEARCH_UI_SEARCH_CONFIG_GEN"]} + + return blueprint + + +def format_sortoptions(sort_options): + """Create sort options JSON dump for Invenio-Search-JS.""" + return json.dumps({"options": sorted_options(sort_options)}) def search(): @@ -46,12 +67,6 @@ def sorted_options(sort_options): ] -@blueprint.app_template_filter("format_sortoptions") -def format_sortoptions(sort_options): - """Create sort options JSON dump for Invenio-Search-JS.""" - return json.dumps({"options": sorted_options(sort_options)}) - - class SearchAppInvenioRestConfigHelper(object): """Configuration generator for Invenio-Search-JS. @@ -247,9 +262,3 @@ def generate(cls, options, **kwargs): } config.update(kwargs) return config - - -@blueprint.app_context_processor -def search_app_helpers(): - """Makes Invenio-Search-JS config generation available for Jinja.""" - return {"search_app_helpers": current_app.config["SEARCH_UI_SEARCH_CONFIG_GEN"]} diff --git a/setup.cfg b/setup.cfg index 644fdd3..e1451a8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -44,7 +44,7 @@ tests = invenio_base.apps = invenio_search_ui = invenio_search_ui:InvenioSearchUI invenio_base.blueprints = - invenio_search_ui = invenio_search_ui.views:blueprint + invenio_search_ui = invenio_search_ui.views:create_blueprint invenio_search_ui.translations = messages = invenio_search_ui invenio_assets.webpack = diff --git a/tests/conftest.py b/tests/conftest.py index a3dede3..f3ac20e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,7 +2,7 @@ # # This file is part of Invenio. # Copyright (C) 2015-2022 CERN. -# Copyright (C) 2023 Graz University of Technology. +# Copyright (C) 2023-2024 Graz University of Technology. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. @@ -20,7 +20,7 @@ from invenio_i18n import Babel from invenio_search_ui import InvenioSearchUI -from invenio_search_ui.views import blueprint +from invenio_search_ui.views import create_blueprint @pytest.yield_fixture() @@ -49,7 +49,8 @@ def app(): def api(): return {} - app.register_blueprint(blueprint) + app.register_blueprint(create_blueprint(app)) + # add extra test templates to the search app blueprint, to fake the # existence of `invenio-theme` base templates. test_templates_path = os.path.join(os.path.dirname(__file__), "templates") From 4eda79b11af35daac79130604312db1ac13258b0 Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Fri, 6 Dec 2024 09:17:29 +0100 Subject: [PATCH 3/3] release: v4.0.0 --- CHANGES.rst | 6 ++++++ invenio_search_ui/__init__.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index d34efad..c8ca0c9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,12 @@ Changes ======= + +Version 4.0.0 (released 2024-12-05) + +- refactor: blueprint creation to new style +- setup: bump major dependencies + Version 3.0.1 (release 2024-11-30) - setup: change to reusable workflows diff --git a/invenio_search_ui/__init__.py b/invenio_search_ui/__init__.py index 619d806..6872132 100644 --- a/invenio_search_ui/__init__.py +++ b/invenio_search_ui/__init__.py @@ -328,6 +328,6 @@ def my_record_search(): from .ext import InvenioSearchUI -__version__ = "3.0.1" +__version__ = "4.0.0" __all__ = ("__version__", "InvenioSearchUI")