From 542ca59d4edfce670a814f2db863d10c02575e8c Mon Sep 17 00:00:00 2001 From: Cyprien de Cerval Date: Fri, 29 Jul 2022 13:00:50 +0200 Subject: [PATCH] add custom link to nav bar --- re2o/settings_local.example.py | 1 + re2o/templatetags/custom_link.py | 18 ++++++++++++++++++ templates/nav.html | 4 ++++ 3 files changed, 23 insertions(+) create mode 100644 re2o/templatetags/custom_link.py diff --git a/re2o/settings_local.example.py b/re2o/settings_local.example.py index a70663db..3b0d0a58 100644 --- a/re2o/settings_local.example.py +++ b/re2o/settings_local.example.py @@ -118,6 +118,7 @@ OPTIONNAL_APPS_RE2O = () # Some Django apps you want to add in you local project OPTIONNAL_APPS = OPTIONNAL_APPS_RE2O + () +OPTIONNAL_LINK_RE2O= () # Add statiffiles dir that were installed using system packaging # Example to reproduce re2o2.9 behavior # SYSTEM_STATICFILES_DIRS = ("/usr/share/fonts-font-awesome/", "/usr/share/javascript/") diff --git a/re2o/templatetags/custom_link.py b/re2o/templatetags/custom_link.py new file mode 100644 index 00000000..f9046097 --- /dev/null +++ b/re2o/templatetags/custom_link.py @@ -0,0 +1,18 @@ +from django import template +from re2o.settings_local import OPTIONNAL_LINK_RE2O + +register = template.Library() + +@register.simple_tag +def nav_link_nologin(): + template = """ +
  • + + {} + +
  • + """ + res = "" + for link in OPTIONNAL_LINK_RE2O: + res += template.format(link[0],link[1],link[2]) + return res \ No newline at end of file diff --git a/templates/nav.html b/templates/nav.html index 8efca1c8..6dc6e84c 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load static %} {% load acl %} +{% load custom_link %} {% load i18n %}