Skip to content
Snippets Groups Projects
Commit be768196 authored by Jan Mach's avatar Jan Mach
Browse files

Improved support for icon customizations.

Application icons are now part of configuration instead of contant definitions.
parent 7d0a5da1
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,7 @@ AODS_IP4 = 'ip4'
AODS_IP6 = 'ip6'
FA_ICONS = {
ICONS = {
#
# General icons.
......
......@@ -84,7 +84,7 @@ class Vial(flask.Flask): # pylint: disable=locally-disabled,too-many-instance-a
"""
Application icon registry.
"""
return vial.const.FA_ICONS
return self.config.get('ICONS')
@flask.app.setupmethod
def add_url_rule(self, rule, endpoint = None, view_func = None, provide_automatic_options = None, **options):
......@@ -481,8 +481,7 @@ class Vial(flask.Flask): # pylint: disable=locally-disabled,too-many-instance-a
def get_icon(icon_name, default_icon = 'missing-icon'):
"""
Get HTML icon markup for given icon. The icon will be looked up in
the :py:const:`vial.const.FA_ICONS` lookup table.
Get HTML icon markup for given icon.
:param str icon_name: Name of the icon.
:param str default_icon: Name of the default icon.
......@@ -490,9 +489,9 @@ class Vial(flask.Flask): # pylint: disable=locally-disabled,too-many-instance-a
:rtype: flask.Markup
"""
return flask.Markup(
vial.const.FA_ICONS.get(
self.config.get('ICONS').get(
icon_name,
vial.const.FA_ICONS.get(default_icon)
self.config.get('ICONS').get(default_icon)
)
)
......@@ -506,9 +505,9 @@ class Vial(flask.Flask): # pylint: disable=locally-disabled,too-many-instance-a
:rtype: flask.Markup
"""
return flask.Markup(
vial.const.FA_ICONS.get(
self.config.get('ICONS').get(
self.get_endpoint_class(endpoint).module_ref().get_module_icon(),
vial.const.FA_ICONS.get(default_icon)
self.config.get('ICONS').get(default_icon)
)
)
......@@ -521,9 +520,9 @@ class Vial(flask.Flask): # pylint: disable=locally-disabled,too-many-instance-a
:rtype: flask.Markup
"""
return flask.Markup(
vial.const.FA_ICONS.get(
self.config.get('ICONS').get(
self.get_endpoint_class(endpoint).get_view_icon(),
vial.const.FA_ICONS.get(default_icon)
self.config.get('ICONS').get(default_icon)
)
)
......
......@@ -171,6 +171,8 @@ class Config: # pylint: disable=locally-disabled,too-few-public-methods
LOG_EMAIL_LEVEL = 'error'
"""File logging level, case insensitive. One of the values ``DEBUG``, ``INFO``, ``WARNING``, ``ERROR``, ``CRITICAL``."""
ICONS = vial.const.ICONS
class ProductionConfig(Config): # pylint: disable=locally-disabled,too-few-public-methods
"""
......
......@@ -176,7 +176,7 @@ ICON_NAME_MISSING_ICON = 'missing-icon'
"""Name of the icon to display instead of missing icons."""
FA_ICONS = {
ICONS = {
#
# General icons.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment