From 5251f12a56813f465a6521ccaf5e869fbfee92fb Mon Sep 17 00:00:00 2001 From: Vitaly Potyarkin Date: Thu, 17 Oct 2019 17:41:50 +0300 Subject: [PATCH] Use macro for URLs that may be relative to site root There are multiple places in the theme where URL value may be either relative to site root or pointing to a third-party resource. Separating the handler logic into a macro makes sense. Now BOOTSTRAP_CSS may contain paths relative to site root - that allows users to apply custom Boostwatch themes without depending on third party resources (custom theme may be included as static file and referenced via relative path). --- alchemy/templates/base.html | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/alchemy/templates/base.html b/alchemy/templates/base.html index ba8b07a..681f92e 100644 --- a/alchemy/templates/base.html +++ b/alchemy/templates/base.html @@ -1,3 +1,12 @@ +{%- macro url(destination) -%} +{%- if destination|lower|truncate(4, True, '') == 'http' or not destination -%} +{{ destination }} +{%- elif destination|first == '/' -%} +{{ SITEURL + destination }} +{%- else -%} +{{ SITEURL + '/' + destination }} +{%- endif -%} +{%- endmacro -%} @@ -17,16 +26,12 @@ {% endif %} - + {% for stylesheet in THEME_CSS_OVERRIDES or () %} - {% if stylesheet|lower|truncate(4, True, '') == 'http' %} - - {% else %} - - {% endif %} + {% endfor %} {% include 'include/xml_feeds.html' %}