X Tutup
Skip to content

Commit 6c0b6c1

Browse files
committed
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.
1 parent 08d59a6 commit 6c0b6c1

File tree

6 files changed

+91
-76
lines changed

6 files changed

+91
-76
lines changed

_includes/JB/categories_list

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,21 @@ Usage:
1717
This helper can be seen in use at: ../_layouts/default.html
1818
-->{% endcomment %}
1919

20-
{% if categories_list.first[0] == null %}
21-
{% for category in categories_list %}
22-
<li><a href="{{ BASE_PATH }}{{ site.var.categories_path }}#{{ category }}-ref">
23-
{{ category | join: "/" }} <span>{{ site.categories[category].size }}</span>
24-
</a></li>
25-
{% endfor %}
20+
{% if site.JB.categories_list.engine == "custom" %}
21+
{% include custom/categories_list %}
2622
{% else %}
27-
{% for category in categories_list %}
28-
<li><a href="{{ BASE_PATH }}{{ site.var.categories_path }}#{{ category[0] }}-ref">
29-
{{ category[0] | join: "/" }} <span>{{ category[1].size }}</span>
30-
</a></li>
31-
{% endfor %}
23+
{% if categories_list.first[0] == null %}
24+
{% for category in categories_list %}
25+
<li><a href="{{ BASE_PATH }}{{ site.var.categories_path }}#{{ category }}-ref">
26+
{{ category | join: "/" }} <span>{{ site.categories[category].size }}</span>
27+
</a></li>
28+
{% endfor %}
29+
{% else %}
30+
{% for category in categories_list %}
31+
<li><a href="{{ BASE_PATH }}{{ site.var.categories_path }}#{{ category[0] }}-ref">
32+
{{ category[0] | join: "/" }} <span>{{ category[1].size }}</span>
33+
</a></li>
34+
{% endfor %}
35+
{% endif %}
3236
{% endif %}
33-
34-
{% assign categories_list = null %}
37+
{% assign categories_list = nil %}

_includes/JB/liquid_raw

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ Usage:
2424
As seen here, you must use "|." and ".|" as opening and closing brackets.
2525
-->{% endcomment%}
2626

27-
<pre><code>{{text | replace:"|.", "&#123;" | replace:".|", "&#125;" | replace:">", "&gt;" | replace:"<", "&lt;" }}</code></pre>
28-
29-
{% assign text = null %}
27+
{% if site.JB.liquid_raw.engine == "custom" %}
28+
{% include custom/liquid_raw %}
29+
{% else %}
30+
<pre><code>{{text | replace:"|.", "&#123;" | replace:".|", "&#125;" | replace:">", "&gt;" | replace:"<", "&lt;" }}</code></pre>
31+
{% endif %}
32+
{% assign text = nil %}

_includes/JB/pages_list

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ Usage:
2020
This helper can be seen in use at: ../_layouts/default.html
2121
-->{% endcomment %}
2222

23-
24-
{% for node in pages_list %}
25-
{% if group == null or group == node.group %}
26-
27-
{% if page.url == node.url %}
28-
<li class="active"><a href="{{ BASE_PATH }}{{node.url}}" class="active">{{node.title}}</a></li>
29-
{% else %}
30-
<li><a href="{{ BASE_PATH }}{{node.url}}">{{node.title}}</a></li>
31-
{% endif %}
32-
33-
{% endif %}
34-
{% endfor %}
35-
36-
{% assign pages_list = null %}
37-
{% assign group = null %}
23+
{% if site.JB.pages_list.engine == "custom" %}
24+
{% include custom/pages_list %}
25+
{% else %}
26+
{% for node in pages_list %}
27+
{% if group == null or group == node.group %}
28+
{% if page.url == node.url %}
29+
<li class="active"><a href="{{ BASE_PATH }}{{node.url}}" class="active">{{node.title}}</a></li>
30+
{% else %}
31+
<li><a href="{{ BASE_PATH }}{{node.url}}">{{node.title}}</a></li>
32+
{% endif %}
33+
{% endif %}
34+
{% endfor %}
35+
{% endif %}
36+
{% assign pages_list = nil %}
37+
{% assign group = nil %}

_includes/JB/posts_collate

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,39 @@ Usage:
1717

1818
-->{% endcomment %}
1919

20-
{% for post in posts_collate %}
21-
{% capture this_year %}{{ post.date | date: "%Y" }}{% endcapture %}
22-
{% capture this_month %}{{ post.date | date: "%B" }}{% endcapture %}
23-
{% capture next_year %}{{ post.previous.date | date: "%Y" }}{% endcapture %}
24-
{% capture next_month %}{{ post.previous.date | date: "%B" }}{% endcapture %}
20+
{% if site.JB.posts_collate.engine == "custom" %}
21+
{% include custom/posts_collate %}
22+
{% else %}
23+
{% for post in posts_collate %}
24+
{% capture this_year %}{{ post.date | date: "%Y" }}{% endcapture %}
25+
{% capture this_month %}{{ post.date | date: "%B" }}{% endcapture %}
26+
{% capture next_year %}{{ post.previous.date | date: "%Y" }}{% endcapture %}
27+
{% capture next_month %}{{ post.previous.date | date: "%B" }}{% endcapture %}
2528

