chulapa-jekyll 2.0.1 → 2.1.0
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/CHANGELOG.md +148 -35
- data/README.md +96 -72
- data/_data/version.yml +2 -2
- data/_includes/components/breadcrumbdatesocial.html +15 -11
- data/_includes/components/headers.html +17 -10
- data/_includes/components/indexcards.html +2 -2
- data/_includes/components/navbeforeafter.html +2 -2
- data/_includes/components/random.html +103 -0
- data/_includes/components/related.html +82 -90
- data/_includes/components/simplelist.html +26 -0
- data/_includes/footer.html +53 -1
- data/_includes/head.html +237 -98
- data/_includes/search/fusejs.html +36 -0
- data/_includes/search/lunr.html +27 -7
- data/_includes/search/simplesearch.html +46 -0
- data/_includes/snippets/article-images.html +25 -0
- data/_includes/snippets/bootstrapdemo.html +1454 -1303
- data/_includes/snippets/breadcrumb-names.html +5 -0
- data/_includes/snippets/canonical-url.html +17 -0
- data/_includes/snippets/datetranslate.html +7 -1
- data/_includes/snippets/jsonld-string.html +16 -0
- data/_includes/snippets/og-locale.html +19 -0
- data/_includes/snippets/page-language.html +4 -0
- data/_includes/snippets/publisher.html +25 -0
- data/_includes/snippets/video-metadata.html +15 -0
- data/_includes/snippets/video.html +20 -17
- data/_includes/snippets/youtube.html +9 -4
- data/_includes/welcomments/template.html +1 -1
- data/_layouts/archive.html +1 -1
- data/_layouts/cloudcategory.html +4 -4
- data/_layouts/cloudtag.html +4 -4
- data/_layouts/default.html +4 -4
- data/_layouts/landingpage.html +8 -5
- data/_layouts/minimal.html +10 -4
- data/_layouts/search.html +12 -13
- data/_sass/chulapa/_classes.scss +68 -58
- data/_sass/chulapa/_reboot.scss +31 -0
- data/_sass/chulapa/_variables.scss +8 -1
- data/_sass/highlight/README.md +176 -14
- data/_sass/highlight/abap.scss +62 -0
- data/_sass/highlight/algol.scss +46 -0
- data/_sass/highlight/algol_nu.scss +46 -0
- data/_sass/highlight/arduino.scss +63 -0
- data/_sass/highlight/autumn.scss +69 -58
- data/_sass/highlight/base16.scss +90 -0
- data/_sass/highlight/borland.scss +55 -46
- data/_sass/highlight/bw.scss +70 -34
- data/_sass/highlight/cobalt2.scss +197 -0
- data/_sass/highlight/coffee.scss +82 -0
- data/_sass/highlight/colorful.scss +178 -61
- data/_sass/highlight/cran.scss +185 -169
- data/_sass/highlight/default.scss +72 -61
- data/_sass/highlight/dracula.scss +93 -169
- data/_sass/highlight/emacs.scss +72 -61
- data/_sass/highlight/friendly.scss +72 -61
- data/_sass/highlight/friendly_grayscale.scss +72 -0
- data/_sass/highlight/fruity.scss +82 -70
- data/_sass/highlight/github.dark.scss +83 -0
- data/_sass/highlight/github.scss +116 -61
- data/_sass/highlight/gruvbox.dark.scss +83 -0
- data/_sass/highlight/gruvbox.light.scss +68 -84
- data/_sass/highlight/gruvbox.scss +97 -0
- data/_sass/highlight/igor.scss +36 -0
- data/_sass/highlight/igorpro.scss +45 -0
- data/_sass/highlight/inkpot.scss +78 -0
- data/_sass/highlight/lightbulb.scss +82 -0
- data/_sass/highlight/lilypond.scss +58 -0
- data/_sass/highlight/lovelace.scss +74 -0
- data/_sass/highlight/magritte.scss +175 -0
- data/_sass/highlight/manni.scss +72 -61
- data/_sass/highlight/material.scss +81 -0
- data/_sass/highlight/molokai.scss +211 -0
- data/_sass/highlight/monokai.scss +217 -65
- data/_sass/highlight/monokai.sublime.scss +203 -0
- data/_sass/highlight/murphy.scss +72 -61
- data/_sass/highlight/native.scss +82 -70
- data/_sass/highlight/night-owl.scss +201 -0
- data/_sass/highlight/nord.darker.scss +82 -0
- data/_sass/highlight/nord.scss +82 -0
- data/_sass/highlight/oksolar.dark.scss +175 -0
- data/_sass/highlight/oksolar.light.scss +175 -0
- data/_sass/highlight/one.dark.scss +82 -0
- data/_sass/highlight/panda.scss +195 -0
- data/_sass/highlight/paraiso.dark.scss +76 -0
- data/_sass/highlight/paraiso.light.scss +76 -0
- data/_sass/highlight/pastie.scss +154 -60
- data/_sass/highlight/perldoc.scss +69 -58
- data/_sass/highlight/rainbow_dash.scss +65 -0
- data/_sass/highlight/rrt.scss +82 -0
- data/_sass/highlight/sas.scss +63 -0
- data/_sass/highlight/selenized.black.scss +175 -0
- data/_sass/highlight/selenized.dark.scss +175 -0
- data/_sass/highlight/selenized.light.scss +175 -0
- data/_sass/highlight/selenized.white.scss +175 -0
- data/_sass/highlight/skeletor.scss +190 -140
- data/_sass/highlight/solarized.dark.scss +82 -0
- data/_sass/highlight/solarized.light.scss +82 -0
- data/_sass/highlight/stackoverflow.dark.scss +175 -0
- data/_sass/highlight/stackoverflow.light.scss +175 -0
- data/_sass/highlight/staroffice.scss +82 -0
- data/_sass/highlight/stata.dark.scss +82 -0
- data/_sass/highlight/stata.light.scss +49 -0
- data/_sass/highlight/tango.scss +81 -69
- data/_sass/highlight/template.scss +290 -0
- data/_sass/highlight/thankful_eyes.scss +180 -173
- data/_sass/highlight/trac.scss +70 -59
- data/_sass/highlight/tulip.scss +171 -0
- data/_sass/highlight/vim.scss +82 -70
- data/_sass/highlight/vs.scss +41 -33
- data/_sass/highlight/xcode.scss +65 -0
- data/_sass/highlight/zenburn.scss +82 -136
- data/_sass/reset-algolia.scss +27 -17
- data/_sass/skins/academia.scss +19 -10
- data/_sass/skins/auto.scss +5 -2
- data/_sass/skins/butterfly-dark.scss +54 -0
- data/_sass/skins/butterfly-dim.scss +54 -0
- data/_sass/skins/butterfly.scss +33 -0
- data/_sass/skins/chulapa.scss +10 -3
- data/_sass/skins/cyborg.scss +512 -0
- data/_sass/skins/dark-bg.scss +83 -49
- data/_sass/skins/darkly.scss +424 -0
- data/_sass/skins/deeply.scss +262 -63
- data/_sass/skins/electro.scss +24 -17
- data/_sass/skins/flatly.scss +386 -0
- data/_sass/skins/focal.scss +24 -18
- data/_sass/skins/gitdev-dark.scss +12 -20
- data/_sass/skins/gitdev.scss +20 -17
- data/_sass/skins/graymor.scss +22 -14
- data/_sass/skins/hootstrap.scss +17 -10
- data/_sass/skins/journal.scss +74 -86
- data/_sass/skins/listen.scss +51 -0
- data/_sass/skins/lux.scss +171 -237
- data/_sass/skins/lymcha.scss +14 -9
- data/_sass/skins/materia.scss +889 -0
- data/_sass/skins/media.scss +29 -11
- data/_sass/skins/mickie.scss +27 -11
- data/_sass/skins/minco.scss +30 -10
- data/_sass/skins/minty.scss +226 -85
- data/_sass/skins/monotone.scss +15 -1
- data/_sass/skins/navi.scss +26 -0
- data/_sass/skins/pear.scss +16 -5
- data/_sass/skins/preptor.scss +13 -12
- data/_sass/skins/skeeblu.scss +11 -11
- data/_sass/skins/sketchy.scss +366 -377
- data/_sass/skins/slate.scss +719 -0
- data/_sass/skins/solar.scss +425 -0
- data/_sass/skins/sunset.scss +27 -12
- data/_sass/skins/towards.scss +19 -5
- data/_sass/skins/twitter-dim.scss +20 -11
- data/_sass/skins/twitter-lights-out.scss +22 -11
- data/_sass/skins/twitter.scss +22 -10
- data/_sass/skins/united.scss +57 -0
- data/_sass/skins/universal.scss +29 -27
- data/_sass/skins/wandoo.scss +12 -11
- data/_sass/skins/yeti.scss +673 -0
- data/assets/atom.xml +10 -6
- data/assets/js/better404/better404.js +75 -0
- data/assets/js/ch_ytdefer/ch_ytdefer.js +0 -1
- data/assets/js/chulapa_script.js +2 -2
- data/assets/js/fusejs/fusejs-search.js +197 -0
- data/assets/js/fusejs/fusejs-search.min.js +4 -0
- data/assets/js/fusejs/fusejs-store.js +43 -0
- data/assets/js/lunr/lunr-search.js +249 -114
- data/assets/js/lunr/lunr-search.min.js +4 -0
- data/assets/js/lunr/lunr-store.js +31 -23
- data/assets/js/simplesearch/simplesearch-store.json +45 -0
- data/assets/rss.xml +4 -3
- metadata +81 -8
- data/_sass/highlight/UNLICENSE.txt +0 -24
|
@@ -1,122 +1,257 @@
|
|
|
1
1
|
---
|
|
2
2
|
layout: null
|
|
3
3
|
---
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
4
|
+
// Based on https://gist.github.com/evenfrost/1ba123656ded32fb7a0cd4651efd4db0
|
|
5
|
+
// Sort regions to avoid breaking layout
|
|
6
|
+
// Avoid highlighting single characters
|
|
7
|
+
// Mask highlighting happening in html tags (class or style)
|
|
8
|
+
// Adaptation of my version of fusejs-search.js
|
|
9
|
+
|
|
10
|
+
const highlight = (lunrSearchResult, highlightClassName, termLen) => {
|
|
11
|
+
// Set a value in a nested object based on a dot-separated path
|
|
12
|
+
const set = (obj, path, value) => {
|
|
13
|
+
const keys = path.split('.');
|
|
14
|
+
keys.slice(0, -1).reduce((acc, key) => acc[key], obj)[keys[keys.length - 1]] = value;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// Generate highlighted text based on regions
|
|
18
|
+
const generateHighlightedText = (inputText, regions, termLen) => {
|
|
19
|
+
let content = '';
|
|
20
|
+
let nextUnhighlightedRegionStartingIndex = 0;
|
|
21
|
+
|
|
22
|
+
// Sort regions to avoid breaking layout
|
|
23
|
+
regions.sort((a, b) => a[0] - b[0]);
|
|
24
|
+
|
|
25
|
+
regions.forEach(region => {
|
|
26
|
+
// Convert [start, len] to [start, end]
|
|
27
|
+
const [start, len] = region;
|
|
28
|
+
const end = start + len;
|
|
29
|
+
|
|
30
|
+
// Skip regions that are already included in content
|
|
31
|
+
if (nextUnhighlightedRegionStartingIndex > start) return;
|
|
32
|
+
|
|
33
|
+
// Skip short matches to avoid visual cluttering
|
|
34
|
+
if (end - start < 2 || end - start < Math.floor(termLen / 2)) return;
|
|
35
|
+
|
|
36
|
+
// Check for HTML tags
|
|
37
|
+
const theInput = inputText.substring(start);
|
|
38
|
+
const indexIniTag = theInput.indexOf("<");
|
|
39
|
+
const indexCloseTag = theInput.indexOf(">");
|
|
40
|
+
|
|
41
|
+
if (indexCloseTag < indexIniTag || (indexIniTag === -1 && indexCloseTag > 0)) return;
|
|
42
|
+
|
|
43
|
+
// Append unhighlighted and highlighted text
|
|
44
|
+
content += inputText.substring(nextUnhighlightedRegionStartingIndex, start);
|
|
45
|
+
content += `<span class="${highlightClassName}">`;
|
|
46
|
+
content += inputText.substring(start, end);
|
|
47
|
+
content += '</span>';
|
|
48
|
+
|
|
49
|
+
nextUnhighlightedRegionStartingIndex = end;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Append remaining unhighlighted text
|
|
53
|
+
content += inputText.substring(nextUnhighlightedRegionStartingIndex);
|
|
54
|
+
|
|
55
|
+
return content;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Highlight search results
|
|
59
|
+
return lunrSearchResult.map(({ item, matches }) => {
|
|
60
|
+
const highlightedItem = { ...item };
|
|
61
|
+
|
|
62
|
+
matches.forEach(match => {
|
|
63
|
+
set(highlightedItem, match.key, generateHighlightedText(match.value, match.indices, termLen));
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return highlightedItem;
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// lunr to fusejs layout
|
|
71
|
+
const lunr2fuse = (result) => {
|
|
72
|
+
result.forEach(i => {
|
|
73
|
+
i["item"] = store[i.ref];
|
|
74
|
+
i["refIndex"] = i.ref;
|
|
75
|
+
|
|
76
|
+
// Merge positions
|
|
77
|
+
const mergedMap = {};
|
|
78
|
+
Object.values(i.matchData.metadata).forEach(section => {
|
|
79
|
+
Object.entries(section).forEach(([key, value]) => {
|
|
80
|
+
if (!mergedMap[key]) {
|
|
81
|
+
mergedMap[key] = [];
|
|
82
|
+
}
|
|
83
|
+
if (Array.isArray(value.position)) {
|
|
84
|
+
mergedMap[key].push(...value.position.filter(p => p !== null)); // Remove null values
|
|
85
|
+
}
|
|
64
86
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
} else {
|
|
71
|
-
resultcount.prepend('<div class="card-columns">');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
Object.keys(mergedMap).forEach(key => {
|
|
90
|
+
if (mergedMap[key][0] === undefined) {
|
|
91
|
+
delete mergedMap[key];
|
|
72
92
|
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Convert merged object into an array with "indices" first and "key" second
|
|
96
|
+
const mergedArray = Object.entries(mergedMap)
|
|
97
|
+
.filter(([, positions]) => positions.length > 0) // Remove empty positions
|
|
98
|
+
.map(([key, indices]) => ({ indices, key }));
|
|
99
|
+
mergedArray.forEach(k => {
|
|
100
|
+
k["value"] = i.item[k.key];
|
|
101
|
+
});
|
|
102
|
+
i["matches"] = mergedArray;
|
|
103
|
+
|
|
104
|
+
delete i['ref'];
|
|
105
|
+
delete i['matchData'];
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return result;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// Event listener to update as you write
|
|
112
|
+
// Based on https://stackoverflow.com/questions/75884233/how-to-set-up-fuse-js-like-vs-code
|
|
113
|
+
function init() {
|
|
114
|
+
const termsInput = document.getElementById('search');
|
|
115
|
+
const resultsContainer = document.getElementById('results');
|
|
116
|
+
const resultCount = document.getElementById('resultscount');
|
|
117
|
+
|
|
118
|
+
function renderEntries(entries) {
|
|
119
|
+
resultsContainer.textContent = '';
|
|
120
|
+
|
|
121
|
+
const resl = entries.length;
|
|
122
|
+
if (resl === 0) {
|
|
123
|
+
const el = document.createElement('h6');
|
|
124
|
+
el.className = 'text-center';
|
|
125
|
+
el.textContent = "No results found";
|
|
126
|
+
resultsContainer.appendChild(el);
|
|
127
|
+
return;
|
|
128
|
+
} else {
|
|
129
|
+
entries.forEach(i => {
|
|
130
|
+
let searchitem;
|
|
131
|
+
if (i.img) {
|
|
132
|
+
searchitem = `
|
|
133
|
+
<article class="my-2 text-left">
|
|
134
|
+
<div class="row">
|
|
135
|
+
<div class="col">
|
|
136
|
+
<h5 class="chulapa-links-hover-only" itemprop="headline">
|
|
137
|
+
<a href="${i.url}" rel="permalink">${i.title}</a>
|
|
138
|
+
</h5>
|
|
139
|
+
</div>
|
|
140
|
+
<div class="col-4 col-md-3">
|
|
141
|
+
<a href="${i.url}" rel="permalink">
|
|
142
|
+
<div class="rounded-lg chulapa-overlay-img chulapa-gradient chulapa-min-h-10" style="background-image: url('${i.img}')"></div>
|
|
143
|
+
</a>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
<div class="row mt-2">
|
|
147
|
+
<div class="col">
|
|
148
|
+
<p>${i.excerpt.trim()}</p>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
<hr>
|
|
152
|
+
</article>`;
|
|
153
|
+
} else {
|
|
154
|
+
searchitem = `
|
|
155
|
+
<article class="my-2 text-left">
|
|
156
|
+
<div class="row">
|
|
157
|
+
<div class="col">
|
|
158
|
+
<h5 class="chulapa-links-hover-only" itemprop="headline">
|
|
159
|
+
<a href="${i.url}" rel="permalink">${i.title}</a>
|
|
160
|
+
</h5>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
<div class="row mt-2">
|
|
164
|
+
<div class="col">
|
|
165
|
+
<p>${i.excerpt.trim()}</p>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
<hr>
|
|
169
|
+
</article>`;
|
|
170
|
+
}
|
|
171
|
+
resultsContainer.innerHTML += searchitem;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function handleInputChange() {
|
|
177
|
+
let terms = termsInput.value;
|
|
178
|
+
const termLen = terms.length;
|
|
179
|
+
if (!terms) {
|
|
180
|
+
resultsContainer.textContent = '';
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (termLen === 1) {
|
|
184
|
+
terms = `^${terms}`;
|
|
73
185
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
} else {
|
|
101
|
-
var searchitem =
|
|
102
|
-
'<article class="my-2 text-left">' +
|
|
103
|
-
'<div class="row">' +
|
|
104
|
-
'<div class="col">' +
|
|
105
|
-
'<h5 class="chulapa-links-hover-only" itemprop="headline">' +
|
|
106
|
-
'<a href="' + store[ref].url + '" rel="permalink">' + store[ref].title + '</a>' +
|
|
107
|
-
'</h5>' +
|
|
108
|
-
'</div>' +
|
|
109
|
-
'</div>' +
|
|
110
|
-
'<div class="row mt-2">' +
|
|
111
|
-
'<div class="col">' +
|
|
112
|
-
'<p>' + store[ref].excerpt.split(" ").splice(0, 10).join(" ") +
|
|
113
|
-
'</p>' +
|
|
114
|
-
'</div>' +
|
|
115
|
-
'</div>' +
|
|
116
|
-
'<hr>' +
|
|
117
|
-
'</article>';
|
|
186
|
+
|
|
187
|
+
// Config search
|
|
188
|
+
const idx = lunr(function () {
|
|
189
|
+
this.field('title');
|
|
190
|
+
this.field('subtitle');
|
|
191
|
+
this.field('excerpt');
|
|
192
|
+
this.field('content');
|
|
193
|
+
this.field('categories');
|
|
194
|
+
this.field('date');
|
|
195
|
+
this.field('tags');
|
|
196
|
+
this.ref('id');
|
|
197
|
+
|
|
198
|
+
this.pipeline.remove(lunr.trimmer);
|
|
199
|
+
this.metadataWhitelist = ['position'];
|
|
200
|
+
|
|
201
|
+
for (const item in store) {
|
|
202
|
+
this.add({
|
|
203
|
+
title: store[item].title,
|
|
204
|
+
subtitle: store[item].subtitle,
|
|
205
|
+
excerpt: store[item].excerpt,
|
|
206
|
+
content: store[item].content,
|
|
207
|
+
categories: store[item].categories,
|
|
208
|
+
date: store[item].date,
|
|
209
|
+
tags: store[item].tags,
|
|
210
|
+
id: item
|
|
211
|
+
});
|
|
118
212
|
}
|
|
119
|
-
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// Trigger search
|
|
216
|
+
terms = terms.toLowerCase();
|
|
217
|
+
const result = idx.query(q => {
|
|
218
|
+
terms.split(lunr.tokenizer.separator).forEach(term => {
|
|
219
|
+
q.term(term, { boost: 100 });
|
|
220
|
+
if (terms.lastIndexOf(" ") !== terms.length - 1) {
|
|
221
|
+
q.term(term, {
|
|
222
|
+
usePipeline: false,
|
|
223
|
+
wildcard: lunr.Query.wildcard.TRAILING,
|
|
224
|
+
boost: 10
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
if (term !== "") {
|
|
228
|
+
q.term(term, {
|
|
229
|
+
usePipeline: false,
|
|
230
|
+
editDistance: 1,
|
|
231
|
+
boost: 1
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
const lunres = lunr2fuse(result);
|
|
238
|
+
|
|
239
|
+
const resultFilter = lunres.filter((x) => x.score > 0.5);
|
|
240
|
+
// Log results
|
|
241
|
+
const itLen = resultFilter.length;
|
|
242
|
+
if (itLen === 0) {
|
|
243
|
+
console.log(`No match for '${terms}'`);
|
|
244
|
+
} else {
|
|
245
|
+
resultFilter.forEach(i => {
|
|
246
|
+
console.log(`Searching string '${terms}' gives Score: ${parseInt(i.score * 1000) / 1000} for title: ${i.item.title}`);
|
|
247
|
+
});
|
|
120
248
|
}
|
|
121
|
-
|
|
122
|
-
|
|
249
|
+
|
|
250
|
+
const res = highlight(resultFilter, "bg-warning text-dark", termLen); // Array of items with highlighted fields
|
|
251
|
+
renderEntries(res);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
termsInput.addEventListener('input', handleInputChange);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
init();
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: null
|
|
3
|
+
---
|
|
4
|
+
const highlight=(lunrSearchResult,highlightClassName,termLen)=>{const set=(obj,path,value)=>{const keys=path.split('.');keys.slice(0,-1).reduce((acc,key)=>acc[key],obj)[keys[keys.length-1]]=value};const generateHighlightedText=(inputText,regions,termLen)=>{let content='';let nextUnhighlightedRegionStartingIndex=0;regions.sort((a,b)=>a[0]-b[0]);regions.forEach(region=>{const[start,len]=region;const end=start+len;if(nextUnhighlightedRegionStartingIndex>start)return;if(end-start<2||end-start<Math.floor(termLen/2))return;const theInput=inputText.substring(start);const indexIniTag=theInput.indexOf("<");const indexCloseTag=theInput.indexOf(">");if(indexCloseTag<indexIniTag||(indexIniTag===-1&&indexCloseTag>0))return;content+=inputText.substring(nextUnhighlightedRegionStartingIndex,start);content+=`<span class="${highlightClassName}">`;content+=inputText.substring(start,end);content+='</span>';nextUnhighlightedRegionStartingIndex=end});content+=inputText.substring(nextUnhighlightedRegionStartingIndex);return content};return lunrSearchResult.map(({item,matches})=>{const highlightedItem={...item};matches.forEach(match=>{set(highlightedItem,match.key,generateHighlightedText(match.value,match.indices,termLen))});return highlightedItem})};const lunr2fuse=result=>{result.forEach(i=>{i["item"]=store[i.ref];i["refIndex"]=i.ref;const mergedMap={};Object.values(i.matchData.metadata).forEach(section=>{Object.entries(section).forEach(([key,value])=>{if(!mergedMap[key]){mergedMap[key]=[]}if(Array.isArray(value.position)){mergedMap[key].push(...value.position.filter(p=>p!==null))}})});Object.keys(mergedMap).forEach(key=>{if(mergedMap[key][0]===undefined){delete mergedMap[key]}});const mergedArray=Object.entries(mergedMap).filter(([,positions])=>positions.length>0).map(([key,indices])=>({indices,key}));mergedArray.forEach(k=>{k["value"]=i.item[k.key]});i["matches"]=mergedArray;delete i['ref'];delete i['matchData']});return result};function init(){const termsInput=document.getElementById('search');const resultsContainer=document.getElementById('results');const resultCount=document.getElementById('resultscount');function renderEntries(entries){resultsContainer.textContent='';const resl=entries.length;if(resl===0){const el=document.createElement('h6');el.className='text-center';el.textContent="No results found";resultsContainer.appendChild(el);return}else{entries.forEach(i=>{let searchitem;if(i.img){searchitem=`<article class="my-2 text-left"><div class="row"><div class="col"><h5 class="chulapa-links-hover-only" itemprop="headline"><a href="${i.url}" rel="permalink">${i.title}</a></h5></div><div class="col-4 col-md-3"><a href="${i.url}" rel="permalink"><div class="rounded-lg chulapa-overlay-img chulapa-gradient chulapa-min-h-10" style="background-image: url('${i.img}')"></div></a></div></div><div class="row mt-2"><div class="col"><p>${i.excerpt.trim()}</p></div></div><hr></article>`}else{searchitem=`<article class="my-2 text-left"><div class="row"><div class="col"><h5 class="chulapa-links-hover-only" itemprop="headline"><a href="${i.url}" rel="permalink">${i.title}</a></h5></div></div><div class="row mt-2"><div class="col"><p>${i.excerpt.trim()}</p></div></div><hr></article>`}resultsContainer.innerHTML+=searchitem})}}function handleInputChange(){let terms=termsInput.value;const termLen=terms.length;if(!terms){resultsContainer.textContent='';return}if(termLen===1){terms=`^${terms}`}const idx=lunr(function(){this.field('title');this.field('subtitle');this.field('excerpt');this.field('content');this.field('categories');this.field('date');this.field('tags');this.ref('id');this.pipeline.remove(lunr.trimmer);this.metadataWhitelist=['position'];for(const item in store){this.add({title:store[item].title,subtitle:store[item].subtitle,excerpt:store[item].excerpt,content:store[item].content,categories:store[item].categories,date:store[item].date,tags:store[item].tags,id:item})}});terms=terms.toLowerCase();const result=idx.query(q=>{terms.split(lunr.tokenizer.separator).forEach(term=>{q.term(term,{boost:100});if(terms.lastIndexOf(" ")!==terms.length-1){q.term(term,{usePipeline:false,wildcard:lunr.Query.wildcard.TRAILING,boost:10})}if(term!==""){q.term(term,{usePipeline:false,editDistance:1,boost:1})}})});const lunres=lunr2fuse(result);const resultFilter=lunres.filter(x=>x.score>0.5);const itLen=resultFilter.length;if(itLen===0){console.log(`No match for '${terms}'`)}else{resultFilter.forEach(i=>{console.log(`Searching string '${terms}' gives Score: ${parseInt(i.score*1000)/1000} for title: ${i.item.title}`)})}const res=highlight(resultFilter,"bg-warning text-dark",termLen);renderEntries(res)}termsInput.addEventListener('input',handleInputChange)}init();
|
|
@@ -7,29 +7,37 @@ MIT License
|
|
|
7
7
|
From minimal-mistakes: https://github.com/mmistakes/minimal-mistakes/
|
|
8
8
|
*/
|
|
9
9
|
{%- if site.search.provider =="lunr" -%}
|
|
10
|
-
{% assign maxwords = site.search.lunr_maxwords | default: "30" %}
|
|
10
|
+
{% assign maxwords = site.search.lunr_maxwords | default: site.search.maxwords | default: "30" %}
|
|
11
11
|
var store = [
|
|
12
|
-
|
|
12
|
+
{%- assign indexlunr = site.pages | concat: site.documents | where_exp:'doc','doc.include_on_search != false' -%}
|
|
13
13
|
{%- for doc in indexlunr -%}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
14
|
+
{%- assign descfallback = doc.content |
|
|
15
|
+
markdownify | newline_to_br |
|
|
16
|
+
replace:"<br />", ",.," |
|
|
17
|
+
replace:"{{", ",.," |
|
|
18
|
+
replace:"{%", ",.," |
|
|
19
|
+
split: ",.," | first -%}
|
|
20
|
+
{%- assign ogdesc = doc.excerpt | markdownify | default: descfallback | strip_html | strip_newlines -%}
|
|
21
|
+
{
|
|
22
|
+
"title": {{ doc.title | markdownify | remove: '<p>' | remove: '</p>' | strip_newlines | strip | jsonify }},
|
|
23
|
+
"subtitle": {{ doc.subtitle | markdownify | remove: '<p>' | remove: '</p>' | strip_newlines | strip | jsonify }},
|
|
24
|
+
"excerpt": {{ ogdesc | strip | jsonify }},
|
|
25
|
+
"content": {{ doc.content | markdownify | newline_to_br |
|
|
26
|
+
replace: "<br />", " " |
|
|
27
|
+
replace: "</p>", " " |
|
|
28
|
+
replace: "</h1>", " " |
|
|
29
|
+
replace: "</h2>", " " |
|
|
30
|
+
replace: "</h3>", " " |
|
|
31
|
+
replace: "</h4>", " " |
|
|
32
|
+
replace: "</h5>", " " |
|
|
33
|
+
replace: "</h6>", " " |
|
|
34
|
+
strip_html | strip_newlines | truncatewords: maxwords | strip | jsonify }},
|
|
35
|
+
"categories": {{ doc.categories | jsonify }},
|
|
36
|
+
"date": {{ doc.date | date: "%Y-%m-%d" | jsonify }},
|
|
37
|
+
"tags": {{ doc.tags | jsonify }},
|
|
38
|
+
"url": {{ doc.url | absolute_url | jsonify }},
|
|
39
|
+
"img": {{ doc.og_image | default: doc.header_img | absolute_url | jsonify }}
|
|
40
|
+
}{%- unless forloop.last -%},{%- endunless -%}
|
|
41
|
+
{%- endfor -%}
|
|
42
|
+
]
|
|
35
43
|
{%- endif -%}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: null
|
|
3
|
+
---
|
|
4
|
+
{%- if site.search.provider == "simplesearch" -%}
|
|
5
|
+
{% assign maxwords = site.search.simplesearch_maxwords | default: site.search.maxwords | default: "30" %}
|
|
6
|
+
{%- assign indexsimple = site.pages | concat: site.documents | where_exp: 'doc', 'doc.include_on_search != false' -%}
|
|
7
|
+
|
|
8
|
+
[
|
|
9
|
+
{% for doc in indexsimple %}
|
|
10
|
+
{%- assign myimg = doc.og_image | default: doc.header_img -%}
|
|
11
|
+
{%- assign descfallback = doc.content |
|
|
12
|
+
markdownify | newline_to_br |
|
|
13
|
+
replace: "<br />", ",.," |
|
|
14
|
+
replace: "{{", ",.," |
|
|
15
|
+
replace: "{%", ",.," |
|
|
16
|
+
split: ",.," | first -%}
|
|
17
|
+
{%- assign ogdesc = doc.excerpt | markdownify | default: descfallback | strip_html | strip_newlines -%}
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
"title": {{ doc.title | markdownify | remove: '<p>' | remove: '</p>' | strip_newlines | strip_html | strip | default: " " | jsonify }},
|
|
21
|
+
"subtitle": {{ doc.subtitle | markdownify | remove: '<p>' | remove: '</p>' | strip_newlines | strip_html | strip | default: " " | jsonify }},
|
|
22
|
+
"excerpt": {{ ogdesc | strip_html | strip | default: " " | jsonify }},
|
|
23
|
+
"content": {{ doc.content | markdownify | newline_to_br |
|
|
24
|
+
replace: "<br />", " " |
|
|
25
|
+
replace: "</p>", " " |
|
|
26
|
+
replace: "</h1>", " " |
|
|
27
|
+
replace: "</h2>", " " |
|
|
28
|
+
replace: "</h3>", " " |
|
|
29
|
+
replace: "</h4>", " " |
|
|
30
|
+
replace: "</h5>", " " |
|
|
31
|
+
replace: "</h6>", " " |
|
|
32
|
+
strip_html | strip_newlines | truncatewords: maxwords | strip | default: " " | jsonify }},
|
|
33
|
+
"categories": {{ doc.categories | join: ', ' | strip_html | jsonify }},
|
|
34
|
+
"date": {{ doc.date | date: "%Y-%m-%d" | strip_html | jsonify }},
|
|
35
|
+
"tags": {{ doc.tags | join: ', ' | strip_html | jsonify }},
|
|
36
|
+
"url": {{ doc.url | absolute_url | escape | jsonify }},
|
|
37
|
+
{% if myimg -%}
|
|
38
|
+
"img": ":url('{{ myimg | absolute_url | escape }}')"
|
|
39
|
+
{%- else -%}
|
|
40
|
+
"img": ": none; display: none;"
|
|
41
|
+
{%- endif %}
|
|
42
|
+
} {% unless forloop.last %},{% endunless %}
|
|
43
|
+
{% endfor %}
|
|
44
|
+
]
|
|
45
|
+
{%- endif -%}
|
data/assets/rss.xml
CHANGED
|
@@ -29,22 +29,23 @@ permalink: ./rss.xml
|
|
|
29
29
|
where_exp: "item", "item.date != nil" |
|
|
30
30
|
sort: 'date' | reverse -%}
|
|
31
31
|
{%- for document in alldocs -%}
|
|
32
|
+
{%- include snippets/canonical-url.html url=document.url canonical=document.canonical_url -%}
|
|
32
33
|
{%- assign ogimage = document.og_image | default: document.header_img |
|
|
33
34
|
default: site.og_image |
|
|
34
35
|
absolute_url -%}
|
|
35
36
|
{%- assign words = document.content | strip_html | number_of_words -%}
|
|
36
37
|
{%- assign minutes = words | divided_by: wpm | ceil | at_least: 1 -%}
|
|
37
38
|
<item>
|
|
38
|
-
<title>{{ document.title | strip_html | escape }}</title>
|
|
39
|
+
<title>{{ document.title | markdownify | strip_html | strip_newlines | strip | escape }}</title>
|
|
39
40
|
<description>
|
|
40
41
|
<![CDATA[
|
|
41
|
-
{% if document.subtitle %}<h3>{{ document.subtitle | markdownify }}</h3>{% endif %}
|
|
42
|
+
{% if document.subtitle %}<h3>{{ document.subtitle | markdownify | remove: '<p>' | remove: '</p>' | strip | strip_newlines }}</h3>{% endif %}
|
|
42
43
|
<p>{{ minutes }} min.</p>
|
|
43
44
|
<div>{{ document.content
|
|
44
45
|
| markdownify }}</div>
|
|
45
46
|
]]>
|
|
46
47
|
</description>
|
|
47
|
-
<link>{{
|
|
48
|
+
<link>{{ canonical_url | escape }}</link>
|
|
48
49
|
<category>{{ document.collection }}</category>
|
|
49
50
|
{% if document.tags.size > 0 -%}
|
|
50
51
|
{%- assign tagrss = document.tags | join: ',' | split: ',' | sort | where_exp: "tag","tag != document.layout " -%}
|