diff options
author | Jade Dominguez <plusjade@gmail.com> | 2012-01-23 04:15:46 -0800 |
---|---|---|
committer | Jade Dominguez <plusjade@gmail.com> | 2012-01-23 04:18:22 -0800 |
commit | 6c0b6c1a1b643d5ffebd2577e98b44db58df09ec (patch) | |
tree | 11978b8e0c85dec3971a033e8f4452cf5c528ead /_includes | |
parent | 08d59a6b60f5dc72b4854867ec7f6374764e9604 (diff) |
Provide custom overrides to all helpers
Now all helpers can be overridden by custom implementations without editing JB source. Just define a helper's 'engine' as 'custom' in the _config.yml file and provide a helper file of the same name in _includes/custom/. This helps users cleanly upgrade JB versions since they no longer need to edit the files directly.
Diffstat (limited to '_includes')
-rw-r--r-- | _includes/JB/categories_list | 29 | ||||
-rw-r--r-- | _includes/JB/liquid_raw | 9 | ||||
-rw-r--r-- | _includes/JB/pages_list | 30 | ||||
-rw-r--r-- | _includes/JB/posts_collate | 51 | ||||
-rw-r--r-- | _includes/JB/setup | 27 | ||||
-rw-r--r-- | _includes/JB/tags_list | 21 |
6 files changed, 91 insertions, 76 deletions
diff --git a/_includes/JB/categories_list b/_includes/JB/categories_list index 218f525..96d2f36 100644 --- a/_includes/JB/categories_list +++ b/_includes/JB/categories_list @@ -17,18 +17,21 @@ Usage: This helper can be seen in use at: ../_layouts/default.html -->{% endcomment %} -{% if categories_list.first[0] == null %} - {% for category in categories_list %} - <li><a href="{{ BASE_PATH }}{{ site.var.categories_path }}#{{ category }}-ref"> - {{ category | join: "/" }} <span>{{ site.categories[category].size }}</span> - </a></li> - {% endfor %} +{% if site.JB.categories_list.engine == "custom" %} + {% include custom/categories_list %} {% else %} - {% for category in categories_list %} - <li><a href="{{ BASE_PATH }}{{ site.var.categories_path }}#{{ category[0] }}-ref"> - {{ category[0] | join: "/" }} <span>{{ category[1].size }}</span> - </a></li> - {% endfor %} + {% if categories_list.first[0] == null %} + {% for category in categories_list %} + <li><a href="{{ BASE_PATH }}{{ site.var.categories_path }}#{{ category }}-ref"> + {{ category | join: "/" }} <span>{{ site.categories[category].size }}</span> + </a></li> + {% endfor %} + {% else %} + {% for category in categories_list %} + <li><a href="{{ BASE_PATH }}{{ site.var.categories_path }}#{{ category[0] }}-ref"> + {{ category[0] | join: "/" }} <span>{{ category[1].size }}</span> + </a></li> + {% endfor %} + {% endif %} {% endif %} - -{% assign categories_list = null %} +{% assign categories_list = nil %}
\ No newline at end of file diff --git a/_includes/JB/liquid_raw b/_includes/JB/liquid_raw index 0bd9598..869e9a1 100644 --- a/_includes/JB/liquid_raw +++ b/_includes/JB/liquid_raw @@ -24,6 +24,9 @@ Usage: As seen here, you must use "|." and ".|" as opening and closing brackets. -->{% endcomment%} -<pre><code>{{text | replace:"|.", "{" | replace:".|", "}" | replace:">", ">" | replace:"<", "<" }}</code></pre> - -{% assign text = null %}
\ No newline at end of file +{% if site.JB.liquid_raw.engine == "custom" %} + {% include custom/liquid_raw %} +{% else %} + <pre><code>{{text | replace:"|.", "{" | replace:".|", "}" | replace:">", ">" | replace:"<", "<" }}</code></pre> +{% endif %} +{% assign text = nil %}
\ No newline at end of file diff --git a/_includes/JB/pages_list b/_includes/JB/pages_list index c247a42..07cb058 100644 --- a/_includes/JB/pages_list +++ b/_includes/JB/pages_list @@ -20,18 +20,18 @@ Usage: This helper can be seen in use at: ../_layouts/default.html -->{% endcomment %} - -{% for node in pages_list %} - {% if group == null or group == node.group %} - - {% if page.url == node.url %} - <li class="active"><a href="{{ BASE_PATH }}{{node.url}}" class="active">{{node.title}}</a></li> - {% else %} - <li><a href="{{ BASE_PATH }}{{node.url}}">{{node.title}}</a></li> - {% endif %} - - {% endif %} -{% endfor %} - -{% assign pages_list = null %} -{% assign group = null %} +{% if site.JB.pages_list.engine == "custom" %} + {% include custom/pages_list %} +{% else %} + {% for node in pages_list %} + {% if group == null or group == node.group %} + {% if page.url == node.url %} + <li class="active"><a href="{{ BASE_PATH }}{{node.url}}" class="active">{{node.title}}</a></li> + {% else %} + <li><a href="{{ BASE_PATH }}{{node.url}}">{{node.title}}</a></li> + {% endif %} + {% endif %} + {% endfor %} +{% endif %} +{% assign pages_list = nil %} +{% assign group = nil %}
\ No newline at end of file diff --git a/_includes/JB/posts_collate b/_includes/JB/posts_collate index 4b344aa..588c6fe 100644 --- a/_includes/JB/posts_collate +++ b/_includes/JB/posts_collate @@ -17,36 +17,39 @@ Usage: -->{% endcomment %} -{% for post in posts_collate %} - {% capture this_year %}{{ post.date | date: "%Y" }}{% endcapture %} - {% capture this_month %}{{ post.date | date: "%B" }}{% endcapture %} - {% capture next_year %}{{ post.previous.date | date: "%Y" }}{% endcapture %} - {% capture next_month %}{{ post.previous.date | date: "%B" }}{% endcapture %} +{% if site.JB.posts_collate.engine == "custom" %} + {% include custom/posts_collate %} +{% else %} + {% for post in posts_collate %} + {% capture this_year %}{{ post.date | date: "%Y" }}{% endcapture %} + {% capture this_month %}{{ post.date | date: "%B" }}{% endcapture %} + {% capture next_year %}{{ post.previous.date | date: "%Y" }}{% endcapture %} + {% capture next_month %}{{ post.previous.date | date: "%B" }}{% endcapture %} - {% if forloop.first %} - <h2>{{this_year}}</h2> - <h3>{{this_month}}</h3> - <ul> - {% endif %} + {% if forloop.first %} + <h2>{{this_year}}</h2> + <h3>{{this_month}}</h3> + <ul> + {% endif %} - <li><span>{{ post.date | date: "%B %e, %Y" }}</span> » <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></li> + <li><span>{{ post.date | date: "%B %e, %Y" }}</span> » <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></li> - {% if forloop.last %} - </ul> - {% else %} - {% if this_year != next_year %} + {% if forloop.last %} </ul> - <h2>{{next_year}}</h2> - <h3>{{next_month}}</h3> - <ul> - {% else %} - {% if this_month != next_month %} + {% else %} + {% if this_year != next_year %} </ul> + <h2>{{next_year}}</h2> <h3>{{next_month}}</h3> <ul> + {% else %} + {% if this_month != next_month %} + </ul> + <h3>{{next_month}}</h3> + <ul> + {% endif %} {% endif %} {% endif %} - {% endif %} -{% endfor %} - -{% assign posts_collate = null %} + {% endfor %} +{% endif %} +{% assign posts_collate = nil %}
\ No newline at end of file diff --git a/_includes/JB/setup b/_includes/JB/setup index 30342fe..ce7ce7d 100644 --- a/_includes/JB/setup +++ b/_includes/JB/setup @@ -2,18 +2,21 @@ <!-- - Dynamically set liquid variables for working with URLs/paths --> - {% if site.safe and site.JB.BASE_PATH %} - {% assign BASE_PATH = site.JB.BASE_PATH %} - {% assign HOME_PATH = site.JB.BASE_PATH %} + {% if site.JB.setup.engine == "custom" %} + {% include custom/setup %} {% else %} - {% assign BASE_PATH = nil %} - {% assign HOME_PATH = "/" %} - {% endif %} - - {% if site.JB.ASSET_PATH %} - {% assign ASSET_PATH = site.JB.ASSET_PATH %} - {% else %} - {% capture ASSET_PATH %}{{ BASE_PATH }}/assets/themes/{{ page.theme.name }}{% endcapture %} - {% endif %} + {% if site.safe and site.JB.BASE_PATH %} + {% assign BASE_PATH = site.JB.BASE_PATH %} + {% assign HOME_PATH = site.JB.BASE_PATH %} + {% else %} + {% assign BASE_PATH = nil %} + {% assign HOME_PATH = "/" %} + {% endif %} + {% if site.JB.ASSET_PATH %} + {% assign ASSET_PATH = site.JB.ASSET_PATH %} + {% else %} + {% capture ASSET_PATH %}{{ BASE_PATH }}/assets/themes/{{ page.theme.name }}{% endcapture %} + {% endif %} + {% endif %} {% endcapture %}{% assign jbcache = nil %}
\ No newline at end of file diff --git a/_includes/JB/tags_list b/_includes/JB/tags_list index 38725f3..a6d68e8 100644 --- a/_includes/JB/tags_list +++ b/_includes/JB/tags_list @@ -17,14 +17,17 @@ Usage: This helper can be seen in use at: ../_layouts/default.html -->{% endcomment %} -{% if tags_list.first[0] == null %} - {% for tag in tags_list %} - <li><a href="{{ BASE_PATH }}{{ site.var.tags_path }}#{{ tag }}-ref">{{ tag }} <span>{{ site.tags[tag].size }}</span></a></li> - {% endfor %} +{% if site.JB.tags_list.engine == "custom" %} + {% include custom/tags_list %} {% else %} - {% for tag in tags_list %} - <li><a href="{{ BASE_PATH }}{{ site.var.tags_path }}#{{ tag[0] }}-ref">{{ tag[0] }} <span>{{ tag[1].size }}</span></a></li> - {% endfor %} + {% if tags_list.first[0] == null %} + {% for tag in tags_list %} + <li><a href="{{ BASE_PATH }}{{ site.var.tags_path }}#{{ tag }}-ref">{{ tag }} <span>{{ site.tags[tag].size }}</span></a></li> + {% endfor %} + {% else %} + {% for tag in tags_list %} + <li><a href="{{ BASE_PATH }}{{ site.var.tags_path }}#{{ tag[0] }}-ref">{{ tag[0] }} <span>{{ tag[1].size }}</span></a></li> + {% endfor %} + {% endif %} {% endif %} - -{% assign tags_list = null %} +{% assign tags_list = nil %} |