-
Notifications
You must be signed in to change notification settings - Fork 55
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
add init function #355
Merged
kpsherva
merged 9 commits into
inveniosoftware:master
from
utnapischtim:add-init-function
Mar 20, 2024
Merged
add init function #355
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a896927
global: remove breadcrumbs
utnapischtim b740de4
global: introduce shared menu
utnapischtim 65d2727
global: refactor current_theme_icons
utnapischtim 42b23c6
setup: use pytest-black-ng instead of pytest-black
utnapischtim 33ee9df
templates: use current_menu instead of menu
utnapischtim a603135
global: move blueprint and ui to views.py
utnapischtim d6541d3
fix: docs
utnapischtim 64690c3
release: v3.0.0
utnapischtim b743e9d
chore: formatting
kpsherva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of Invenio. | ||
# Copyright (C) 2020 CERN. | ||
# | ||
# 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. | ||
|
||
"""Theme Icons.""" | ||
|
||
|
||
class ThemeIcons: | ||
"""Defines names for theme icons used in CSS classes. | ||
|
||
This class is used via the proxy ``current_theme_icons``, which initialize | ||
it with the right parameters. Also, the ``current_theme_icons`` proxy is | ||
automatically available in templates because it is added via a template | ||
context processor. | ||
|
||
Examples of usage: | ||
|
||
.. code-block:: python | ||
|
||
current_theme_icons.cogs | ||
current_theme_icons['cogs'] | ||
|
||
Note, that the proxy is dependent on the Flask application context, thus | ||
it can often be useful to wrap it in lazy string, to only have it evaluated | ||
when needed: | ||
|
||
.. code-block:: python | ||
|
||
from invenio_i18n import LazyString | ||
LazyString(lambda: f'<i class="{current_theme_icons.cogs}"></i>') | ||
""" | ||
|
||
def __init__(self, app_themes, theme_icons): | ||
"""Initialize.""" | ||
self._app_themes = app_themes or [] | ||
self._theme_icons = theme_icons or {} | ||
|
||
def __getattr__(self, name): | ||
"""Attribute support for getting an icon.""" | ||
return self.__getitem__(name) | ||
|
||
def __getitem__(self, key): | ||
"""Get a icon for a specific theme.""" | ||
for theme in self._app_themes: | ||
if theme in self._theme_icons: | ||
# Icon exists for theme | ||
if key in self._theme_icons[theme]: | ||
return self._theme_icons[theme][key] | ||
# Pattern exists for theme | ||
# If an icon is not defined we create it via a pattern - | ||
# e.g. the smeantic ui pattern is ``{} icon`` and the | ||
# bootstrap3 pattern is ``fa fa-{} fa-fw``. | ||
elif "*" in self._theme_icons[theme]: | ||
return self._theme_icons[theme]["*"].format(key) | ||
return "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor: we're now establishing a naming convention for these types of "shared extensions" files. I'm aware that we have the same name in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of Invenio. | ||
# Copyright (C) 2023 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. | ||
|
||
"""Invenio standard theme.""" | ||
|
||
from flask_menu.menu import MenuNode | ||
|
||
menu = MenuNode("", None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.