jekyll-calculus-theme 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32cc802a73fbd787aca0fed3c5022c013b5f33ebef53abc93f468a4be57bcd36
4
- data.tar.gz: 1e2b994a71d8bc4b2d1d047d916a89b9185d5bcce2057610605ac5d2b191b116
3
+ metadata.gz: 475d7f3c38371b348b2b3d79dd97caffeed21336037b20dc3a1432812bf297f4
4
+ data.tar.gz: 1fcddedb24c6b5175a46e7e343abd1d4389704dda4a592633ccf323dec4ff3f9
5
5
  SHA512:
6
- metadata.gz: 69d8b1bea5be9677689f07b7f734c1484f276d24e0079daa43ad6a80366096fc0c95498d4a1df8745fb9f5b42843b9dd3afc0c249e9350c3816e632eb19beec5
7
- data.tar.gz: df15b79248ea21a0102ff0026e340dcd52f8f3c5011fe89f985f8bd8bc030b24720a141ffbae2ca72823ed60425e890c0dbb5b4db0cb0517a27f8e38535c8ec9
6
+ metadata.gz: d13c691f8f86659643c860e24fe3bc64c46d2eb59a2e3c8e2e7ceec7d35c00a4ca69c608fdcb2f125747727d810aa02b2a55a1b32e7af39fba064740992c3bce
7
+ data.tar.gz: e5e7a6b3c500dfd80ae4b663807eed5f0cd9545ac7ec029c6a7c09b5fef309c3b6e58fb05082e68c9d548ca3d56f5104c9ffb270d16d6ec50e897aa1fdba6bc7
data/_sass/_main.scss CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
 
11
11
  html {
12
- font-size: 15px;
12
+ font-size: 16px;
13
13
  }
14
14
 
15
15
  #theme-toggle {
