chulapa-jekyll 2.0.1 → 2.2.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 +264 -35
- data/README.md +189 -180
- data/_data/version.yml +2 -2
- data/_includes/components/archive-documents.html +56 -0
- data/_includes/components/author.html +6 -1
- data/_includes/components/breadcrumbdatesocial.html +16 -12
- data/_includes/components/cactus.html +2 -1
- data/_includes/components/cloud-entry.html +26 -0
- data/_includes/components/cloud.html +66 -0
- data/_includes/components/collection-documents.html +17 -0
- data/_includes/components/footer-content.html +34 -0
- data/_includes/components/headers.html +22 -15
- data/_includes/components/indexcards.html +13 -10
- data/_includes/components/indexcategory-documents.html +11 -0
- data/_includes/components/navbar-classic.html +58 -0
- data/_includes/components/navbeforeafter.html +9 -6
- data/_includes/components/navigation-fallback.html +19 -0
- data/_includes/components/random.html +1 -0
- data/_includes/components/recommendations.html +97 -0
- data/_includes/components/related.html +1 -104
- data/_includes/components/scripts.html +9 -0
- data/_includes/components/sidetoc.html +5 -4
- data/_includes/components/simplelist.html +26 -0
- data/_includes/components/skin-attribution.html +169 -0
- data/_includes/components/theme-selector.html +14 -0
- data/_includes/footer.html +14 -165
- data/_includes/head.html +389 -242
- data/_includes/navbar.html +33 -77
- data/_includes/search/fusejs.html +20 -0
- data/_includes/search/google.html +3 -3
- data/_includes/search/lunr.html +19 -7
- data/_includes/search/simplesearch.html +46 -0
- data/_includes/snippets/article-images.html +25 -0
- data/_includes/snippets/bootstrapdemo.html +1472 -1303
- data/_includes/snippets/breadcrumb-names.html +5 -0
- data/_includes/snippets/canonical-url.html +17 -0
- data/_includes/snippets/carousel.html +16 -12
- data/_includes/snippets/dark-skin-enabled.html +14 -0
- data/_includes/snippets/datetranslate.html +7 -1
- data/_includes/snippets/jsonld-string.html +16 -0
- data/_includes/snippets/masonry.html +6 -4
- data/_includes/snippets/microformats-url.html +2 -0
- data/_includes/snippets/og-locale.html +19 -0
- data/_includes/snippets/page-language.html +4 -0
- data/_includes/snippets/publisher.html +22 -0
- data/_includes/snippets/video-metadata.html +15 -0
- data/_includes/snippets/video.html +21 -18
- data/_includes/snippets/youtube.html +17 -6
- data/_includes/theme-styles.html +201 -0
- data/_includes/welcomments/comment_form.html +5 -4
- data/_includes/welcomments/comments.html +5 -5
- data/_includes/welcomments/template.html +1 -1
- data/_layouts/archive.html +2 -75
- data/_layouts/cloudcategory.html +2 -101
- data/_layouts/cloudtag.html +2 -103
- data/_layouts/compress.html +1 -1
- data/_layouts/default.html +20 -9
- data/_layouts/indexcategory.html +2 -30
- data/_layouts/landingpage.html +12 -7
- data/_layouts/minimal.html +19 -9
- data/_layouts/search.html +17 -17
- data/_sass/bootstrap/_variables.scss +1 -1
- data/_sass/bootstrap/mixins/_badge.scss +1 -1
- data/_sass/chulapa/_autothemer.scss +31 -0
- data/_sass/chulapa/_buttons.scss +101 -0
- data/_sass/chulapa/_classes.scss +197 -59
- data/_sass/chulapa/_mixins.scss +42 -1
- data/_sass/chulapa/_reboot.scss +31 -0
- data/_sass/chulapa/_theme-selector.scss +1 -0
- data/_sass/chulapa/_variables.scss +8 -1
- data/_sass/chulapa/skins/_deeply.scss +229 -0
- data/_sass/chulapa/skins/_electro.scss +30 -0
- data/_sass/chulapa/skins/_graymor.scss +39 -0
- data/_sass/chulapa/skins/_hootstrap.scss +34 -0
- data/_sass/chulapa/skins/_lymcha.scss +27 -0
- data/_sass/chulapa/skins/_mickie.scss +38 -0
- data/_sass/chulapa/skins/_minco.scss +45 -0
- data/_sass/chulapa/skins/_monotone.scss +15 -0
- data/_sass/chulapa/skins/_preptor.scss +30 -0
- data/_sass/chulapa/skins/_skeeblu.scss +34 -0
- data/_sass/chulapa/skins/_sunset.scss +33 -0
- data/_sass/chulapa/skins/_wandoo.scss +22 -0
- data/_sass/chulapa/skins/bootswatch/_cyborg.scss +543 -0
- data/_sass/chulapa/skins/bootswatch/_darkly.scss +452 -0
- data/_sass/chulapa/skins/bootswatch/_flatly.scss +415 -0
- data/_sass/chulapa/skins/bootswatch/_journal.scss +163 -0
- data/_sass/chulapa/skins/bootswatch/_lux.scss +342 -0
- data/_sass/chulapa/skins/bootswatch/_materia.scss +914 -0
- data/_sass/chulapa/skins/bootswatch/_minty.scss +342 -0
- data/_sass/chulapa/skins/bootswatch/_sketchy.scss +757 -0
- data/_sass/chulapa/skins/bootswatch/_slate.scss +746 -0
- data/_sass/chulapa/skins/bootswatch/_solar.scss +454 -0
- data/_sass/chulapa/skins/bootswatch/_united.scss +85 -0
- data/_sass/chulapa/skins/bootswatch/_yeti.scss +699 -0
- data/_sass/chulapa/skins/bootswatch/cyborg.patch +301 -0
- data/_sass/chulapa/skins/bootswatch/darkly.patch +493 -0
- data/_sass/chulapa/skins/bootswatch/flatly.patch +325 -0
- data/_sass/chulapa/skins/bootswatch/journal.patch +71 -0
- data/_sass/chulapa/skins/bootswatch/lux.patch +97 -0
- data/_sass/chulapa/skins/bootswatch/materia.patch +250 -0
- data/_sass/chulapa/skins/bootswatch/minty.patch +400 -0
- data/_sass/chulapa/skins/bootswatch/sketchy.patch +863 -0
- data/_sass/chulapa/skins/bootswatch/slate.patch +537 -0
- data/_sass/chulapa/skins/bootswatch/solar.patch +307 -0
- data/_sass/chulapa/skins/bootswatch/united.patch +91 -0
- data/_sass/chulapa/skins/bootswatch/yeti.patch +552 -0
- data/_sass/chulapa-master.scss +10 -0
- 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 +47 -10
- data/_sass/skins/auto.scss +25 -27
- data/_sass/skins/butterfly-dark.scss +73 -0
- data/_sass/skins/butterfly-dim.scss +81 -0
- data/_sass/skins/butterfly.scss +65 -0
- data/_sass/skins/cerulean.scss +120 -0
- data/_sass/skins/chulapa.scss +33 -6
- data/_sass/skins/cyborg.scss +3 -0
- data/_sass/skins/dark-bg.scss +83 -49
- data/_sass/skins/darkly.scss +3 -0
- data/_sass/skins/deeply.scss +17 -87
- data/_sass/skins/electro.scss +5 -19
- data/_sass/skins/flatly.scss +3 -0
- data/_sass/skins/focal.scss +56 -19
- data/_sass/skins/gitdev-dark.scss +28 -25
- data/_sass/skins/gitdev.scss +22 -19
- data/_sass/skins/graymor.scss +7 -22
- data/_sass/skins/hootstrap.scss +6 -13
- data/_sass/skins/journal.scss +3 -143
- data/_sass/skins/listen.scss +83 -0
- data/_sass/skins/litera.scss +281 -0
- data/_sass/skins/lux.scss +3 -376
- data/_sass/skins/lymcha.scss +4 -12
- data/_sass/skins/materia.scss +3 -0
- data/_sass/skins/media.scss +40 -12
- data/_sass/skins/mickie.scss +8 -11
- data/_sass/skins/minco.scss +11 -10
- data/_sass/skins/minty.scss +3 -168
- data/_sass/skins/monotone.scss +7 -11
- data/_sass/skins/navi.scss +54 -0
- data/_sass/skins/none.scss +24 -2
- data/_sass/skins/pear.scss +50 -6
- data/_sass/skins/preptor.scss +6 -15
- data/_sass/skins/pulse.scss +158 -0
- data/_sass/skins/skeeblu.scss +6 -17
- data/_sass/skins/sketchy.scss +3 -746
- data/_sass/skins/slate.scss +3 -0
- data/_sass/skins/solar.scss +3 -0
- data/_sass/skins/sunset.scss +6 -11
- data/_sass/skins/towards.scss +44 -5
- data/_sass/skins/twitter-dim.scss +60 -13
- data/_sass/skins/twitter-lights-out.scss +44 -11
- data/_sass/skins/twitter.scss +51 -10
- data/_sass/skins/united.scss +3 -0
- data/_sass/skins/universal.scss +46 -27
- data/_sass/skins/wandoo.scss +7 -12
- data/_sass/skins/yeti.scss +3 -0
- data/_sass/vendor/bootswatch/LICENSE +21 -0
- data/_sass/vendor/bootswatch/LICENSE-4.5.0 +21 -0
- data/_sass/vendor/bootswatch/README.md +57 -0
- data/_sass/vendor/bootswatch/cerulean/_bootswatch.scss +102 -0
- data/_sass/vendor/bootswatch/cerulean/_variables.scss +57 -0
- data/_sass/vendor/bootswatch/cyborg/_bootswatch.scss +330 -0
- data/_sass/vendor/bootswatch/cyborg/_variables.scss +169 -0
- data/_sass/vendor/bootswatch/darkly/_bootswatch.scss +247 -0
- data/_sass/vendor/bootswatch/darkly/_variables.scss +164 -0
- data/_sass/vendor/bootswatch/flatly/_bootswatch.scss +274 -0
- data/_sass/vendor/bootswatch/flatly/_variables.scss +106 -0
- data/_sass/vendor/bootswatch/journal/_bootswatch.scss +62 -0
- data/_sass/vendor/bootswatch/journal/_variables.scss +60 -0
- data/_sass/vendor/bootswatch/litera/_bootswatch.scss +268 -0
- data/_sass/vendor/bootswatch/litera/_variables.scss +96 -0
- data/_sass/vendor/bootswatch/lux/_bootswatch.scss +191 -0
- data/_sass/vendor/bootswatch/lux/_variables.scss +103 -0
- data/_sass/vendor/bootswatch/materia/_bootswatch.scss +747 -0
- data/_sass/vendor/bootswatch/materia/_variables.scss +129 -0
- data/_sass/vendor/bootswatch/minty/_bootswatch.scss +380 -0
- data/_sass/vendor/bootswatch/minty/_variables.scss +94 -0
- data/_sass/vendor/bootswatch/pulse/_bootswatch.scss +145 -0
- data/_sass/vendor/bootswatch/pulse/_variables.scss +96 -0
- data/_sass/vendor/bootswatch/sketchy/_bootswatch.scss +492 -0
- data/_sass/vendor/bootswatch/sketchy/_variables.scss +172 -0
- data/_sass/vendor/bootswatch/slate/_bootswatch.scss +531 -0
- data/_sass/vendor/bootswatch/slate/_variables.scss +163 -0
- data/_sass/vendor/bootswatch/solar/_bootswatch.scss +243 -0
- data/_sass/vendor/bootswatch/solar/_variables.scss +171 -0
- data/_sass/vendor/bootswatch/source.json +86 -0
- data/_sass/vendor/bootswatch/united/_bootswatch.scss +10 -0
- data/_sass/vendor/bootswatch/united/_variables.scss +54 -0
- data/_sass/vendor/bootswatch/yeti/_bootswatch.scss +586 -0
- data/_sass/vendor/bootswatch/yeti/_variables.scss +110 -0
- data/_sass/vendor/tophat/LICENSE +21 -0
- data/_sass/vendor/tophat/README.md +38 -0
- data/_sass/vendor/tophat/deeply/_styles.scss +6 -0
- data/_sass/vendor/tophat/deeply/_variables.scss +73 -0
- data/_sass/vendor/tophat/deeply/theme.scss +77 -0
- data/_sass/vendor/tophat/electro/_styles.scss +5 -0
- data/_sass/vendor/tophat/electro/_variables.scss +23 -0
- data/_sass/vendor/tophat/electro/theme.scss +28 -0
- data/_sass/vendor/tophat/graymor/_styles.scss +5 -0
- data/_sass/vendor/tophat/graymor/_variables.scss +18 -0
- data/_sass/vendor/tophat/graymor/theme.scss +24 -0
- data/_sass/vendor/tophat/hootstrap/_styles.scss +5 -0
- data/_sass/vendor/tophat/hootstrap/_variables.scss +14 -0
- data/_sass/vendor/tophat/hootstrap/theme.scss +18 -0
- data/_sass/vendor/tophat/lymcha/_styles.scss +5 -0
- data/_sass/vendor/tophat/lymcha/_variables.scss +13 -0
- data/_sass/vendor/tophat/lymcha/theme.scss +16 -0
- data/_sass/vendor/tophat/mickie/_styles.scss +5 -0
- data/_sass/vendor/tophat/mickie/_variables.scss +13 -0
- data/_sass/vendor/tophat/mickie/theme.scss +17 -0
- data/_sass/vendor/tophat/minco/_styles.scss +5 -0
- data/_sass/vendor/tophat/minco/_variables.scss +14 -0
- data/_sass/vendor/tophat/minco/theme.scss +18 -0
- data/_sass/vendor/tophat/monotone/_styles.scss +5 -0
- data/_sass/vendor/tophat/monotone/_variables.scss +14 -0
- data/_sass/vendor/tophat/monotone/theme.scss +18 -0
- data/_sass/vendor/tophat/preptor/_styles.scss +5 -0
- data/_sass/vendor/tophat/preptor/_variables.scss +14 -0
- data/_sass/vendor/tophat/preptor/theme.scss +18 -0
- data/_sass/vendor/tophat/skeeblu/_styles.scss +5 -0
- data/_sass/vendor/tophat/skeeblu/_variables.scss +17 -0
- data/_sass/vendor/tophat/skeeblu/theme.scss +22 -0
- data/_sass/vendor/tophat/source.json +57 -0
- data/_sass/vendor/tophat/sunset/_styles.scss +5 -0
- data/_sass/vendor/tophat/sunset/_variables.scss +13 -0
- data/_sass/vendor/tophat/sunset/theme.scss +16 -0
- data/_sass/vendor/tophat/wandoo/_styles.scss +5 -0
- data/_sass/vendor/tophat/wandoo/_variables.scss +18 -0
- data/_sass/vendor/tophat/wandoo/theme.scss +24 -0
- data/assets/atom.xml +10 -6
- data/assets/css/dark/highlighter.scss +10 -0
- data/assets/css/dark/main.scss +43 -0
- data/assets/css/highlighter.scss +6 -1
- data/assets/css/main.scss +12 -3
- data/assets/css/search-fusejs.css +14 -0
- data/assets/css/search-lunr.css +7 -0
- data/assets/js/better404/better404.js +68 -0
- data/assets/js/ch_ytdefer/ch_ytdefer.js +27 -83
- data/assets/js/chulapa_carousel.js +115 -0
- data/assets/js/chulapa_mermaid.js +31 -0
- data/assets/js/chulapa_navigation.js +71 -0
- data/assets/js/chulapa_photoswipe.js +106 -0
- data/assets/js/chulapa_script.js +199 -77
- data/assets/js/chulapa_search.js +89 -0
- data/assets/js/clipboard/chulapa_clipboard.js +17 -108
- data/assets/js/cusdis/chulapa_cusdis.js +1 -1
- data/assets/js/fusejs/fusejs-search.js +62 -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 +127 -115
- 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 +220 -8
- data/_sass/highlight/UNLICENSE.txt +0 -24
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Shared presentation for local search engines; index positions are normalized here.
|
|
2
|
+
window.ChulapaSearch = (function () {
|
|
3
|
+
function highlight(results, className, termLength, positionsAreLengths) {
|
|
4
|
+
return results.map(({item, matches = []}) => {
|
|
5
|
+
const output = {...item};
|
|
6
|
+
for (const match of matches) {
|
|
7
|
+
const text = String(match.value);
|
|
8
|
+
let content = "", next = 0;
|
|
9
|
+
const ranges = match.indices.map(([start, end]) => [start, positionsAreLengths ? start + end : end + 1])
|
|
10
|
+
.sort((a, b) => a[0] - b[0]);
|
|
11
|
+
for (const [start, end] of ranges) {
|
|
12
|
+
if (start < next || end - start < Math.max(2, Math.floor(termLength / 2))) continue;
|
|
13
|
+
// Leave author-supplied HTML tags and encoded entities intact.
|
|
14
|
+
const before = text.slice(0, start);
|
|
15
|
+
if (before.lastIndexOf("<") > before.lastIndexOf(">") || /[<>]/.test(text.slice(start, end))) continue;
|
|
16
|
+
if (before.lastIndexOf("&") > before.lastIndexOf(";") && /^&[^;\s]*$/.test(before.slice(before.lastIndexOf("&")))) continue;
|
|
17
|
+
if (/&[^;\s]*$/.test(text.slice(start, end))) continue;
|
|
18
|
+
content += text.slice(next, start) + `<span class="${className}">` + text.slice(start, end) + "</span>";
|
|
19
|
+
next = end;
|
|
20
|
+
}
|
|
21
|
+
content += text.slice(next);
|
|
22
|
+
const keys = match.key.split(".");
|
|
23
|
+
const target = keys.slice(0, -1).reduce((value, key) => value[key], output);
|
|
24
|
+
target[keys[keys.length - 1]] = content;
|
|
25
|
+
}
|
|
26
|
+
return output;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function renderEntries(container, entries) {
|
|
30
|
+
const fragment = document.createDocumentFragment();
|
|
31
|
+
if (!entries.length) {
|
|
32
|
+
const empty = document.createElement("p");
|
|
33
|
+
empty.className = "h6 text-center";
|
|
34
|
+
empty.textContent = "No results found";
|
|
35
|
+
fragment.append(empty);
|
|
36
|
+
}
|
|
37
|
+
for (const item of entries) {
|
|
38
|
+
const article = document.createElement("article");
|
|
39
|
+
article.className = "my-2 text-left";
|
|
40
|
+
article.innerHTML = `<div class="row"><div class="col"><h2 class="h5 chulapa-links-hover-only" itemprop="headline"><a rel="permalink"></a></h2></div></div>
|
|
41
|
+
<div class="row mt-2"><div class="col"><p></p></div></div><hr>`;
|
|
42
|
+
const title = article.querySelector("h2 a");
|
|
43
|
+
title.href = item.url;
|
|
44
|
+
title.innerHTML = item.title;
|
|
45
|
+
article.querySelector("p").innerHTML = item.excerpt.trim();
|
|
46
|
+
if (item.img) {
|
|
47
|
+
const column = document.createElement("div");
|
|
48
|
+
column.className = "col-4 col-md-3";
|
|
49
|
+
const link = document.createElement("a");
|
|
50
|
+
link.href = item.url;
|
|
51
|
+
link.rel = "permalink";
|
|
52
|
+
// Highlight spans belong to the visible title, not its accessible name.
|
|
53
|
+
link.setAttribute("aria-label", title.textContent);
|
|
54
|
+
const image = document.createElement("div");
|
|
55
|
+
image.className = "rounded-lg chulapa-overlay-img chulapa-gradient chulapa-min-h-10";
|
|
56
|
+
image.style.backgroundImage = `url(${JSON.stringify(item.img)})`;
|
|
57
|
+
link.append(image);
|
|
58
|
+
column.append(link);
|
|
59
|
+
article.querySelector(".row").append(column);
|
|
60
|
+
}
|
|
61
|
+
fragment.append(article);
|
|
62
|
+
}
|
|
63
|
+
container.replaceChildren(fragment);
|
|
64
|
+
const status = document.getElementById("resultscount");
|
|
65
|
+
if (status) status.textContent = `${entries.length} ${entries.length === 1 ? "result" : "results"} found`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function bindInput(input, render) {
|
|
69
|
+
let timer;
|
|
70
|
+
function update() {
|
|
71
|
+
if (!input.value) {
|
|
72
|
+
const status = document.getElementById("resultscount");
|
|
73
|
+
if (status) status.textContent = "";
|
|
74
|
+
}
|
|
75
|
+
render();
|
|
76
|
+
}
|
|
77
|
+
input.addEventListener("input", () => {
|
|
78
|
+
clearTimeout(timer);
|
|
79
|
+
if (!input.value) update();
|
|
80
|
+
else timer = setTimeout(update, 150);
|
|
81
|
+
});
|
|
82
|
+
if (input.form) input.form.addEventListener("submit", event => {
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
update();
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return {highlight, renderEntries, bindInput};
|
|
89
|
+
})();
|
|
@@ -1,109 +1,18 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
function showTooltip(btn, message) {
|
|
8
|
-
btn.tooltip('hide')
|
|
9
|
-
.attr('data-original-title', message)
|
|
10
|
-
.tooltip('show');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function hideTooltip(btn) {
|
|
14
|
-
setTimeout(function() {
|
|
15
|
-
btn.tooltip('hide');
|
|
16
|
-
}, 1000);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function sleep(ms) {
|
|
20
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function setTooltip(btn, tooltip, style) {
|
|
24
|
-
btn.classList.remove('text-muted');
|
|
25
|
-
btn.classList.add(style);
|
|
26
|
-
btn.setAttribute('aria-label', tooltip);
|
|
27
|
-
await sleep(1000);
|
|
28
|
-
btn.classList.add('text-muted');
|
|
29
|
-
btn.setAttribute('aria-label', 'Copy code to clipboard');
|
|
30
|
-
btn.removeAttribute('data-original-title');
|
|
31
|
-
btn.classList.remove(style);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// End helpers tooltip
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// Insert buttons
|
|
38
|
-
function ch_clipboard_setup() {
|
|
39
|
-
var d = document;
|
|
40
|
-
var els = d.querySelectorAll('pre');
|
|
41
|
-
for (var i = 0; i < els.length; i++) {
|
|
42
|
-
// Select all pre codes
|
|
43
|
-
var preBlock = els[i];
|
|
44
|
-
// Select first child
|
|
45
|
-
let codeBlock = preBlock.firstChild;
|
|
46
|
-
|
|
47
|
-
// If first child is code
|
|
48
|
-
if (codeBlock.tagName.toLowerCase() == 'code') {
|
|
49
|
-
// Add id to code block
|
|
50
|
-
codeBlock.setAttribute('id', 'clipboard_code' + i);
|
|
51
|
-
// Create button
|
|
52
|
-
var btn = d.createElement('button');
|
|
53
|
-
btn.classList.add('btn', 'text-muted', 'btn-sm', 'btn-chulapa-copy-code');
|
|
54
|
-
btn.innerHTML = "<i class='far fa-copy'></i>";
|
|
55
|
-
btn.id = 'clipboard_btn' + i;
|
|
56
|
-
btn.type = 'button';
|
|
57
|
-
btn.setAttribute('data-toggle', 'tooltip');
|
|
58
|
-
btn.setAttribute('data-placement', 'left');
|
|
59
|
-
btn.setAttribute('aria-label', 'Copy code to clipboard');
|
|
60
|
-
//Function to copy to clipboard
|
|
61
|
-
btn.onclick = ch_copy_cliboard(i);
|
|
62
|
-
preBlock.prepend(btn);
|
|
63
|
-
} else {
|
|
64
|
-
console.log('No code block for\n' + preBlock.innerHTML);
|
|
65
|
-
}
|
|
1
|
+
// Compatibility entry point: use the maintained clipboard implementation.
|
|
2
|
+
(function () {
|
|
3
|
+
var source = document.currentScript;
|
|
4
|
+
function setup() {
|
|
5
|
+
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", function () { ch_clipboard_setup(document); }, {once: true});
|
|
6
|
+
else ch_clipboard_setup(document);
|
|
66
7
|
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
navigator.clipboard.writeText('');
|
|
79
|
-
|
|
80
|
-
var btn = d.getElementById('clipboard_btn' + i);
|
|
81
|
-
var btnTrigger = $(btn);
|
|
82
|
-
|
|
83
|
-
// Set initial values
|
|
84
|
-
|
|
85
|
-
let style = 'text-success';
|
|
86
|
-
let msg = 'Copied on the clipboard:\n' + codeBlockStripped;
|
|
87
|
-
let tooltip = 'Copied!';
|
|
88
|
-
try {
|
|
89
|
-
navigator.clipboard.writeText(codeBlockStripped);
|
|
90
|
-
} catch {
|
|
91
|
-
// Modify on error
|
|
92
|
-
style = 'text-danger';
|
|
93
|
-
tooltip = 'Error!';
|
|
94
|
-
msg = 'Error when copying the code';
|
|
95
|
-
}
|
|
96
|
-
setTooltip(btn, tooltip, style);
|
|
97
|
-
showTooltip(btnTrigger, tooltip);
|
|
98
|
-
hideTooltip(btnTrigger);
|
|
99
|
-
console.log(msg);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
// stripHtml safely
|
|
103
|
-
function stripHtml(html){
|
|
104
|
-
let tmp = document.createElement('DIV');
|
|
105
|
-
tmp.innerHTML = html;
|
|
106
|
-
return tmp.textContent || tmp.innerText || '';
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
window.addEventListener('load', ch_clipboard_setup);
|
|
8
|
+
if (typeof ch_clipboard_setup === "function") { setup(); return; }
|
|
9
|
+
var url = new URL("../chulapa_script.js", source.src).href;
|
|
10
|
+
var script = Array.from(document.scripts).find(function (item) { return item.src === url; });
|
|
11
|
+
if (!script) {
|
|
12
|
+
script = document.createElement("script");
|
|
13
|
+
script.src = url;
|
|
14
|
+
script.setAttribute("data-clipboard-only", "true");
|
|
15
|
+
script.addEventListener("load", setup);
|
|
16
|
+
(document.body || document.head).append(script);
|
|
17
|
+
} else script.addEventListener("load", setup, {once: true});
|
|
18
|
+
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
window.CUSDIS={};let e;function t(t){return e||(e=document.createElement("iframe"),function(e,t){const s=window.matchMedia("(prefers-color-scheme: dark)"),d=d=>{try{const i=JSON.parse(d.data);if("cusdis"===i.from)switch(i.event){case"onload":"auto"===t.dataset.theme&&n("setTheme",s.matches?"dark":"light");break;case"resize":e.style.height=i.data+"px"}}catch(i){}};function i(e){const s=e.matches;"auto"===t.dataset.theme&&n("setTheme",s?"dark":"light")}window.addEventListener("message",d),s.addEventListener("change",i)}(e,t)),e.srcdoc=(e=>{const t=e.dataset.host||"https://cusdis.com",n=e.dataset.iframe||`${t}/js/iframe.umd.js`,cch=document.getElementById("maincss").href;return`<!DOCTYPE html>\n<html>\n <head>\n <link rel="stylesheet" href="${t}/js/style.css">\n <link rel="stylesheet" href="${cch}">\n <base target="_parent" />\n <link>\n <script>\n window.CUSDIS_LOCALE = ${JSON.stringify(window.CUSDIS_LOCALE)}\n window.__DATA__ = ${JSON.stringify(e.dataset)}\n <\/script>\n <style>\n :root {\n color-scheme: light;\n }\n </style>\n </head>\n <body id="ch-cusdis">\n <div id="root"></div>\n <script src="${n}" type="module">\n \n <\/script>\n </body>\n</html>`})(t),e.style.width="100%",e.style.border="0",e}function n(t,n){e&&e.contentWindow.postMessage(JSON.stringify({from:"cusdis",event:t,data:n}))}function s(e){if(e){e.innerHTML="";const n=t(e);e.appendChild(n)}}function d(){let e;window.cusdisElementId?e=document.querySelector(`#${window.cusdisElementId}`):document.querySelector("#cusdis_thread")?e=document.querySelector("#cusdis_thread"):document.querySelector("#cusdis")&&(console.warn("id `cusdis` is deprecated. Please use `cusdis_thread` instead"),e=document.querySelector("#cusdis")),!0===window.CUSDIS_PREVENT_INITIAL_RENDER||e&&s(e)}window.renderCusdis=s,window.CUSDIS.renderTo=s,window.CUSDIS.setTheme=function(e){n("setTheme",e)},window.CUSDIS.initial=d,d();
|
|
1
|
+
(function(){window.CUSDIS={};let e;function t(t){return e||(e=document.createElement("iframe"),function(e,t){const s=window.matchMedia("(prefers-color-scheme: dark)"),d=d=>{try{if(d.source!==e.contentWindow)return;const i=JSON.parse(d.data);if("cusdis"===i.from)switch(i.event){case"onload":"auto"===t.dataset.theme&&n("setTheme",s.matches?"dark":"light");break;case"resize":if(typeof i.data==="number"&&Number.isFinite(i.data)&&i.data>=0)e.style.height=i.data+"px"}}catch(i){}};function i(e){const s=e.matches;"auto"===t.dataset.theme&&n("setTheme",s?"dark":"light")}window.addEventListener("message",d),s.addEventListener("change",i)}(e,t)),e.srcdoc=(e=>{const t=e.dataset.host||"https://cusdis.com",n=e.dataset.iframe||`${t}/js/iframe.umd.js`,cch=document.getElementById("maincss").href;return`<!DOCTYPE html>\n<html>\n <head>\n <link rel="stylesheet" href="${t}/js/style.css">\n <link rel="stylesheet" href="${cch}">\n <base target="_parent" />\n <link>\n <script>\n window.CUSDIS_LOCALE = ${JSON.stringify(window.CUSDIS_LOCALE)}\n window.__DATA__ = ${JSON.stringify(e.dataset)}\n <\/script>\n <style>\n :root {\n color-scheme: light;\n }\n </style>\n </head>\n <body id="ch-cusdis">\n <div id="root"></div>\n <script src="${n}" type="module">\n \n <\/script>\n </body>\n</html>`})(t),e.style.width="100%",e.style.border="0",e}function n(t,n){e&&e.contentWindow.postMessage(JSON.stringify({from:"cusdis",event:t,data:n}))}function s(e){if(e){e.innerHTML="";const n=t(e);e.appendChild(n)}}function d(){let e;window.cusdisElementId?e=document.querySelector(`#${window.cusdisElementId}`):document.querySelector("#cusdis_thread")?e=document.querySelector("#cusdis_thread"):document.querySelector("#cusdis")&&(console.warn("id `cusdis` is deprecated. Please use `cusdis_thread` instead"),e=document.querySelector("#cusdis")),!0===window.CUSDIS_PREVENT_INITIAL_RENDER||e&&s(e)}window.renderCusdis=s,window.CUSDIS.renderTo=s,window.CUSDIS.setTheme=function(e){n("setTheme",e)},window.CUSDIS.initial=d,d();})();
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: null
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
// Based on https://gist.github.com/evenfrost/1ba123656ded32fb7a0cd4651efd4db0
|
|
6
|
+
// Sort regions to avoid breaking layout
|
|
7
|
+
// Avoid highlighting single characters
|
|
8
|
+
// Mask highlighting happening in html tags (class or style)
|
|
9
|
+
|
|
10
|
+
const highlight = (results, className, termLength) =>
|
|
11
|
+
ChulapaSearch.highlight(results.filter(result => result.matches && result.matches.length), className, termLength, false);
|
|
12
|
+
|
|
13
|
+
// Event listener to update as you write
|
|
14
|
+
// Based on https://stackoverflow.com/questions/75884233/how-to-set-up-fuse-js-like-vs-code
|
|
15
|
+
function init() {
|
|
16
|
+
const termsInput = document.getElementById('search');
|
|
17
|
+
const resultsContainer = document.getElementById('results');
|
|
18
|
+
if (!termsInput || !resultsContainer) return;
|
|
19
|
+
const options = {
|
|
20
|
+
keys: ['subtitle', 'content', 'categories', 'date',
|
|
21
|
+
{ name: 'title', weight: 1.15 },
|
|
22
|
+
{ name: 'tags', weight: 1.1 },
|
|
23
|
+
{ name: 'excerpt', weight: 1.05 }
|
|
24
|
+
],
|
|
25
|
+
isCaseSensitive: false,
|
|
26
|
+
ignoreDiacritics: true,
|
|
27
|
+
includeScore: true,
|
|
28
|
+
includeMatches: true, // For search highlight
|
|
29
|
+
minMatchCharLength: 2,
|
|
30
|
+
threshold: 0.35,
|
|
31
|
+
shouldSort: true,
|
|
32
|
+
ignoreLocation: true,
|
|
33
|
+
ignoreFieldNorm: true,
|
|
34
|
+
useExtendedSearch: true,
|
|
35
|
+
};
|
|
36
|
+
const fuse = new Fuse(store, options);
|
|
37
|
+
|
|
38
|
+
function renderEntries(entries) {
|
|
39
|
+
ChulapaSearch.renderEntries(resultsContainer, entries);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function handleInputChange() {
|
|
43
|
+
let terms = termsInput.value;
|
|
44
|
+
const termLen = terms.length;
|
|
45
|
+
if (!terms) {
|
|
46
|
+
resultsContainer.textContent = '';
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (termLen === 1) {
|
|
50
|
+
terms = `^${terms}`;
|
|
51
|
+
}
|
|
52
|
+
const result = fuse.search(terms, { limit: 10 });
|
|
53
|
+
const resultFilter = result.filter((x) => x.score < 0.75);
|
|
54
|
+
|
|
55
|
+
const res = highlight(resultFilter, "bg-warning text-dark", termLen); // array of items with highlighted fields
|
|
56
|
+
renderEntries(res);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
ChulapaSearch.bindInput(termsInput, handleInputChange);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
init();
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: null
|
|
3
|
+
---
|
|
4
|
+
const highlight=(t,n,i)=>ChulapaSearch.highlight(t.filter(r=>r.matches&&r.matches.length),n,i,!1);function init(){const t=document.getElementById("search"),n=document.getElementById("results");if(!t||!n)return;const i={keys:["subtitle","content","categories","date",{name:"title",weight:1.15},{name:"tags",weight:1.1},{name:"excerpt",weight:1.05}],isCaseSensitive:!1,ignoreDiacritics:!0,includeScore:!0,includeMatches:!0,minMatchCharLength:2,threshold:.35,shouldSort:!0,ignoreLocation:!0,ignoreFieldNorm:!0,useExtendedSearch:!0},r=new Fuse(store,i);function a(e){ChulapaSearch.renderEntries(n,e)}function c(){let e=t.value;const s=e.length;if(!e){n.textContent="";return}s===1&&(e=`^${e}`);const o=r.search(e,{limit:10}).filter(h=>h.score<.75),u=highlight(o,"bg-warning text-dark",s);a(u)}ChulapaSearch.bindInput(t,c)}init();
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: null
|
|
3
|
+
---
|
|
4
|
+
/*
|
|
5
|
+
Copyright (c) 2013-2020 Michael Rose and contributors
|
|
6
|
+
MIT License
|
|
7
|
+
From minimal-mistakes: https://github.com/mmistakes/minimal-mistakes/
|
|
8
|
+
*/
|
|
9
|
+
{%- if site.search.provider == "fusejs" -%}
|
|
10
|
+
{% assign maxwords = site.search.fusejs_maxwords | default: site.search.maxwords | default: "30" %}
|
|
11
|
+
var store = [
|
|
12
|
+
{%- assign indexfusejs = site.pages | concat: site.documents | where_exp: 'doc', 'doc.include_on_search != false' -%}
|
|
13
|
+
{%- for doc in indexfusejs -%}
|
|
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 | markdownify | 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
|
+
]
|
|
43
|
+
{%- endif -%}
|
|
@@ -1,122 +1,134 @@
|
|
|
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
|
-
date: store[item].date,
|
|
30
|
-
tags: store[item].tags,
|
|
31
|
-
id: item
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
console.log(jQuery.type(idx));
|
|
37
|
-
|
|
38
|
-
$(document).ready(function() {
|
|
39
|
-
$('input#search').on('keyup', function() {
|
|
40
|
-
var resultdiv = $('#results');
|
|
41
|
-
var resultcount = $('#resultscount');
|
|
42
|
-
var query = $(this).val().toLowerCase();
|
|
43
|
-
var result =
|
|
44
|
-
idx.query(function(q) {
|
|
45
|
-
query.split(lunr.tokenizer.separator).forEach(function(term) {
|
|
46
|
-
q.term(term, {
|
|
47
|
-
boost: 100
|
|
48
|
-
})
|
|
49
|
-
if (query.lastIndexOf(" ") != query.length - 1) {
|
|
50
|
-
q.term(term, {
|
|
51
|
-
usePipeline: false,
|
|
52
|
-
wildcard: lunr.Query.wildcard.TRAILING,
|
|
53
|
-
boost: 10
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
if (term != "") {
|
|
57
|
-
q.term(term, {
|
|
58
|
-
usePipeline: false,
|
|
59
|
-
editDistance: 1,
|
|
60
|
-
boost: 1
|
|
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 = (results, className, termLength) =>
|
|
11
|
+
ChulapaSearch.highlight(results, className, termLength, true);
|
|
12
|
+
|
|
13
|
+
// lunr to fusejs layout
|
|
14
|
+
const lunr2fuse = (result) => {
|
|
15
|
+
result.forEach(i => {
|
|
16
|
+
i["item"] = store[i.ref];
|
|
17
|
+
i["refIndex"] = i.ref;
|
|
18
|
+
|
|
19
|
+
// Merge positions
|
|
20
|
+
const mergedMap = {};
|
|
21
|
+
Object.values(i.matchData.metadata).forEach(section => {
|
|
22
|
+
Object.entries(section).forEach(([key, value]) => {
|
|
23
|
+
if (!mergedMap[key]) {
|
|
24
|
+
mergedMap[key] = [];
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(value.position)) {
|
|
27
|
+
mergedMap[key].push(...value.position.filter(p => p !== null)); // Remove null values
|
|
28
|
+
}
|
|
64
29
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
} else {
|
|
71
|
-
resultcount.prepend('<div class="card-columns">');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
Object.keys(mergedMap).forEach(key => {
|
|
33
|
+
if (mergedMap[key][0] === undefined) {
|
|
34
|
+
delete mergedMap[key];
|
|
72
35
|
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Convert merged object into an array with "indices" first and "key" second
|
|
39
|
+
const mergedArray = Object.entries(mergedMap)
|
|
40
|
+
.filter(([, positions]) => positions.length > 0) // Remove empty positions
|
|
41
|
+
.map(([key, indices]) => ({ indices, key }));
|
|
42
|
+
mergedArray.forEach(k => {
|
|
43
|
+
k["value"] = i.item[k.key];
|
|
44
|
+
});
|
|
45
|
+
i["matches"] = mergedArray;
|
|
46
|
+
|
|
47
|
+
delete i['ref'];
|
|
48
|
+
delete i['matchData'];
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Event listener to update as you write
|
|
55
|
+
// Based on https://stackoverflow.com/questions/75884233/how-to-set-up-fuse-js-like-vs-code
|
|
56
|
+
function init() {
|
|
57
|
+
const termsInput = document.getElementById('search');
|
|
58
|
+
const resultsContainer = document.getElementById('results');
|
|
59
|
+
if (!termsInput || !resultsContainer) return;
|
|
60
|
+
|
|
61
|
+
function renderEntries(entries) {
|
|
62
|
+
ChulapaSearch.renderEntries(resultsContainer, entries);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let idx;
|
|
66
|
+
function handleInputChange() {
|
|
67
|
+
let terms = termsInput.value;
|
|
68
|
+
const termLen = terms.length;
|
|
69
|
+
if (!terms) {
|
|
70
|
+
resultsContainer.textContent = '';
|
|
71
|
+
return;
|
|
73
72
|
}
|
|
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>';
|
|
73
|
+
|
|
74
|
+
// Config search
|
|
75
|
+
if (!idx) idx = lunr(function () {
|
|
76
|
+
this.field('title');
|
|
77
|
+
this.field('subtitle');
|
|
78
|
+
this.field('excerpt');
|
|
79
|
+
this.field('content');
|
|
80
|
+
this.field('categories');
|
|
81
|
+
this.field('date');
|
|
82
|
+
this.field('tags');
|
|
83
|
+
this.ref('id');
|
|
84
|
+
|
|
85
|
+
this.pipeline.remove(lunr.trimmer);
|
|
86
|
+
this.metadataWhitelist = ['position'];
|
|
87
|
+
|
|
88
|
+
for (const item in store) {
|
|
89
|
+
this.add({
|
|
90
|
+
title: store[item].title,
|
|
91
|
+
subtitle: store[item].subtitle,
|
|
92
|
+
excerpt: store[item].excerpt,
|
|
93
|
+
content: store[item].content,
|
|
94
|
+
categories: store[item].categories,
|
|
95
|
+
date: store[item].date,
|
|
96
|
+
tags: store[item].tags,
|
|
97
|
+
id: item
|
|
98
|
+
});
|
|
118
99
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Trigger search
|
|
103
|
+
terms = terms.toLowerCase();
|
|
104
|
+
const result = idx.query(q => {
|
|
105
|
+
terms.split(lunr.tokenizer.separator).forEach(term => {
|
|
106
|
+
q.term(term, { boost: 100 });
|
|
107
|
+
if (terms.lastIndexOf(" ") !== terms.length - 1) {
|
|
108
|
+
q.term(term, {
|
|
109
|
+
usePipeline: false,
|
|
110
|
+
wildcard: lunr.Query.wildcard.TRAILING,
|
|
111
|
+
boost: 10
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (term !== "") {
|
|
115
|
+
q.term(term, {
|
|
116
|
+
usePipeline: false,
|
|
117
|
+
editDistance: 1,
|
|
118
|
+
boost: 1
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const lunres = lunr2fuse(result);
|
|
125
|
+
|
|
126
|
+
const resultFilter = lunres.filter((x) => x.score > 0.5);
|
|
127
|
+
const res = highlight(resultFilter, "bg-warning text-dark", termLen); // Array of items with highlighted fields
|
|
128
|
+
renderEntries(res);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
ChulapaSearch.bindInput(termsInput, handleInputChange);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
init();
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: null
|
|
3
|
+
---
|
|
4
|
+
const highlight=(n,e,i)=>ChulapaSearch.highlight(n,e,i,!0),lunr2fuse=n=>(n.forEach(e=>{e.item=store[e.ref],e.refIndex=e.ref;const i={};Object.values(e.matchData.metadata).forEach(s=>{Object.entries(s).forEach(([t,o])=>{i[t]||(i[t]=[]),Array.isArray(o.position)&&i[t].push(...o.position.filter(c=>c!==null))})}),Object.keys(i).forEach(s=>{i[s][0]===void 0&&delete i[s]});const a=Object.entries(i).filter(([,s])=>s.length>0).map(([s,t])=>({indices:t,key:s}));a.forEach(s=>{s.value=e.item[s.key]}),e.matches=a,delete e.ref,delete e.matchData}),n);function init(){const n=document.getElementById("search"),e=document.getElementById("results");if(!n||!e)return;function i(t){ChulapaSearch.renderEntries(e,t)}let a;function s(){let t=n.value;const o=t.length;if(!t){e.textContent="";return}a||(a=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 r in store)this.add({title:store[r].title,subtitle:store[r].subtitle,excerpt:store[r].excerpt,content:store[r].content,categories:store[r].categories,date:store[r].date,tags:store[r].tags,id:r})})),t=t.toLowerCase();const c=a.query(r=>{t.split(lunr.tokenizer.separator).forEach(l=>{r.term(l,{boost:100}),t.lastIndexOf(" ")!==t.length-1&&r.term(l,{usePipeline:!1,wildcard:lunr.Query.wildcard.TRAILING,boost:10}),l!==""&&r.term(l,{usePipeline:!1,editDistance:1,boost:1})})}),d=lunr2fuse(c).filter(r=>r.score>.5),h=highlight(d,"bg-warning text-dark",o);i(h)}ChulapaSearch.bindInput(n,s)}init();
|