jekyll-ham 0.3.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +71 -4
- data/_config.yml +2 -0
- data/_includes/comments.html +4 -50
- data/_includes/favicon.html +3 -0
- data/_includes/ham/comments.html +49 -0
- data/_includes/{external-link.html → ham/external-link.html} +1 -1
- data/_includes/ham/navbar.html +25 -0
- data/_includes/{search-modal.html → ham/search-modal.html} +1 -1
- data/_includes/ham/sidebar.html +39 -0
- data/_includes/navbar.html +3 -27
- data/_layouts/default.html +26 -11
- data/_layouts/page.html +70 -19
- data/assets/bootstrap-color-modes.js +90 -0
- data/assets/bootstrap-icons.min.css +2 -3
- data/assets/cookies.js +21 -0
- data/assets/default.css +18 -9
- data/assets/entry-parser.js +104 -21
- data/assets/fonts/bootstrap-icons.woff +0 -0
- data/assets/fonts/bootstrap-icons.woff2 +0 -0
- data/assets/halfmoon-variables.min.css +22 -11
- data/assets/halfmoon.min.js +7 -11
- data/assets/main.css +4 -13
- metadata +12 -8
- data/_includes/custom-comments.html +0 -4
- data/_includes/sidebar.html +0 -62
- /data/_includes/{footer.html → ham/footer.html} +0 -0
- /data/_includes/{random-posts.html → ham/random-posts.html} +0 -0
data/assets/default.css
CHANGED
@@ -22,21 +22,30 @@
|
|
22
22
|
margin-right: 0.5rem;
|
23
23
|
}
|
24
24
|
|
25
|
+
/* Removes the unnecessary bottom padding on alerts */
|
26
|
+
.alert address, .alert dl, .alert ol, .alert p, .alert ul {
|
27
|
+
margin-bottom: 0.5rem;
|
28
|
+
}
|
29
|
+
|
30
|
+
.alert > :last-child {
|
31
|
+
margin-bottom: 0;
|
32
|
+
}
|
33
|
+
|
25
34
|
/* Make syntax highlighter */
|
26
35
|
.content-wrapper pre {
|
27
36
|
word-wrap: normal;
|
28
37
|
padding: 20px;
|
29
38
|
border-radius: 4px;
|
30
|
-
white-space:pre;
|
31
|
-
transform:translate3d(0, 0, 0);
|
39
|
+
white-space: pre;
|
40
|
+
transform: translate3d(0, 0, 0);
|
32
41
|
overflow-x:auto;
|
33
|
-
-webkit-overflow-scrolling:touch;
|
34
|
-
word-wrap:normal;
|
35
|
-
-moz-tab-size:4;
|
36
|
-
-o-tab-size:4;
|
37
|
-
-webkit-tab-size:4;
|
38
|
-
-ms-tab-size:4;
|
39
|
-
tab-size:4;
|
42
|
+
-webkit-overflow-scrolling: touch;
|
43
|
+
word-wrap: normal;
|
44
|
+
-moz-tab-size: 4;
|
45
|
+
-o-tab-size: 4;
|
46
|
+
-webkit-tab-size: 4;
|
47
|
+
-ms-tab-size: 4;
|
48
|
+
tab-size: 4;
|
40
49
|
}
|
41
50
|
.content-wrapper pre::-webkit-scrollbar-thumb {
|
42
51
|
background-color: rgba(255, 255, 255, 0.5);
|
data/assets/entry-parser.js
CHANGED
@@ -23,10 +23,19 @@ function parseRawEntry(originalContent, onThisPageEntry, siteTitle, siteTagline)
|
|
23
23
|
var headingTags = ['H2', 'H3', 'H4', 'H5', 'H6'];
|
24
24
|
var i, j;
|
25
25
|
var taglinePlaced = false;
|
26
|
-
var
|
26
|
+
var originalChildren = originalContent.childNodes;
|
27
27
|
var currentAccordionId = '';
|
28
|
-
|
29
|
-
|
28
|
+
|
29
|
+
var onThisPageEntryDraft = document.createElement('ul');
|
30
|
+
onThisPageEntryDraft.className = 'list-group';
|
31
|
+
|
32
|
+
var firstH2 = true;
|
33
|
+
var accordionContainer = document.createElement('div');
|
34
|
+
accordionContainer.className = 'accordion';
|
35
|
+
|
36
|
+
// Scan the content to generate On This Page list and style blockquotes
|
37
|
+
for (i = 0; i < originalChildren.length; i++) {
|
38
|
+
var node = originalChildren[i];
|
30
39
|
if (node.nodeName == 'H1' && !taglinePlaced && typeof siteTitle === 'string' && siteTitle.length > 0){
|
31
40
|
var newTagline = document.createElement('span');
|
32
41
|
newTagline.textContent = 'from ' + siteTitle;
|
@@ -47,23 +56,80 @@ function parseRawEntry(originalContent, onThisPageEntry, siteTitle, siteTagline)
|
|
47
56
|
}
|
48
57
|
|
49
58
|
// Create "On This Page entry"
|
59
|
+
var newLi = document.createElement('li');
|
60
|
+
newLi.className = 'list-group-item';
|
50
61
|
var newA = document.createElement('a');
|
51
62
|
newA.href = '#' + node.id;
|
52
|
-
newA.className = '
|
63
|
+
newA.className = 'nav-link text-truncate';
|
53
64
|
newA.setAttribute('onclick', 'expandAccordion(\'' + currentAccordionId + '\')');
|
54
65
|
for (j = 2; j < currentHeadingLevel; j++){
|
55
66
|
var newSpan = document.createElement('span');
|
56
|
-
|
67
|
+
if (j == currentHeadingLevel - 1) {
|
68
|
+
newSpan.className = 'me-1 d-inline-block text-body-tertiary';
|
69
|
+
newSpan.textContent = '↳';
|
70
|
+
} else {
|
71
|
+
newSpan.className = 'ms-3 d-inline-block';
|
72
|
+
}
|
57
73
|
newSpan.setAttribute('aria-hidden', true);
|
58
74
|
newA.appendChild(newSpan);
|
59
75
|
}
|
60
76
|
newA.appendChild(document.createTextNode(node.textContent));
|
61
|
-
|
77
|
+
newLi.appendChild(newA)
|
78
|
+
onThisPageEntryDraft.appendChild(newLi);
|
79
|
+
}
|
80
|
+
if (node.nodeName == 'BLOCKQUOTE') {
|
81
|
+
var blockquoteChildren = node.childNodes;
|
82
|
+
node.className = 'alert';
|
83
|
+
var firstP = true;
|
84
|
+
for (j = 0; j < blockquoteChildren.length; j++) {
|
85
|
+
// Support GitHub-style Note, Important, and Warning blockquote style
|
86
|
+
if (blockquoteChildren[j].nodeName == 'P' && firstP) {
|
87
|
+
switch (blockquoteChildren[j].textContent) {
|
88
|
+
case '[!NOTE]':
|
89
|
+
node.className += ' alert-primary';
|
90
|
+
blockquoteChildren[j].className = ' fs-5 fw-bolder text-primary';
|
91
|
+
blockquoteChildren[j].innerHTML = '<i class="bi bi-info-circle"></i> Note';
|
92
|
+
break;
|
93
|
+
case '[!TIP]':
|
94
|
+
node.className += ' alert-success';
|
95
|
+
blockquoteChildren[j].className = ' fs-5 fw-bolder text-success';
|
96
|
+
blockquoteChildren[j].innerHTML = '<i class="bi bi-lightbulb"></i> Tip';
|
97
|
+
break;
|
98
|
+
case '[!IMPORTANT]':
|
99
|
+
node.className += ' alert-info';
|
100
|
+
blockquoteChildren[j].className = ' fs-5 fw-bolder text-info';
|
101
|
+
blockquoteChildren[j].innerHTML = '<i class="bi bi-exclamation-diamond"></i> Important';
|
102
|
+
break;
|
103
|
+
case '[!WARNING]':
|
104
|
+
node.className += ' alert-warning';
|
105
|
+
blockquoteChildren[j].className = ' fs-5 fw-bolder text-warning';
|
106
|
+
blockquoteChildren[j].innerHTML = '<i class="bi bi-exclamation-triangle"></i> Warning';
|
107
|
+
break;
|
108
|
+
case '[!CAUTION]':
|
109
|
+
node.className += ' alert-danger';
|
110
|
+
blockquoteChildren[j].className = ' fs-5 fw-bolder text-danger';
|
111
|
+
blockquoteChildren[j].innerHTML = '<i class="bi bi-exclamation-octagon"></i> Caution';
|
112
|
+
break;
|
113
|
+
default:
|
114
|
+
node.className += ' alert-secondary';
|
115
|
+
}
|
116
|
+
firstP = false;
|
117
|
+
}
|
118
|
+
}
|
62
119
|
}
|
63
120
|
}
|
121
|
+
|
122
|
+
// Rescan the content to create collapsible headings
|
123
|
+
var children = originalContent.cloneNode(true).childNodes;
|
64
124
|
for (i = 0; i < children.length; i++){
|
65
125
|
var node = children[i];
|
66
126
|
if (node.nodeName === 'H2'){
|
127
|
+
if (firstH2) {
|
128
|
+
// Delete the original children to create a new accordion container
|
129
|
+
for (j = i; j < originalChildren.length; j++) originalChildren[j].remove();
|
130
|
+
firstH2 = false;
|
131
|
+
}
|
132
|
+
|
67
133
|
var start = i; end = i;
|
68
134
|
var collapseChildren = [];
|
69
135
|
while (end + 1 < children.length && children[end + 1].nodeName !== 'H2') end++;
|
@@ -77,21 +143,38 @@ function parseRawEntry(originalContent, onThisPageEntry, siteTitle, siteTagline)
|
|
77
143
|
}
|
78
144
|
|
79
145
|
// Create actual collapse
|
80
|
-
var newDetails = document.createElement('
|
81
|
-
newDetails.className = '
|
82
|
-
var newSummary = document.createElement('summary');
|
83
|
-
newSummary.className = 'collapse-header font-size-20 h2';
|
84
|
-
newSummary.innerHTML = node.innerHTML;
|
85
|
-
var newDiv = document.createElement('div');
|
86
|
-
newDiv.className = 'collapse-content';
|
87
|
-
for (j = 0; j < collapseChildren.length; j++) newDiv.appendChild(collapseChildren[j]);
|
88
|
-
newDetails.appendChild(newSummary);
|
89
|
-
newDetails.appendChild(newDiv);
|
90
|
-
|
146
|
+
var newDetails = document.createElement('div')
|
147
|
+
newDetails.className = 'accordion-item';
|
91
148
|
newDetails.id = children[i].id;
|
92
|
-
|
149
|
+
var newSummary = document.createElement('h2');
|
150
|
+
newSummary.className = 'accordion-header';
|
151
|
+
var newSummaryButton = document.createElement('button');
|
152
|
+
newSummaryButton.className = 'accordion-button fs-4';
|
153
|
+
newSummaryButton.setAttribute('type', 'button');
|
154
|
+
newSummaryButton.setAttribute('data-bs-toggle', 'collapse');
|
155
|
+
newSummaryButton.setAttribute('data-bs-target', '#' + children[i].id + "-content");
|
156
|
+
newSummaryButton.setAttribute('aria-expanded', 'true');
|
157
|
+
newSummaryButton.setAttribute('aria-controls', children[i].id + "-content");
|
158
|
+
newSummaryButton.setAttribute('type', 'button');
|
159
|
+
newSummaryButton.setAttribute('type', 'button');
|
160
|
+
newSummaryButton.innerHTML = node.innerHTML;
|
161
|
+
newSummary.appendChild(newSummaryButton);
|
162
|
+
|
163
|
+
var newCollapse = document.createElement('div');
|
164
|
+
newCollapse.className = 'accordion-collapse collapse show';
|
165
|
+
newCollapse.id = children[i].id + "-content";
|
166
|
+
var newBody = document.createElement('div');
|
167
|
+
newBody.className = 'accordion-body';
|
168
|
+
for (j = 0; j < collapseChildren.length; j++) newBody.appendChild(collapseChildren[j]);
|
169
|
+
newCollapse.appendChild(newBody);
|
170
|
+
newDetails.appendChild(newSummary);
|
171
|
+
newDetails.appendChild(newCollapse);
|
172
|
+
accordionContainer.appendChild(newDetails);
|
93
173
|
}
|
94
174
|
}
|
175
|
+
|
176
|
+
originalContent.appendChild(accordionContainer);
|
177
|
+
onThisPageEntry.appendChild(onThisPageEntryDraft);
|
95
178
|
}
|
96
179
|
|
97
180
|
var _ham_state_is_all_accordion_collapsed = true;
|
@@ -110,9 +193,9 @@ function autoexpandAccordion(){
|
|
110
193
|
}
|
111
194
|
}
|
112
195
|
|
113
|
-
function expandAccordion(id){
|
114
|
-
var el = document.getElementById(id);
|
115
|
-
el.
|
196
|
+
async function expandAccordion(id){
|
197
|
+
var el = new bootstrap.Collapse(document.getElementById(id + "-content"), {toggle: false});
|
198
|
+
await el.show();
|
116
199
|
}
|
117
200
|
|
118
201
|
window.addEventListener("load", autoexpandAccordion);
|
Binary file
|
Binary file
|