Skip to content

Commit fbc5cf0

Browse files
committed
feat: added /screenshots/ page, added toc, fixed stats page not rendering, misc fixes
1 parent 207f0ba commit fbc5cf0

File tree

11 files changed

+418
-22
lines changed

11 files changed

+418
-22
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build: assets
44
# compass compile
55
bundle exec jekyll build
66

7-
dev: assets
7+
dev:
88
bundle exec jekyll serve
99

1010
assets: _includes/tables img/stats img/*.png

_includes/anchor_headings.html

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
{% capture headingsWorkspace %}
2+
{% comment %}
3+
Copyright (c) 2018 Vladimir "allejo" Jimenez
4+
5+
Permission is hereby granted, free of charge, to any person
6+
obtaining a copy of this software and associated documentation
7+
files (the "Software"), to deal in the Software without
8+
restriction, including without limitation the rights to use,
9+
copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the
11+
Software is furnished to do so, subject to the following
12+
conditions:
13+
14+
The above copyright notice and this permission notice shall be
15+
included in all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24+
OTHER DEALINGS IN THE SOFTWARE.
25+
{% endcomment %}
26+
{% comment %}
27+
Version 1.0.11
28+
https://github.com/allejo/jekyll-anchor-headings
29+
30+
"Be the pull request you wish to see in the world." ~Ben Balter
31+
32+
Usage:
33+
{% include anchor_headings.html html=content anchorBody="#" %}
34+
35+
Parameters:
36+
* html (string) - the HTML of compiled markdown generated by kramdown in Jekyll
37+
38+
Optional Parameters:
39+
* beforeHeading (bool) : false - Set to true if the anchor should be placed _before_ the heading's content
40+
* headerAttrs (string) : '' - Any custom HTML attributes that will be added to the heading tag; you may NOT use `id`;
41+
the `%heading%` and `%html_id%` placeholders are available
42+
* anchorAttrs (string) : '' - Any custom HTML attributes that will be added to the `<a>` tag; you may NOT use `href`, `class` or `title`;
43+
the `%heading%` and `%html_id%` placeholders are available
44+
* anchorBody (string) : '' - The content that will be placed inside the anchor; the `%heading%` placeholder is available
45+
* anchorClass (string) : '' - The class(es) that will be used for each anchor. Separate multiple classes with a space
46+
* anchorTitle (string) : '' - The `title` attribute that will be used for anchors
47+
* h_min (int) : 1 - The minimum header level to build an anchor for; any header lower than this value will be ignored
48+
* h_max (int) : 6 - The maximum header level to build an anchor for; any header greater than this value will be ignored
49+
* bodyPrefix (string) : '' - Anything that should be inserted inside of the heading tag _before_ its anchor and content
50+
* bodySuffix (string) : '' - Anything that should be inserted inside of the heading tag _after_ its anchor and content
51+
* generateId (true) : false - Set to true if a header without id should generate an id to use.
52+
53+
Output:
54+
The original HTML with the addition of anchors inside of all of the h1-h6 headings.
55+
{% endcomment %}
56+
57+
{% assign minHeader = include.h_min | default: 1 %}
58+
{% assign maxHeader = include.h_max | default: 6 %}
59+
{% assign beforeHeading = include.beforeHeading %}
60+
{% assign headerAttrs = include.headerAttrs %}
61+
{% assign nodes = include.html | split: '<h' %}
62+
63+
{% capture edited_headings %}{% endcapture %}
64+
65+
{% for _node in nodes %}
66+
{% capture node %}{{ _node | strip }}{% endcapture %}
67+
68+
{% if node == "" %}
69+
{% continue %}
70+
{% endif %}
71+
72+
{% assign nextChar = node | replace: '"', '' | strip | slice: 0, 1 %}
73+
{% assign headerLevel = nextChar | times: 1 %}
74+
75+
<!-- If the level is cast to 0, it means it's not a h1-h6 tag, so let's see if we need to fix it -->
76+
{% if headerLevel == 0 %}
77+
<!-- Split up the node based on closing angle brackets and get the first one. -->
78+
{% assign firstChunk = node | split: '>' | first %}
79+
80+
<!-- If the first chunk does NOT contain a '<', that means we've broken another HTML tag that starts with 'h' -->
81+
{% unless firstChunk contains '<' %}
82+
{% capture node %}<h{{ node }}{% endcapture %}
83+
{% endunless %}
84+
85+
{% capture edited_headings %}{{ edited_headings }}{{ node }}{% endcapture %}
86+
{% continue %}
87+
{% endif %}
88+
89+
{% capture _closingTag %}</h{{ headerLevel }}>{% endcapture %}
90+
{% assign _workspace = node | split: _closingTag %}
91+
{% capture _hAttrToStrip %}{{ _workspace[0] | split: '>' | first }}>{% endcapture %}
92+
{% assign header = _workspace[0] | replace: _hAttrToStrip, '' %}
93+
{% assign escaped_header = header | strip_html | strip %}
94+
95+
{% assign _classWorkspace = _workspace[0] | split: 'class="' %}
96+
{% assign _classWorkspace = _classWorkspace[1] | split: '"' %}
97+
{% assign _html_class = _classWorkspace[0] %}
98+
99+
{% if _html_class contains "no_anchor" %}
100+
{% assign skip_anchor = true %}
101+
{% else %}
102+
{% assign skip_anchor = false %}
103+
{% endif %}
104+
105+
{% assign _idWorkspace = _workspace[0] | split: 'id="' %}
106+
{% if _idWorkspace[1] %}
107+
{% assign _idWorkspace = _idWorkspace[1] | split: '"' %}
108+
{% assign html_id = _idWorkspace[0] %}
109+
{% elsif include.generateId %}
110+
<!-- If the header did not have an id we create one. -->
111+
{% assign html_id = escaped_header | slugify %}
112+
{% if html_id == "" %}
113+
{% assign html_id = false %}
114+
{% endif %}
115+
{% capture headerAttrs %}{{ headerAttrs }} id="%html_id%"{% endcapture %}
116+
{% endif %}
117+
118+
<!-- Build the anchor to inject for our heading -->
119+
{% capture anchor %}{% endcapture %}
120+
121+
{% if skip_anchor == false and html_id and headerLevel >= minHeader and headerLevel <= maxHeader %}
122+
{% if headerAttrs %}
123+
{% capture _hAttrToStrip %}{{ _hAttrToStrip | split: '>' | first }} {{ headerAttrs | replace: '%heading%', escaped_header | replace: '%html_id%', html_id }}>{% endcapture %}
124+
{% endif %}
125+
126+
{% capture anchor %}href="#{{ html_id }}"{% endcapture %}
127+
128+
{% if include.anchorClass %}
129+
{% capture anchor %}{{ anchor }} class="{{ include.anchorClass }}"{% endcapture %}
130+
{% endif %}
131+
132+
{% if include.anchorTitle %}
133+
{% capture anchor %}{{ anchor }} title="{{ include.anchorTitle | replace: '%heading%', escaped_header }}"{% endcapture %}
134+
{% endif %}
135+
136+
{% if include.anchorAttrs %}
137+
{% capture anchor %}{{ anchor }} {{ include.anchorAttrs | replace: '%heading%', escaped_header | replace: '%html_id%', html_id }}{% endcapture %}
138+
{% endif %}
139+
140+
{% capture anchor %}<a {{ anchor }}>{{ include.anchorBody | replace: '%heading%', escaped_header | default: '' }}</a>{% endcapture %}
141+
142+
<!-- In order to prevent adding extra space after a heading, we'll let the 'anchor' value contain it -->
143+
{% if beforeHeading %}
144+
{% capture anchor %}{{ anchor }} {% endcapture %}
145+
{% else %}
146+
{% capture anchor %} {{ anchor }}{% endcapture %}
147+
{% endif %}
148+
{% endif %}
149+
150+
{% capture new_heading %}
151+
<h{{ _hAttrToStrip }}
152+
{{ include.bodyPrefix }}
153+
{% if beforeHeading %}
154+
{{ anchor }}{{ header }}
155+
{% else %}
156+
{{ header }}{{ anchor }}
157+
{% endif %}
158+
{{ include.bodySuffix }}
159+
</h{{ headerLevel }}>
160+
{% endcapture %}
161+
162+
<!--
163+
If we have content after the `</hX>` tag, then we'll want to append that here so we don't lost any content.
164+
-->
165+
{% assign chunkCount = _workspace | size %}
166+
{% if chunkCount > 1 %}
167+
{% capture new_heading %}{{ new_heading }}{{ _workspace | last }}{% endcapture %}
168+
{% endif %}
169+
170+
{% capture edited_headings %}{{ edited_headings }}{{ new_heading }}{% endcapture %}
171+
{% endfor %}
172+
{% endcapture %}{% assign headingsWorkspace = '' %}{{ edited_headings | strip }}

_includes/toc.html

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
{% capture tocWorkspace %}
2+
{% comment %}
3+
Copyright (c) 2017 Vladimir "allejo" Jimenez
4+
5+
Permission is hereby granted, free of charge, to any person
6+
obtaining a copy of this software and associated documentation
7+
files (the "Software"), to deal in the Software without
8+
restriction, including without limitation the rights to use,
9+
copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the
11+
Software is furnished to do so, subject to the following
12+
conditions:
13+
14+
The above copyright notice and this permission notice shall be
15+
included in all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24+
OTHER DEALINGS IN THE SOFTWARE.
25+
{% endcomment %}
26+
{% comment %}
27+
Version 1.2.0
28+
https://github.com/allejo/jekyll-toc
29+
30+
"...like all things liquid - where there's a will, and ~36 hours to spare, there's usually a/some way" ~jaybe
31+
32+
Usage:
33+
{% include toc.html html=content sanitize=true class="inline_toc" id="my_toc" h_min=2 h_max=3 %}
34+
35+
Parameters:
36+
* html (string) - the HTML of compiled markdown generated by kramdown in Jekyll
37+
38+
Optional Parameters:
39+
* sanitize (bool) : false - when set to true, the headers will be stripped of any HTML in the TOC
40+
* class (string) : '' - a CSS class assigned to the TOC
41+
* id (string) : '' - an ID to assigned to the TOC
42+
* h_min (int) : 1 - the minimum TOC header level to use; any header lower than this value will be ignored
43+
* h_max (int) : 6 - the maximum TOC header level to use; any header greater than this value will be ignored
44+
* ordered (bool) : false - when set to true, an ordered list will be outputted instead of an unordered list
45+
* item_class (string) : '' - add custom class(es) for each list item; has support for '%level%' placeholder, which is the current heading level
46+
* submenu_class (string) : '' - add custom class(es) for each child group of headings; has support for '%level%' placeholder which is the current "submenu" heading level
47+
* base_url (string) : '' - add a base url to the TOC links for when your TOC is on another page than the actual content
48+
* anchor_class (string) : '' - add custom class(es) for each anchor element
49+
* skip_no_ids (bool) : false - skip headers that do not have an `id` attribute
50+
51+
Output:
52+
An ordered or unordered list representing the table of contents of a markdown block. This snippet will only
53+
generate the table of contents and will NOT output the markdown given to it
54+
{% endcomment %}
55+
56+
{% capture newline %}
57+
{% endcapture %}
58+
{% assign newline = newline | rstrip %} <!-- Remove the extra spacing but preserve the newline -->
59+
60+
{% capture deprecation_warnings %}{% endcapture %}
61+
62+
{% if include.baseurl %}
63+
{% capture deprecation_warnings %}{{ deprecation_warnings }}<!-- jekyll-toc :: "baseurl" has been deprecated, use "base_url" instead -->{{ newline }}{% endcapture %}
64+
{% endif %}
65+
66+
{% if include.skipNoIDs %}
67+
{% capture deprecation_warnings %}{{ deprecation_warnings }}<!-- jekyll-toc :: "skipNoIDs" has been deprecated, use "skip_no_ids" instead -->{{ newline }}{% endcapture %}
68+
{% endif %}
69+
70+
{% capture jekyll_toc %}{% endcapture %}
71+
{% assign orderedList = include.ordered | default: false %}
72+
{% assign baseURL = include.base_url | default: include.baseurl | default: '' %}
73+
{% assign skipNoIDs = include.skip_no_ids | default: include.skipNoIDs | default: false %}
74+
{% assign minHeader = include.h_min | default: 1 %}
75+
{% assign maxHeader = include.h_max | default: 6 %}
76+
{% assign nodes = include.html | strip | split: '<h' %}
77+
78+
{% assign firstHeader = true %}
79+
{% assign currLevel = 0 %}
80+
{% assign lastLevel = 0 %}
81+
82+
{% capture listModifier %}{% if orderedList %}ol{% else %}ul{% endif %}{% endcapture %}
83+
84+
{% for node in nodes %}
85+
{% if node == "" %}
86+
{% continue %}
87+
{% endif %}
88+
89+
{% assign currLevel = node | replace: '"', '' | slice: 0, 1 | times: 1 %}
90+
91+
{% if currLevel < minHeader or currLevel > maxHeader %}
92+
{% continue %}
93+
{% endif %}
94+
95+
{% assign _workspace = node | split: '</h' %}
96+
97+
{% assign _idWorkspace = _workspace[0] | split: 'id="' %}
98+
{% assign _idWorkspace = _idWorkspace[1] | split: '"' %}
99+
{% assign htmlID = _idWorkspace[0] %}
100+
101+
{% assign _classWorkspace = _workspace[0] | split: 'class="' %}
102+
{% assign _classWorkspace = _classWorkspace[1] | split: '"' %}
103+
{% assign htmlClass = _classWorkspace[0] %}
104+
105+
{% if htmlClass contains "no_toc" %}
106+
{% continue %}
107+
{% endif %}
108+
109+
{% if firstHeader %}
110+
{% assign minHeader = currLevel %}
111+
{% endif %}
112+
113+
{% capture _hAttrToStrip %}{{ _workspace[0] | split: '>' | first }}>{% endcapture %}
114+
{% assign header = _workspace[0] | replace: _hAttrToStrip, '' %}
115+
116+
{% if include.item_class and include.item_class != blank %}
117+
{% capture listItemClass %} class="{{ include.item_class | replace: '%level%', currLevel | split: '.' | join: ' ' }}"{% endcapture %}
118+
{% endif %}
119+
120+
{% if include.submenu_class and include.submenu_class != blank %}
121+
{% assign subMenuLevel = currLevel | minus: 1 %}
122+
{% capture subMenuClass %} class="{{ include.submenu_class | replace: '%level%', subMenuLevel | split: '.' | join: ' ' }}"{% endcapture %}
123+
{% endif %}
124+
125+
{% capture anchorBody %}{% if include.sanitize %}{{ header | strip_html }}{% else %}{{ header }}{% endif %}{% endcapture %}
126+
127+
{% if htmlID %}
128+
{% capture anchorAttributes %} href="{% if baseURL %}{{ baseURL }}{% endif %}#{{ htmlID }}"{% endcapture %}
129+
130+
{% if include.anchor_class %}
131+
{% capture anchorAttributes %}{{ anchorAttributes }} class="{{ include.anchor_class | split: '.' | join: ' ' }}"{% endcapture %}
132+
{% endif %}
133+
134+
{% capture listItem %}<a{{ anchorAttributes }}>{{ anchorBody }}</a>{% endcapture %}
135+
{% elsif skipNoIDs == true %}
136+
{% continue %}
137+
{% else %}
138+
{% capture listItem %}{{ anchorBody }}{% endcapture %}
139+
{% endif %}
140+
141+
{% if currLevel > lastLevel %}
142+
{% capture jekyll_toc %}{{ jekyll_toc }}<{{ listModifier }}{{ subMenuClass }}>{% endcapture %}
143+
{% elsif currLevel < lastLevel %}
144+
{% assign repeatCount = lastLevel | minus: currLevel %}
145+
146+
{% for i in (1..repeatCount) %}
147+
{% capture jekyll_toc %}{{ jekyll_toc }}</li></{{ listModifier }}>{% endcapture %}
148+
{% endfor %}
149+
150+
{% capture jekyll_toc %}{{ jekyll_toc }}</li>{% endcapture %}
151+
{% else %}
152+
{% capture jekyll_toc %}{{ jekyll_toc }}</li>{% endcapture %}
153+
{% endif %}
154+
155+
{% capture jekyll_toc %}{{ jekyll_toc }}<li{{ listItemClass }}>{{ listItem }}{% endcapture %}
156+
157+
{% assign lastLevel = currLevel %}
158+
{% assign firstHeader = false %}
159+
{% endfor %}
160+
161+
{% assign repeatCount = minHeader | minus: 1 %}
162+
{% assign repeatCount = lastLevel | minus: repeatCount %}
163+
{% for i in (1..repeatCount) %}
164+
{% capture jekyll_toc %}{{ jekyll_toc }}</li></{{ listModifier }}>{% endcapture %}
165+
{% endfor %}
166+
167+
{% if jekyll_toc != '' %}
168+
{% assign rootAttributes = '' %}
169+
{% if include.class and include.class != blank %}
170+
{% capture rootAttributes %} class="{{ include.class | split: '.' | join: ' ' }}"{% endcapture %}
171+
{% endif %}
172+
173+
{% if include.id and include.id != blank %}
174+
{% capture rootAttributes %}{{ rootAttributes }} id="{{ include.id }}"{% endcapture %}
175+
{% endif %}
176+
177+
{% if rootAttributes %}
178+
{% assign nodes = jekyll_toc | split: '>' %}
179+
{% capture jekyll_toc %}<{{ listModifier }}{{ rootAttributes }}>{{ nodes | shift | join: '>' }}>{% endcapture %}
180+
{% endif %}
181+
{% endif %}
182+
{% endcapture %}{% assign tocWorkspace = '' %}{{ deprecation_warnings }}{{ jekyll_toc -}}

_layouts/page.html

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,22 @@
88
<h1 class="post-title">{{ page.title }}</h1>
99
</header>
1010

11+
{% capture processed_content %}
12+
{% include anchor_headings.html html=content generateId=true %}
13+
{% endcapture %}
14+
1115
<div class="post-content">
12-
{{ content }}
13-
</div>
16+
<p>
17+
{{ page.excerpt }}
18+
</p>
1419

20+
{% if page.toc %}
21+
<div style="font-size: 0.8em; background-color: #f9faff; padding: 0.5em; display: table; border: 1px solid #d7dfe3;">
22+
<b style="display: inline-block; margin-bottom: 0.5em">Contents</b>
23+
{% include toc.html html=processed_content %}
24+
</div>
25+
{% endif %}
26+
{{ processed_content | remove_first:page.excerpt }}
27+
</div>
1528
</article>
1629
</div>
File renamed without changes.
File renamed without changes.

img/screenshot.png renamed to img/screenshots/screenshot-v0.8.0dev-activity.png

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)