chiark / gitweb /
theme: apply format_siteurl to all navbar and feed links.
authorVladimír Vondruš <mosra@centrum.cz>
Thu, 2 Nov 2017 19:43:41 +0000 (20:43 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Thu, 2 Nov 2017 19:52:51 +0000 (20:52 +0100)
So all URLs are absolute.

doc/css/page-layout.rst
doc/pelican/theme.rst
pelican-theme/templates/base.html
site/pelicanconf.py

index f0d3862db20df571006217274ce8e9e26dabe441..76135f9a9e7a13830dd106497b57d9880e5a4c80 100644 (file)
@@ -267,10 +267,10 @@ just the builtin ``m.css`` grid features:
           </div>
           <div class="m-clearfix-t"></div>
           <div class="m-col-s-3 m-col-t-6">
-            <h3><a href="#">Contact</a></h3>
+            <h3>Contact</h3>
             <ul>
-              <li><a href="#">E-mail</a></li>
-              <li><a href="#">GitHub</a></li>
+              <li><a href="mailto:you@your.brand">E-mail</a></li>
+              <li><a href="https://github.com/your-brand">GitHub</a></li>
             </ul>
           </div>
           <div class="m-col-s-3 m-col-t-6">
index 6f08f2764d0bf711e855563f7b4c2cfc86f7f805..7dd806258a31bfb212c67001da529187e4d6f492 100644 (file)
@@ -135,7 +135,8 @@ to highlight currently active menu item) and fourth is a list of sub-menu items
 will make the menu item never highlighted; providing an empty list of sub-menu
 items will not add any submenu. All blog-related pages (articles, article
 listing, authors, tags, categories etc.) have the slug set to a special value
-``[blog]``.
+``[blog]``. The URL is prepended with :py:`SITEURL` unless it contains also
+domain name, then it's left as-is (`detailed behavior <{filename}/plugins/htmlsanity.rst#siteurl-formatting>`_).
 
 Example configuration, matching example markup from the
 `CSS page layout <{filename}/css/page-layout.rst#sub-menus-in-the-navbar>`__
@@ -145,14 +146,14 @@ documentation:
 
     SITE_LOGO_TEXT = 'Your Brand'
 
-    LINKS_NAVBAR1 = [('Features', '/features/', 'features', []),
-                     ('Showcase', '/showcase/', 'showcase', []),
-                     ('Download', '/download/', 'download', [])]
+    LINKS_NAVBAR1 = [('Features', 'features/', 'features', []),
+                     ('Showcase', 'showcase/', 'showcase', []),
+                     ('Download', 'download/', 'download', [])]
 
-    LINKS_NAVBAR2 = [('Blog', '/blog/', '[blog]', [
-                        ('News', '/blog/news/', ''),
-                        ('Archive', '/blog/archive/', '')]),
-                     ('Contact', '/contact/', 'contact', [])]
+    LINKS_NAVBAR2 = [('Blog', 'blog/', '[blog]', [
+                        ('News', 'blog/news/', ''),
+                        ('Archive', 'blog/archive/', '')]),
+                     ('Contact', 'contact/', 'contact', [])]
 
 `Footer navigation`_
 --------------------
@@ -167,7 +168,8 @@ given column empty.
 
 The variables are lists of 2-tuples, containing link title and URL. First item
 is used for column header, if link URL of the first item is empty, given column
-header is just a plain :html:`<h3>` without a link.
+header is just a plain :html:`<h3>` without a link. The URLs are processed in
+the same way as in the `top navbar`_.
 
 Footer fine print can be specified via :py:`FINE_PRINT`. Contents of the
 variable are processed as :abbr:`reST <reStructuredText>`, so you can use all
@@ -180,16 +182,16 @@ documentation, populating the last column implicitly:
 .. code:: py
 
     LINKS_FOOTER1 = [('Your Brand', '/'),
-                     ('Features', '/features/'),
-                     ('Showcase', '/showcase/')]
+                     ('Features', 'features/'),
+                     ('Showcase', 'showcase/')]
 
