chulapa-jekyll 2.0.0 → 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.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +154 -31
  3. data/README.md +96 -76
  4. data/_data/version.yml +2 -2
  5. data/_includes/components/breadcrumbdatesocial.html +15 -11
  6. data/_includes/components/headers.html +17 -10
  7. data/_includes/components/indexcards.html +2 -2
  8. data/_includes/components/navbeforeafter.html +2 -2
  9. data/_includes/components/random.html +103 -0
  10. data/_includes/components/related.html +84 -60
  11. data/_includes/components/simplelist.html +26 -0
  12. data/_includes/footer.html +53 -1
  13. data/_includes/head.html +237 -98
  14. data/_includes/search/fusejs.html +36 -0
  15. data/_includes/search/lunr.html +27 -7
  16. data/_includes/search/simplesearch.html +46 -0
  17. data/_includes/snippets/article-images.html +25 -0
  18. data/_includes/snippets/bootstrapdemo.html +1454 -1303
  19. data/_includes/snippets/breadcrumb-names.html +5 -0
  20. data/_includes/snippets/canonical-url.html +17 -0
  21. data/_includes/snippets/datetranslate.html +7 -1
  22. data/_includes/snippets/jsonld-string.html +16 -0
  23. data/_includes/snippets/og-locale.html +19 -0
  24. data/_includes/snippets/page-language.html +4 -0
  25. data/_includes/snippets/publisher.html +25 -0
  26. data/_includes/snippets/video-metadata.html +15 -0
  27. data/_includes/snippets/video.html +20 -17
  28. data/_includes/snippets/youtube.html +9 -4
  29. data/_includes/welcomments/template.html +1 -1
  30. data/_layouts/archive.html +1 -1
  31. data/_layouts/cloudcategory.html +34 -16
  32. data/_layouts/cloudcategory2.html +4 -85
  33. data/_layouts/cloudtag.html +39 -16
  34. data/_layouts/cloudtag2.html +4 -81
  35. data/_layouts/default.html +4 -4
  36. data/_layouts/landingpage.html +8 -5
  37. data/_layouts/minimal.html +10 -4
  38. data/_layouts/search.html +12 -13
  39. data/_sass/chulapa/_classes.scss +68 -58
  40. data/_sass/chulapa/_reboot.scss +31 -0
  41. data/_sass/chulapa/_variables.scss +8 -1
  42. data/_sass/highlight/README.md +176 -14
  43. data/_sass/highlight/abap.scss +62 -0
  44. data/_sass/highlight/algol.scss +46 -0
  45. data/_sass/highlight/algol_nu.scss +46 -0
  46. data/_sass/highlight/arduino.scss +63 -0
  47. data/_sass/highlight/autumn.scss +69 -58
  48. data/_sass/highlight/base16.scss +90 -0
  49. data/_sass/highlight/borland.scss +55 -46
  50. data/_sass/highlight/bw.scss +70 -34
  51. data/_sass/highlight/cobalt2.scss +197 -0
  52. data/_sass/highlight/coffee.scss +82 -0
  53. data/_sass/highlight/colorful.scss +178 -61
  54. data/_sass/highlight/cran.scss +185 -169
  55. data/_sass/highlight/default.scss +72 -61
  56. data/_sass/highlight/dracula.scss +93 -169
  57. data/_sass/highlight/emacs.scss +72 -61
  58. data/_sass/highlight/friendly.scss +72 -61
  59. data/_sass/highlight/friendly_grayscale.scss +72 -0
  60. data/_sass/highlight/fruity.scss +82 -70
  61. data/_sass/highlight/github.dark.scss +83 -0
  62. data/_sass/highlight/github.scss +116 -61
  63. data/_sass/highlight/gruvbox.dark.scss +83 -0
  64. data/_sass/highlight/gruvbox.light.scss +68 -84
  65. data/_sass/highlight/gruvbox.scss +97 -0
  66. data/_sass/highlight/igor.scss +36 -0
  67. data/_sass/highlight/igorpro.scss +45 -0
  68. data/_sass/highlight/inkpot.scss +78 -0
  69. data/_sass/highlight/lightbulb.scss +82 -0
  70. data/_sass/highlight/lilypond.scss +58 -0
  71. data/_sass/highlight/lovelace.scss +74 -0
  72. data/_sass/highlight/magritte.scss +175 -0
  73. data/_sass/highlight/manni.scss +72 -61
  74. data/_sass/highlight/material.scss +81 -0
  75. data/_sass/highlight/molokai.scss +211 -0
  76. data/_sass/highlight/monokai.scss +217 -65
  77. data/_sass/highlight/monokai.sublime.scss +203 -0
  78. data/_sass/highlight/murphy.scss +72 -61
  79. data/_sass/highlight/native.scss +82 -70
  80. data/_sass/highlight/night-owl.scss +201 -0
  81. data/_sass/highlight/nord.darker.scss +82 -0
  82. data/_sass/highlight/nord.scss +82 -0
  83. data/_sass/highlight/oksolar.dark.scss +175 -0
  84. data/_sass/highlight/oksolar.light.scss +175 -0
  85. data/_sass/highlight/one.dark.scss +82 -0
  86. data/_sass/highlight/panda.scss +195 -0
  87. data/_sass/highlight/paraiso.dark.scss +76 -0
  88. data/_sass/highlight/paraiso.light.scss +76 -0
  89. data/_sass/highlight/pastie.scss +154 -60
  90. data/_sass/highlight/perldoc.scss +69 -58
  91. data/_sass/highlight/rainbow_dash.scss +65 -0
  92. data/_sass/highlight/rrt.scss +82 -0
  93. data/_sass/highlight/sas.scss +63 -0
  94. data/_sass/highlight/selenized.black.scss +175 -0
  95. data/_sass/highlight/selenized.dark.scss +175 -0
  96. data/_sass/highlight/selenized.light.scss +175 -0
  97. data/_sass/highlight/selenized.white.scss +175 -0
  98. data/_sass/highlight/skeletor.scss +190 -140
  99. data/_sass/highlight/solarized.dark.scss +82 -0
  100. data/_sass/highlight/solarized.light.scss +82 -0
  101. data/_sass/highlight/stackoverflow.dark.scss +175 -0
  102. data/_sass/highlight/stackoverflow.light.scss +175 -0
  103. data/_sass/highlight/staroffice.scss +82 -0
  104. data/_sass/highlight/stata.dark.scss +82 -0
  105. data/_sass/highlight/stata.light.scss +49 -0
  106. data/_sass/highlight/tango.scss +81 -69
  107. data/_sass/highlight/template.scss +290 -0
  108. data/_sass/highlight/thankful_eyes.scss +180 -173
  109. data/_sass/highlight/trac.scss +70 -59
  110. data/_sass/highlight/tulip.scss +171 -0
  111. data/_sass/highlight/vim.scss +82 -70
  112. data/_sass/highlight/vs.scss +41 -33
  113. data/_sass/highlight/xcode.scss +65 -0
  114. data/_sass/highlight/zenburn.scss +82 -136
  115. data/_sass/reset-algolia.scss +27 -17
  116. data/_sass/skins/academia.scss +19 -10
  117. data/_sass/skins/auto.scss +5 -2
  118. data/_sass/skins/butterfly-dark.scss +54 -0
  119. data/_sass/skins/butterfly-dim.scss +54 -0
  120. data/_sass/skins/butterfly.scss +33 -0
  121. data/_sass/skins/chulapa.scss +10 -3
  122. data/_sass/skins/cyborg.scss +512 -0
  123. data/_sass/skins/dark-bg.scss +83 -49
  124. data/_sass/skins/darkly.scss +424 -0
  125. data/_sass/skins/deeply.scss +262 -63
  126. data/_sass/skins/electro.scss +24 -17
  127. data/_sass/skins/flatly.scss +386 -0
  128. data/_sass/skins/focal.scss +24 -18
  129. data/_sass/skins/gitdev-dark.scss +12 -20
  130. data/_sass/skins/gitdev.scss +20 -17
  131. data/_sass/skins/graymor.scss +22 -14
  132. data/_sass/skins/hootstrap.scss +17 -10
  133. data/_sass/skins/journal.scss +74 -86
  134. data/_sass/skins/listen.scss +51 -0
  135. data/_sass/skins/lux.scss +171 -237
  136. data/_sass/skins/lymcha.scss +14 -9
  137. data/_sass/skins/materia.scss +889 -0
  138. data/_sass/skins/media.scss +29 -11
  139. data/_sass/skins/mickie.scss +27 -11
  140. data/_sass/skins/minco.scss +30 -10
  141. data/_sass/skins/minty.scss +226 -85
  142. data/_sass/skins/monotone.scss +15 -1
  143. data/_sass/skins/navi.scss +26 -0
  144. data/_sass/skins/pear.scss +16 -5
  145. data/_sass/skins/preptor.scss +13 -12
  146. data/_sass/skins/skeeblu.scss +11 -11
  147. data/_sass/skins/sketchy.scss +366 -377
  148. data/_sass/skins/slate.scss +719 -0
  149. data/_sass/skins/solar.scss +425 -0
  150. data/_sass/skins/sunset.scss +27 -12
  151. data/_sass/skins/towards.scss +19 -5
  152. data/_sass/skins/twitter-dim.scss +20 -11
  153. data/_sass/skins/twitter-lights-out.scss +22 -11
  154. data/_sass/skins/twitter.scss +22 -10
  155. data/_sass/skins/united.scss +57 -0
  156. data/_sass/skins/universal.scss +29 -27
  157. data/_sass/skins/wandoo.scss +12 -11
  158. data/_sass/skins/yeti.scss +673 -0
  159. data/assets/atom.xml +10 -6
  160. data/assets/js/better404/better404.js +75 -0
  161. data/assets/js/ch_ytdefer/ch_ytdefer.js +0 -1
  162. data/assets/js/chulapa_script.js +2 -2
  163. data/assets/js/fusejs/fusejs-search.js +197 -0
  164. data/assets/js/fusejs/fusejs-search.min.js +4 -0
  165. data/assets/js/fusejs/fusejs-store.js +43 -0
  166. data/assets/js/lunr/lunr-search.js +249 -114
  167. data/assets/js/lunr/lunr-search.min.js +4 -0
  168. data/assets/js/lunr/lunr-store.js +31 -23
  169. data/assets/js/simplesearch/simplesearch-store.json +45 -0
  170. data/assets/rss.xml +4 -3
  171. metadata +81 -8
  172. data/_sass/highlight/UNLICENSE.txt +0 -24
