Skip to content

Commit

Permalink
Provide custom overrides to all helpers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
plusjade committed Jan 23, 2012
1 parent 08d59a6 commit 6c0b6c1
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 76 deletions.
29 changes: 16 additions & 13 deletions _includes/JB/categories_list
Expand Up @@ -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 %}
9 changes: 6 additions & 3 deletions _includes/JB/liquid_raw
Expand Up @@ -24,6 +24,9 @@ Usage:
As seen here, you must use "|." and ".|" as opening and closing brackets.
-->{% endcomment%}

<pre><code>{{text | replace:"|.", "&#123;" | replace:".|", "&#125;" | replace:">", "&gt;" | replace:"<", "&lt;" }}</code></pre>

{% assign text = null %}
{% if site.JB.liquid_raw.engine == "custom" %}
{% include custom/liquid_raw %}
{% else %}
<pre><code>{{text | replace:"|.", "&#123;" | replace:".|", "&#125;" | replace:">", "&gt;" | replace:"<", "&lt;" }}</code></pre>
{% endif %}
{% assign text = nil %}
30 changes: 15 additions & 15 deletions _includes/JB/pages_list
Expand Up @@ -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 %}
51 changes: 27 additions & 24 deletions _includes/JB/posts_collate
Expand Up @@ -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> &raquo; <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></li>
<li><span>{{ post.date | date: "%B %e, %Y" }}</span> &raquo; <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 %}
27 changes: 15 additions & 12 deletions _includes/JB/setup
Expand Up @@ -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 %}
21 changes: 12 additions & 9 deletions _includes/JB/tags_list
Expand Up @@ -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 %}

0 comments on commit 6c0b6c1

Please sign in to comment.