@@ -0,0 +1,433 @@
1
+ /*!
2
+ * Simple-Jekyll-Search
3
+ * Copyright 2015-2020, Christian Fei
4
+ * Licensed under the MIT License.
5
+ */
6
+
7
+ (function(){
8
+ 'use strict'
9
+
10
+ var _$Templater_7 = {
11
+ compile: compile,
12
+ setOptions: setOptions
13
+ }
14
+
15
+ const options = {}
16
+ options.pattern = /\{(.*?)\}/g
17
+ options.template = ''
18
+ options.middleware = function () {}
19
+
20
+ function setOptions (_options) {
21
+ options.pattern = _options.pattern || options.pattern
22
+ options.template = _options.template || options.template
23
+ if (typeof _options.middleware === 'function') {
24
+ options.middleware = _options.middleware
25
+ }
26
+ }
27
+
28
+ function compile (data) {
29
+ return options.template.replace(options.pattern, function (match, prop) {
30
+ const value = options.middleware(prop, data[prop], options.template)
31
+ if (typeof value !== 'undefined') {
32
+ return value
33
+ }
34
+ return data[prop] || match
35
+ })
36
+ }
37
+
38
+ 'use strict';
39
+
40
+ function fuzzysearch (needle, haystack) {
41
+ var tlen = haystack.length;
42
+ var qlen = needle.length;
43
+ if (qlen > tlen) {
44
+ return false;
45
+ }
46
+ if (qlen === tlen) {
47
+ return needle === haystack;
48
+ }
49
+ outer: for (var i = 0, j = 0; i < qlen; i++) {
50
+ var nch = needle.charCodeAt(i);
51
+ while (j < tlen) {
52
+ if (haystack.charCodeAt(j++) === nch) {
53
+ continue outer;
54
+ }
55
+ }
56
+ return false;
57
+ }
58
+ return true;
59
+ }
60
+
61
+ var _$fuzzysearch_1 = fuzzysearch;
62
+
63
+ 'use strict'
64
+
65
+ /* removed: const _$fuzzysearch_1 = require('fuzzysearch') */;
66
+
67
+ var _$FuzzySearchStrategy_5 = new FuzzySearchStrategy()
68
+
69
+ function FuzzySearchStrategy () {
70
+ this.matches = function (string, crit) {
71
+ return _$fuzzysearch_1(crit.toLowerCase(), string.toLowerCase())
72
+ }
73
+ }
74
+
75
+ 'use strict'
76
+
77
+ var _$LiteralSearchStrategy_6 = new LiteralSearchStrategy()
78
+
79
+ function LiteralSearchStrategy () {
80
+ this.matches = function (str, crit) {
81
+ if (!str) return false
82
+
83
+ str = str.trim().toLowerCase()
84
+ crit = crit.trim().toLowerCase()
85
+
86
+ return crit.split(' ').filter(function (word) {
87
+ return str.indexOf(word) >= 0
88
+ }).length === crit.split(' ').length
89
+ }
90
+ }
91
+
92
+ 'use strict'
93
+
94
+ var _$Repository_4 = {
95
+ put: put,
96
+ clear: clear,
97
+ search: search,
98
+ setOptions: __setOptions_4
99
+ }
100
+
101
+ /* removed: const _$FuzzySearchStrategy_5 = require('./SearchStrategies/FuzzySearchStrategy') */;
102
+ /* removed: const _$LiteralSearchStrategy_6 = require('./SearchStrategies/LiteralSearchStrategy') */;
103
+
104
+ function NoSort () {
105
+ return 0
106
+ }
107
+
108
+ const data = []
109
+ let opt = {}
110
+
111
+ opt.fuzzy = false
112
+ opt.limit = 10
113
+ opt.searchStrategy = opt.fuzzy ? _$FuzzySearchStrategy_5 : _$LiteralSearchStrategy_6
114
+ opt.sort = NoSort
115
+ opt.exclude = []
116
+
117
+ function put (data) {
118
+ if (isObject(data)) {
119
+ return addObject(data)
120
+ }
121
+ if (isArray(data)) {
122
+ return addArray(data)
123
+ }
124
+ return undefined
125
+ }
126
+ function clear () {
127
+ data.length = 0
128
+ return data
129
+ }
130
+
131
+ function isObject (obj) {
132
+ return Boolean(obj) && Object.prototype.toString.call(obj) === '[object Object]'
133
+ }
134
+
135
+ function isArray (obj) {
136
+ return Boolean(obj) && Object.prototype.toString.call(obj) === '[object Array]'
137
+ }
138
+
139
+ function addObject (_data) {
140
+ data.push(_data)
141
+ return data
142
+ }
143
+
144
+ function addArray (_data) {
145
+ const added = []
146
+ clear()
147
+ for (let i = 0, len = _data.length; i < len; i++) {
148
+ if (isObject(_data[i])) {
149
+ added.push(addObject(_data[i]))
150
+ }
151
+ }
152
+ return added
153
+ }
154
+
155
+ function search (crit) {
156
+ if (!crit) {
157
+ return []
158
+ }
159
+ return findMatches(data, crit, opt.searchStrategy, opt).sort(opt.sort)
160
+ }
161
+
162
+ function __setOptions_4 (_opt) {
163
+ opt = _opt || {}
164
+
165
+ opt.fuzzy = _opt.fuzzy || false
166
+ opt.limit = _opt.limit || 10
167
+ opt.searchStrategy = _opt.fuzzy ? _$FuzzySearchStrategy_5 : _$LiteralSearchStrategy_6
168
+ opt.sort = _opt.sort || NoSort
169
+ opt.exclude = _opt.exclude || []
170
+ }
171
+
172
+ function findMatches (data, crit, strategy, opt) {
173
+ const matches = []
174
+ for (let i = 0; i < data.length && matches.length < opt.limit; i++) {
175
+ const match = findMatchesInObject(data[i], crit, strategy, opt)
176
+ if (match) {
177
+ matches.push(match)
178
+ }
179
+ }
180
+ return matches
181
+ }
182
+
183
+ function findMatchesInObject (obj, crit, strategy, opt) {
184
+ for (const key in obj) {
185
+ if (!isExcluded(obj[key], opt.exclude) && strategy.matches(obj[key], crit)) {
186
+ return obj
187
+ }
188
+ }
189
+ }
190
+
191
+ function isExcluded (term, excludedTerms) {
192
+ for (let i = 0, len = excludedTerms.length; i < len; i++) {
193
+ const excludedTerm = excludedTerms[i]
194
+ if (new RegExp(excludedTerm).test(term)) {
195
+ return true
196
+ }
197
+ }
198
+ return false
199
+ }
200
+
201
+ /* globals ActiveXObject:false */
202
+
203
+ 'use strict'
204
+
205
+ var _$JSONLoader_2 = {
206
+ load: load
207
+ }
208
+
209
+ function load (location, callback) {
210
+ const xhr = getXHR()
211
+ xhr.open('GET', location, true)
212
+ xhr.onreadystatechange = createStateChangeListener(xhr, callback)
213
+ xhr.send()
214
+ }
215
+
216
+ function createStateChangeListener (xhr, callback) {
217
+ return function () {
218
+ if (xhr.readyState === 4 && xhr.status === 200) {
219
+ try {
220
+ callback(null, JSON.parse(xhr.responseText))
221
+ } catch (err) {
222
+ callback(err, null)
223
+ }
224
+ }
225
+ }
226
+ }
227
+
228
+ function getXHR () {
229
+ return window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP')
230
+ }
231
+
232
+ 'use strict'
233
+
234
+ var _$OptionsValidator_3 = function OptionsValidator (params) {
235
+ if (!validateParams(params)) {
236
+ throw new Error('-- OptionsValidator: required options missing')
237
+ }
238
+
239
+ if (!(this instanceof OptionsValidator)) {
240
+ return new OptionsValidator(params)
241
+ }
242
+
243
+ const requiredOptions = params.required
244
+
245
+ this.getRequiredOptions = function () {
246
+ return requiredOptions
247
+ }
248
+
249
+ this.validate = function (parameters) {
250
+ const errors = []
251
+ requiredOptions.forEach(function (requiredOptionName) {
252
+ if (typeof parameters[requiredOptionName] === 'undefined') {
253
+ errors.push(requiredOptionName)
254
+ }
255
+ })
256
+ return errors
257
+ }
258
+
259
+ function validateParams (params) {
260
+ if (!params) {
261
+ return false
262
+ }
263
+ return typeof params.required !== 'undefined' && params.required instanceof Array
264
+ }
265
+ }
266
+
267
+ 'use strict'
268
+
269
+ var _$utils_9 = {
270
+ merge: merge,
271
+ isJSON: isJSON
272
+ }
273
+
274
+ function merge (defaultParams, mergeParams) {
275
+ const mergedOptions = {}
276
+ for (const option in defaultParams) {
277
+ mergedOptions[option] = defaultParams[option]
278
+ if (typeof mergeParams[option] !== 'undefined') {
279
+ mergedOptions[option] = mergeParams[option]
280
+ }
281
+ }
282
+ return mergedOptions
283
+ }
284
+
285
+ function isJSON (json) {
286
+ try {
287
+ if (json instanceof Object && JSON.parse(JSON.stringify(json))) {
288
+ return true
289
+ }
290
+ return false
291
+ } catch (err) {
292
+ return false
293
+ }
294
+ }
295
+
296
+ var _$src_8 = {};
297
+ (function (window) {
298
+ 'use strict'
299
+
300
+ let options = {
301
+ searchInput: null,
302
+ resultsContainer: null,
303
+ json: [],
304
+ success: Function.prototype,
305
+ searchResultTemplate: '<li><a href="{url}" title="{desc}">{title}</a></li>',
306
+ templateMiddleware: Function.prototype,
307
+ sortMiddleware: function () {
308
+ return 0
309
+ },
310
+ noResultsText: 'No results found',
311
+ limit: 10,
312
+ fuzzy: false,
313
+ debounceTime: null,
314
+ exclude: []
315
+ }
316
+
317
+ let debounceTimerHandle
318
+ const debounce = function (func, delayMillis) {
319
+ if (delayMillis) {
320
+ clearTimeout(debounceTimerHandle)
321
+ debounceTimerHandle = setTimeout(func, delayMillis)
322
+ } else {
323
+ func.call()
324
+ }
325
+ }
326
+
327
+ const requiredOptions = ['searchInput', 'resultsContainer', 'json']
328
+
329
+ /* removed: const _$Templater_7 = require('./Templater') */;
330
+ /* removed: const _$Repository_4 = require('./Repository') */;
331
+ /* removed: const _$JSONLoader_2 = require('./JSONLoader') */;
332
+ const optionsValidator = _$OptionsValidator_3({
333
+ required: requiredOptions
334
+ })
335
+ /* removed: const _$utils_9 = require('./utils') */;
336
+
337
+ window.SimpleJekyllSearch = function (_options) {
338
+ const errors = optionsValidator.validate(_options)
339
+ if (errors.length > 0) {
340
+ throwError('You must specify the following required options: ' + requiredOptions)
341
+ }
342
+
343
+ options = _$utils_9.merge(options, _options)
344
+
345
+ _$Templater_7.setOptions({
346
+ template: options.searchResultTemplate,
347
+ middleware: options.templateMiddleware
348
+ })
349
+
350
+ _$Repository_4.setOptions({
351
+ fuzzy: options.fuzzy,
352
+ limit: options.limit,
353
+ sort: options.sortMiddleware,
354
+ exclude: options.exclude
355
+ })
356
+
357
+ if (_$utils_9.isJSON(options.json)) {
358
+ initWithJSON(options.json)
359
+ } else {
360
+ initWithURL(options.json)
361
+ }
362
+
363
+ const rv = {
364
+ search: search
365
+ }
366
+
367
+ typeof options.success === 'function' && options.success.call(rv)
368
+ return rv
369
+ }
370
+
371
+ function initWithJSON (json) {
372
+ _$Repository_4.put(json)
373
+ registerInput()
374
+ }
375
+
376
+ function initWithURL (url) {
377
+ _$JSONLoader_2.load(url, function (err, json) {
378
+ if (err) {
379
+ throwError('failed to get JSON (' + url + ')')
380
+ }
381
+ initWithJSON(json)
382
+ })
383
+ }
384
+
385
+ function emptyResultsContainer () {
386
+ options.resultsContainer.innerHTML = ''
387
+ }
388
+
389
+ function appendToResultsContainer (text) {
390
+ options.resultsContainer.innerHTML += text
391
+ }
392
+
393
+ function registerInput () {
394
+ options.searchInput.addEventListener('input', function (e) {
395
+ if (isWhitelistedKey(e.which)) {
396
+ emptyResultsContainer()
397
+ debounce(function () { search(e.target.value) }, options.debounceTime)
398
+ }
399
+ })
400
+ }
401
+
402
+ function search (query) {
403
+ if (isValidQuery(query)) {
404
+ emptyResultsContainer()
405
+ render(_$Repository_4.search(query), query)
406
+ }
407
+ }
408
+
409
+ function render (results, query) {
410
+ const len = results.length
411
+ if (len === 0) {
412
+ return appendToResultsContainer(options.noResultsText)
413
+ }
414
+ for (let i = 0; i < len; i++) {
415
+ results[i].query = query
416
+ appendToResultsContainer(_$Templater_7.compile(results[i]))
417
+ }
418
+ }
419
+
420
+ function isValidQuery (query) {
421
+ return query && query.length > 0
422
+ }
423
+
424
+ function isWhitelistedKey (key) {
425
+ return [13, 16, 20, 37, 38, 39, 40, 91].indexOf(key) === -1
426
+ }
427
+
428
+ function throwError (message) {
429
+ throw new Error('SimpleJekyllSearch --- ' + message)
430
+ }
431
+ })(window)
432
+
433
+ }());
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-calculus-theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jain Basil Aliyas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-08 00:00:00.000000000 Z
11
+ date: 2021-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -46,6 +46,7 @@ files:
46
46
  - _layouts/tag.html
47
47
  - _sass/_main.scss
48
48
  - assets/css/syntax.css
49
+ - assets/js/simple-jekyll-search.js
49
50
  homepage: https://jainbasilaliyas.in
50
51
  licenses:
51
52
  - MIT