-    LINKS_FOOTER2 = [('Download', '/download/'),
-                     ('Packages', '/download/packages/'),
-                     ('Source', '/download/source/')]
+    LINKS_FOOTER2 = [('Download', 'download/'),
+                     ('Packages', 'download/packages/'),
+                     ('Source', 'download/source/')]
 
-    LINKS_FOOTER3 = [('Contact', '/contact/'),
-                     ('E-mail', '#'),
-                     ('GitHub', '#')]
+    LINKS_FOOTER3 = [('Contact', ''),
+                     ('E-mail', 'mailto:you@your.brand'),
+                     ('GitHub', 'https://github.com/your-brand')]
 
     FINE_PRINT = """
     Your Brand. Copyright © `You <mailto:you@your.brand>`_, 2017. All rights
index 11ecef6811cbccabe93fe75355f61efa1c7068a9..64e517fe6a37da2f641b56ae76ac0631822a27b6 100644 (file)
   <meta name="theme-color" content="{{ THEME_COLOR }}" />
   {% endif %}
   {% if FEED_ALL_ATOM_URL %}
-  <link href="{{ FEED_ALL_ATOM_URL }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }}" />
+  <link href="{{ FEED_ALL_ATOM_URL|format_siteurl }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }}" />
   {% endif %}
   {% if CATEGORY_FEED_ATOM_URL and category %}
-  <link href="{{ CATEGORY_FEED_ATOM_URL|format(category.slug) }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} | {{ category }}" />
+  <link href="{{ CATEGORY_FEED_ATOM_URL|format(category.slug)|format_siteurl }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} | {{ category }}" />
   {% endif %}
   {% endblock head %}
 </head>
           <ol class="m-col-t-6 m-col-m-none">
             {% for title, link, slug, sub in LINKS_NAVBAR1 %}
             <li>
-              <a href="{{ link }}"{% if (page and page.highlight == slug) or slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a>
+              <a href="{{ link|format_siteurl }}"{% if (page and page.highlight == slug) or slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a>
               {% if sub %}
               <ol>
                 {% for title, link, slug in sub %}
-                <li><a href="{{ link }}"{% if (page and page.highlight == slug) or slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a></li>
+                <li><a href="{{ link|format_siteurl }}"{% if (page and page.highlight == slug) or slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a></li>
                 {% endfor %}
               </ol>
               {% endif %}
           <ol class="m-col-t-6 m-col-m-none">
             {% for title, link, slug, sub in LINKS_NAVBAR2 %}
             <li>
-              <a href="{{ link }}"{% if (page and page.highlight == slug) or slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a>
+              <a href="{{ link|format_siteurl }}"{% if (page and page.highlight == slug) or slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a>
               {% if sub %}
               <ol>
                 {% for title, link, slug in sub %}
-                <li><a href="{{ link }}"{% if (page and page.highlight == slug) or slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a></li>
+                <li><a href="{{ link|format_siteurl }}"{% if (page and page.highlight == slug) or slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a></li>
                 {% endfor %}
               </ol>
               {% endif %}
       <div class="m-col-s-3 m-col-t-6">
         {% if LINKS_FOOTER1 %}
         <h3>
-          {%- if LINKS_FOOTER1[0][1] %}<a href="{{ LINKS_FOOTER1[0][1] }}">{% endif %}
+          {%- if LINKS_FOOTER1[0][1] %}<a href="{{ LINKS_FOOTER1[0][1]|format_siteurl }}">{% endif %}
           {{- LINKS_FOOTER1[0][0] -}}
           {% if LINKS_FOOTER1[0][1] -%}</a>{% endif -%}
         </h3>
         <ul>
           {% for title, link in LINKS_FOOTER1 %}{% if loop.index0 != 0 %}
-          <li><a href="{{ link }}">{{ title }}</a></li>
+          <li><a href="{{ link|format_siteurl }}">{{ title }}</a></li>
           {% endif %}{% endfor %}
         </ul>
         {% endif %}
       <div class="m-col-s-3 m-col-t-6">
         {% if LINKS_FOOTER2 %}
         <h3>
-          {%- if LINKS_FOOTER2[0][1] %}<a href="{{ LINKS_FOOTER2[0][1] }}">{% endif %}
+          {%- if LINKS_FOOTER2[0][1] %}<a href="{{ LINKS_FOOTER2[0][1]|format_siteurl }}">{% endif %}
           {{- LINKS_FOOTER2[0][0] -}}
           {% if LINKS_FOOTER2[0][1] %}</a>{% endif -%}
         </h3>
         <ul>
           {% for title, link in LINKS_FOOTER2 %}{% if loop.index0 != 0 %}
-          <li><a href="{{ link }}">{{ title }}</a></li>
+          <li><a href="{{ link|format_siteurl }}">{{ title }}</a></li>
           {% endif %}{% endfor %}
         </ul>
         {% endif %}
       <div class="m-col-s-3 m-col-t-6">
         {% if LINKS_FOOTER3 %}
         <h3>
-          {%- if LINKS_FOOTER3[0][1] %}<a href="{{ LINKS_FOOTER3[0][1] }}">{% endif %}
+          {%- if LINKS_FOOTER3[0][1] %}<a href="{{ LINKS_FOOTER3[0][1]|format_siteurl }}">{% endif %}
           {{- LINKS_FOOTER3[0][0] -}}
           {% if LINKS_FOOTER3[0][1] %}</a>{% endif -%}
         </h3>
         <ul>
           {% for title, link in LINKS_FOOTER3 %}{% if loop.index0 != 0 %}
-          <li><a href="{{ link }}">{{ title }}</a></li>
+          <li><a href="{{ link|format_siteurl }}">{{ title }}</a></li>
           {% endif %}{% endfor %}
         </ul>
         {% endif %}
       <div class="m-col-s-3 m-col-t-6">
         {% if LINKS_FOOTER4 %}
         <h3>
-          {%- if LINKS_FOOTER4[0][1] %}<a href="{{ LINKS_FOOTER4[0][1] }}">{% endif %}
+          {%- if LINKS_FOOTER4[0][1] %}<a href="{{ LINKS_FOOTER4[0][1]|format_siteurl }}">{% endif %}
           {{- LINKS_FOOTER4[0][0] -}}
           {% if LINKS_FOOTER4[0][1] %}</a>{% endif -%}
         </h3>
         <ul>
           {% for title, link in LINKS_FOOTER4 %}{% if loop.index0 != 0 %}
-          <li><a href="{{ link }}">{{ title }}</a></li>
+          <li><a href="{{ link|format_siteurl }}">{{ title }}</a></li>
           {% endif %}{% endfor %}
         </ul>
         {% else %}
index 26e59607919c9d619945e4cd4f68c36370fb8055..91496fa43cc4e5fc038bab317dfb90639d4611e3 100644 (file)
@@ -51,48 +51,48 @@ TRANSLATION_FEED_ATOM = None
 AUTHOR_FEED_ATOM = None
 AUTHOR_FEED_RSS = None
 
-LINKS_NAVBAR1 = [('Why?', '/why/', 'why', []),
-                 ('CSS', '/css/', 'css', [
-                    ('Grid system', '/css/grid/', 'css/grid'),
-                    ('Typography', '/css/typography/', 'css/typography'),
-                    ('Components', '/css/components/', 'css/components'),
-                    ('Page layout', '/css/page-layout/', 'css/page-layout'),
-                    ('Themes', '/css/themes/', 'css/themes')]),
-                 ('Pelican', '/pelican/', 'pelican', [
-                    ('Writing content', '/pelican/writing-content/', 'pelican/writing-content'),
-                    ('Theme', '/pelican/theme/', 'pelican/theme')])]
-
-LINKS_NAVBAR2 = [('Pelican plugins', '/plugins/', 'plugins', [
-                    ('HTML sanity', '/plugins/htmlsanity/', 'plugins/htmlsanity'),
-                    ('Components', '/plugins/components/', 'plugins/components'),
-                    ('Images', '/plugins/images/', 'plugins/images'),
-                    ('Math and code', '/plugins/math-and-code/', 'plugins/math-and-code'),
-                    ('Links', '/plugins/links/', 'plugins/links')]),
+LINKS_NAVBAR1 = [('Why?', 'why/', 'why', []),
+                 ('CSS', 'css/', 'css', [
+                    ('Grid system', 'css/grid/', 'css/grid'),
+                    ('Typography', 'css/typography/', 'css/typography'),
+                    ('Components', 'css/components/', 'css/components'),
+                    ('Page layout', 'css/page-layout/', 'css/page-layout'),
+                    ('Themes', 'css/themes/', 'css/themes')]),
+                 ('Pelican', 'pelican/', 'pelican', [
+                    ('Writing content', 'pelican/writing-content/', 'pelican/writing-content'),
+                    ('Theme', 'pelican/theme/', 'pelican/theme')])]
+
+LINKS_NAVBAR2 = [('Pelican plugins', 'plugins/', 'plugins', [
+                    ('HTML sanity', 'plugins/htmlsanity/', 'plugins/htmlsanity'),
+                    ('Components', 'plugins/components/', 'plugins/components'),
+                    ('Images', 'plugins/images/', 'plugins/images'),
+                    ('Math and code', 'plugins/math-and-code/', 'plugins/math-and-code'),
+                    ('Links', 'plugins/links/', 'plugins/links')]),
                  ('GitHub', 'https://github.com/mosra/m.css', '', [])]
 
 LINKS_FOOTER1 = [('m.css', '/'),
-                 ('Why?', '/why/'),
+                 ('Why?', 'why/'),
                  ('GitHub', 'https://github.com/mosra/m.css'),
                  ('Gitter', 'https://gitter.im/mosra/m.css'),
                  ('Twitter', 'https://twitter.com/czmosra')]
 
-LINKS_FOOTER2 = [('CSS', '/css/'),
-                 ('Grid system', '/css/grid/'),
-                 ('Typography', '/css/typography/'),
-                 ('Components', '/css/components/'),
-                 ('Page layout', '/css/page-layout/'),
-                 ('Themes', '/css/themes/')]
-
-LINKS_FOOTER3 = [('Pelican', '/pelican/'),
-                 ('Writing content', '/pelican/writing-content/'),
-                 ('Theme', '/pelican/theme/')]
-
-LINKS_FOOTER4 = [('Pelican plugins', '/plugins/'),
-                 ('HTML sanity', '/plugins/htmlsanity/'),
-                 ('Components', '/plugins/components/'),
-                 ('Images', '/plugins/images/'),
-                 ('Math and code', '/plugins/math-and-code/'),
-                 ('Links', '/plugins/links/')]
+LINKS_FOOTER2 = [('CSS', 'css/'),
+                 ('Grid system', 'css/grid/'),
+                 ('Typography', 'css/typography/'),
+                 ('Components', 'css/components/'),
+                 ('Page layout', 'css/page-layout/'),
+                 ('Themes', 'css/themes/')]
+
+LINKS_FOOTER3 = [('Pelican', 'pelican/'),
+                 ('Writing content', 'pelican/writing-content/'),
+                 ('Theme', 'pelican/theme/')]
+
+LINKS_FOOTER4 = [('Pelican plugins', 'plugins/'),
+                 ('HTML sanity', 'plugins/htmlsanity/'),
+                 ('Components', 'plugins/components/'),
+                 ('Images', 'plugins/images/'),
+                 ('Math and code', 'plugins/math-and-code/'),
+                 ('Links', 'plugins/links/')]
 
 FINE_PRINT = """
 m.css. Copyright © Vladimír Vondruš 2017. Site powered by `Pelican <https://getpelican.com>`_