ソースを参照

Consolidate all default strings and integer values into a single to help user customize the theme

User can read the variable name from _defaults.html and customize it in the file or in the pelicanconf.py file.
pelicanconf.py has higher precedence over _defaults.html file.

Update #96
Talha Mansoor 11 年 前
コミット
98735e88a6
共有5 個のファイルを変更した49 個の追加16 個の削除を含む
  1. 42 0
      templates/_includes/_defaults.html
  2. 3 9
      templates/_includes/mailchimp.html
  3. 2 1
      templates/_includes/related_posts.html
  4. 1 3
      templates/_includes/social_links.html
  5. 1 3
      templates/index.html

+ 42 - 0
templates/_includes/_defaults.html

@@ -0,0 +1,42 @@
+{# Heading for the list of related posts #}
+{% if not RELATED_POSTS_LABEL %}
+{% set RELATED_POSTS_LABEL = 'Related Posts' %}
+{% else %}
+{% set RELATED_POSTS_LABEL = RELATED_POSTS_LABEL %}
+{% endif %}
+
+{# Heading for the list of social profiles #}
+{% if not SOCIAL_PROFILE_LABEL %}
+{% set SOCIAL_PROFILE_LABEL = 'Contact' %}
+{% else %}
+{% set SOCIAL_PROFILE_LABEL = SOCIAL_PROFILE_LABEL %}
+{% endif %}
+
+{# Heading for the Email subscription form #}
+{% if not EMAIL_SUBSCRIPTION_LABEL %}
+{% set EMAIL_SUBSCRIPTION_LABEL = 'Email Newsletter' %}
+{% else %}
+{% set EMAIL_SUBSCRIPTION_LABEL = EMAIL_SUBSCRIPTION_LABEL %}
+{% endif %}
+
+{# Placeholder text for Email field #}
+{% if not EMAIL_FIELD_PLACEHOLDER  %}
+{% set EMAIL_FIELD_PLACEHOLDER  = 'Enter your email...' %}
+{% else %}
+{% set EMAIL_FIELD_PLACEHOLDER  = EMAIL_FIELD_PLACEHOLDER  %}
+{% endif %}
+
+{# Subscribe button title #}
+{% if not SUBSCRIBE_BUTTON_TITLE  %}
+{% set SUBSCRIBE_BUTTON_TITLE  = 'Subscribe' %}
+{% else %}
+{% set SUBSCRIBE_BUTTON_TITLE  = SUBSCRIBE_BUTTON_TITLE  %}
+{% endif %}
+
+{# Count of recent articles to be shown on the home page #}
+{% if not RECENT_ARTICLES_COUNT  %}
+{% set RECENT_ARTICLES_COUNT  = 10 %}
+{% else %}
+{% set RECENT_ARTICLES_COUNT  = RECENT_ARTICLES_COUNT  %}
+{% endif %}
+

+ 3 - 9
templates/_includes/mailchimp.html

@@ -1,13 +1,7 @@
 {% if MAILCHIMP_FORM_ACTION %}
-    {% if not EMAIL_SUBSCRIPTION_LABEL %}
-        {% set EMAIL_SUBSCRIPTION_LABEL='Email Newsletter' %}
-    {% endif %}
-    {% if not SUBSCRIBE_BUTTON_TITLE %}
-        {% set SUBSCRIBE_BUTTON_TITLE='Subscribe' %}
-    {% endif %}
-    {% if not EMAIL_PLACEHOLDER %}
-        {% set EMAIL_PLACEHOLDER ='Enter your email...' %}
-    {% endif %}
+{% from '_includes/_defaults.html' import EMAIL_SUBSCRIPTION_LABEL with context %}
+{% from '_includes/_defaults.html' import EMAIL_FIELD_PLACEHOLDER with context %}
+{% from '_includes/_defaults.html' import SUBSCRIBE_BUTTON_TITLE with context %}
 <!-- Begin MailChimp Signup Form -->
 <div id="mc-embed-signup">
 <form action="{{ MAILCHIMP_FORM_ACTION }}" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>

+ 2 - 1
templates/_includes/related_posts.html

@@ -1,6 +1,7 @@
 {% if article.related_posts %}
+{% from '_includes/_defaults.html' import RELATED_POSTS_LABEL with context %}
 <section>
-<h2>Read this next</h2>
+    <h2>{{ RELATED_POSTS_LABEL }}</h2>
 <ul>
 {% for related_post in article.related_posts %}
     {% set title = related_post.title|striptags %}

+ 1 - 3
templates/_includes/social_links.html

@@ -1,7 +1,5 @@
 {% if SOCIAL %}
-    {% if not SOCIAL_PROFILE_LABEL %}
-        {% set SOCIAL_PROFILE_LABEL ='Contact' %}
-    {% endif %}
+{% from '_includes/_defaults.html' import SOCIAL_PROFILE_LABEL with context %}
 <h4>{{ SOCIAL_PROFILE_LABEL }}</h4>
 {% for entry in SOCIAL %}
 {% set f_entry = [] %}

+ 1 - 3
templates/index.html

@@ -48,9 +48,7 @@
             </header>
         <div class="recent-posts">
             {% for article in articles %}
-            {% if not RECENT_ARTICLES_COUNT %}
-            {% set RECENT_ARTICLES_COUNT = 10 %}
-            {% endif %}
+            {% from '_includes/_defaults.html' import RECENT_ARTICLES_COUNT with context %}
             {% if loop.index0 < RECENT_ARTICLES_COUNT %}
             <article>
                 <a href="{{ SITEURL }}/{{ article.url }}">{{ article.title }} {%if article.subtitle %} <small> {{ article.subtitle }} </small> {% endif %} </a>