26-
{% if forloop.first %}
27-
<h2>{{this_year}}</h2>
28-
<h3>{{this_month}}</h3>
29-
<ul>
30-
{% endif %}
29+
{% if forloop.first %}
30+
<h2>{{this_year}}</h2>
31+
<h3>{{this_month}}</h3>
32+
<ul>
33+
{% endif %}
3134

32-
<li><span>{{ post.date | date: "%B %e, %Y" }}</span> &raquo; <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></li>
35+
<li><span>{{ post.date | date: "%B %e, %Y" }}</span> &raquo; <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></li>
3336

34-
{% if forloop.last %}
35-
</ul>
36-
{% else %}
37-
{% if this_year != next_year %}
37+
{% if forloop.last %}
3838
</ul>
39-
<h2>{{next_year}}</h2>
40-
<h3>{{next_month}}</h3>
41-
<ul>
42-
{% else %}
43-
{% if this_month != next_month %}
39+
{% else %}
40+
{% if this_year != next_year %}
4441
</ul>
42+
<h2>{{next_year}}</h2>
4543
<h3>{{next_month}}</h3>
4644
<ul>
45+
{% else %}
46+
{% if this_month != next_month %}
47+
</ul>
48+
<h3>{{next_month}}</h3>
49+
<ul>
50+
{% endif %}
4751
{% endif %}
4852
{% endif %}
49-
{% endif %}
50-
{% endfor %}
51-
52-
{% assign posts_collate = null %}
53+
{% endfor %}
54+
{% endif %}
55+
{% assign posts_collate = nil %}

_includes/JB/setup

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@
22
<!--
33
- Dynamically set liquid variables for working with URLs/paths
44
-->
5-
{% if site.safe and site.JB.BASE_PATH %}
6-
{% assign BASE_PATH = site.JB.BASE_PATH %}
7-
{% assign HOME_PATH = site.JB.BASE_PATH %}
5+
{% if site.JB.setup.engine == "custom" %}
6+
{% include custom/setup %}
87
{% else %}
9-
{% assign BASE_PATH = nil %}
10-
{% assign HOME_PATH = "/" %}
11-
{% endif %}
12-
13-
{% if site.JB.ASSET_PATH %}
14-
{% assign ASSET_PATH = site.JB.ASSET_PATH %}
15-
{% else %}
16-
{% capture ASSET_PATH %}{{ BASE_PATH }}/assets/themes/{{ page.theme.name }}{% endcapture %}
17-
{% endif %}
8+
{% if site.safe and site.JB.BASE_PATH %}
9+
{% assign BASE_PATH = site.JB.BASE_PATH %}
10+
{% assign HOME_PATH = site.JB.BASE_PATH %}
11+
{% else %}
12+
{% assign BASE_PATH = nil %}
13+
{% assign HOME_PATH = "/" %}
14+
{% endif %}
1815

16+
{% if site.JB.ASSET_PATH %}
17+
{% assign ASSET_PATH = site.JB.ASSET_PATH %}
18+
{% else %}
19+
{% capture ASSET_PATH %}{{ BASE_PATH }}/assets/themes/{{ page.theme.name }}{% endcapture %}
20+
{% endif %}
21+
{% endif %}
1922
{% endcapture %}{% assign jbcache = nil %}

_includes/JB/tags_list

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ Usage:
1717
This helper can be seen in use at: ../_layouts/default.html
1818
-->{% endcomment %}
1919

20-
{% if tags_list.first[0] == null %}
21-
{% for tag in tags_list %}
22-
<li><a href="{{ BASE_PATH }}{{ site.var.tags_path }}#{{ tag }}-ref">{{ tag }} <span>{{ site.tags[tag].size }}</span></a></li>
23-
{% endfor %}
20+
{% if site.JB.tags_list.engine == "custom" %}
21+
{% include custom/tags_list %}
2422
{% else %}
25-
{% for tag in tags_list %}
26-
<li><a href="{{ BASE_PATH }}{{ site.var.tags_path }}#{{ tag[0] }}-ref">{{ tag[0] }} <span>{{ tag[1].size }}</span></a></li>
27-
{% endfor %}
23+
{% if tags_list.first[0] == null %}
24+
{% for tag in tags_list %}
25+
<li><a href="{{ BASE_PATH }}{{ site.var.tags_path }}#{{ tag }}-ref">{{ tag }} <span>{{ site.tags[tag].size }}</span></a></li>
26+
{% endfor %}
27+
{% else %}
28+
{% for tag in tags_list %}
29+
<li><a href="{{ BASE_PATH }}{{ site.var.tags_path }}#{{ tag[0] }}-ref">{{ tag[0] }} <span>{{ tag[1].size }}</span></a></li>
30+
{% endfor %}
31+
{% endif %}
2832
{% endif %}
29-
30-
{% assign tags_list = null %}
33+
{% assign tags_list = nil %}

0 commit comments

Comments
 (0)
X Tutup