@@ -1,122 +1,257 @@
1
1
  ---
2
2
  layout: null
3
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
-
10
-
11
- var inputVal = document.getElementById("search").value;
12
- var idx = lunr(function() {
13
- this.field('title')
14
- this.field('subtitle')
15
- this.field('excerpt')
16
- this.field('categories')
17
- this.field('date')
18
- this.field('tags')
19
- this.ref('id')
20
-
21
- this.pipeline.remove(lunr.trimmer)
22
-
23
- for (var item in store) {
24
- this.add({
25
- title: store[item].title,
26
- subtitle: store[item].subtitle,
27
- excerpt: store[item].excerpt,
28
- categories: store[item].categories,
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 = (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
- resultdiv.empty();
66
- resultcount.empty()
67
- if (query.length > 0) {
68
- if (result.length < 1) {
69
- resultcount.prepend('<h6 class="text-center">No results found</h6><div class="card-columns">');
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
- for (var item in result) {
75
- var ref = result[item].ref;
76
- if (store[ref].img) {
77
- var searchitem =
78
- '<article class="my-2 text-left">' +
79
- '<div class="row">' +
80
- '<div class="col">' +
81
- '<h5 class="chulapa-links-hover-only" itemprop="headline">' +
82
- '<a href="' + store[ref].url + '" rel="permalink">' + store[ref].title + '</a>' +
83
- '</h5>' +
84
- '</div>' +
85
- '<div class="col-4 col-md-3">' +
86
- '<a href="' + store[ref].url + '" rel="permalink">' +
87
- '<div class="rounded-lg chulapa-overlay-img chulapa-gradient chulapa-min-h-10"'+
88
- 'style="background-image:' +
89
- 'url(\'' + store[ref].img + '\')" ></div>' +
90
- '</div></a>' +
91
- '</div>' +
92
- '<div class="row mt-2">' +
93
- '<div class="col">' +
94
- '<p>' + store[ref].excerpt.split(" ").splice(0, 10).join(" ") +
95
- '</p>' +
96
- '</div>' +
97
- '</div>' +
98
- '<hr>' +
99
- '</article>';
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
- resultdiv.append(searchitem);
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
- {%- assign indexlunr = site.pages | concat: site.documents | where_exp:'doc','doc.include_on_search != false' -%}
12
+ {%- assign indexlunr = site.pages | concat: site.documents | where_exp:'doc','doc.include_on_search != false' -%}
13
13
  {%- for doc in indexlunr -%}
14
- {
15
- "title": {{ doc.title | jsonify }},
16
- "subtitle": {{ doc.subtitle | jsonify }},
17
- "excerpt":
18
- {{ doc.content | newline_to_br |
19
- replace:"<br />", " " |
20
- replace:"</p>", " " |
21
- replace:"</h1>", " " |
22
- replace:"</h2>", " " |
23
- replace:"</h3>", " " |
24
- replace:"</h4>", " " |
25
- replace:"</h5>", " " |
26
- replace:"</h6>", " "|
27
- strip_html | strip_newlines | truncatewords: maxwords | jsonify }},
28
- "categories": {{ doc.categories | jsonify }},
29
- "date": {{ doc.date | date: "%Y-%m-%d" | jsonify }},
30
- "tags": {{ doc.tags | jsonify }},
31
- "url": {{ doc.url | absolute_url | jsonify }},
32
- "img": {{ doc.og_image | default: doc.header_img | absolute_url | jsonify }}
33
- }{%- unless forloop.last -%},{%- endunless -%}
34
- {%- endfor -%}]
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>{{ document.url | absolute_url }}</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 " -%}