Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump major #208

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion invenio_search_ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,6 @@ def my_record_search():

from .ext import InvenioSearchUI

__version__ = "3.0.1"
__version__ = "4.0.0"

__all__ = ("__version__", "InvenioSearchUI")
5 changes: 1 addition & 4 deletions invenio_search_ui/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
#
# 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.

"""UI for Invenio-Search."""

from . import config
from .views import blueprint, search


class InvenioSearchUI(object):
Expand All @@ -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.

Expand Down
45 changes: 27 additions & 18 deletions invenio_search_ui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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():
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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"]}
16 changes: 8 additions & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ 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]
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 =
Expand Down
7 changes: 4 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
Expand Down Expand Up @@ -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")
Expand Down