diff --git a/sipa/flatpages.py b/sipa/flatpages.py index ab9ade6d..9622e30e 100644 --- a/sipa/flatpages.py +++ b/sipa/flatpages.py @@ -132,6 +132,12 @@ def hidden(self) -> bool: """ return self.localized_page.meta.get('hidden', False) + @property + def icon(self) -> str: + return self.localized_page.meta.get("icon") or self.localized_page.meta.get( + "glyphicon" + ) + def __getattr__(self, attr: str) -> str: """Return the meta attribute of the localized page diff --git a/sipa/initialization.py b/sipa/initialization.py index 0738e6ef..be7037a9 100644 --- a/sipa/initialization.py +++ b/sipa/initialization.py @@ -99,6 +99,37 @@ def init_app(app, **kwargs): app.context_processor(inject_meetingcal) app.add_template_filter(render_links) + + def glyphicon_to_bi(glyphicon: str) -> str: + MAP = { + "glyphicon-briefcase": "bi-briefcase-fill", + "glyphicon-bullhorn": "bi-megaphone-fill", + "glyphicon-chevron-down": "bi-chevron-down", + "glyphicon-cloud": "bi-cloud-fill", + "glyphicon-comment": "bi-chat-left-fill", + "glyphicon-dashboard": "bi-speedometer", + "glyphicon-download-alt": "bi-download", + "glyphicon-envelope": "bi-envelope-fill", + "glyphicon-euro": "bi-currency-euro", + "glyphicon-file": "bi-file-earmark-fill", + "glyphicon-globe": "bi-globe-europe-africa", + "glyphicon-headphones": "bi-headphones", + "glyphicon-list-alt": "bi-card-list", + "glyphicon-lock": "bi-lock-fill", + "glyphicon-log-in": "bi-box-arrow-in-right", + "glyphicon-question-sign": "bi-question-circle-fill", + "glyphicon-retweet": "bi-arrow-repeat", + "glyphicon-signal": "bi-router-fill", # used for router page + "glyphicon-star": "bi-star-fill", + "glyphicon-tasks": "bi-box-arrow-up-right", + "glyphicon-tint": "bi-droplet-fill", + "glyphicon-transfer": "bi-arrow-left-right", + "glyphicon-user": "bi-person-fill", + "glyphicon-wrench": "bi-wrench-adjustable", + } + return MAP.get(glyphicon, glyphicon.replace("glyphicon-", "bi-")) + + app.add_template_filter(glyphicon_to_bi) logger.debug("Jinja globals have been set", extra={'data': {'jinja_globals': app.jinja_env.globals}}) diff --git a/sipa/templates/base.html b/sipa/templates/base.html index 0930067b..3c438c2e 100644 --- a/sipa/templates/base.html +++ b/sipa/templates/base.html @@ -136,7 +136,7 @@ {%- for article in c.articles -%} {%- if not article.id == 'index' and article.title and not article.hidden -%} - +   {{ article.title }} {%- endif %}