rawfeed 0.0.1 → 0.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/LICENSE.txt +21 -0
- data/README.md +153 -1
- data/_data/resume.yml +184 -0
- data/_includes/alert +3 -0
- data/_includes/chart +34 -0
- data/_includes/details +57 -0
- data/_includes/enddetails +2 -0
- data/_includes/endtabs +2 -0
- data/_includes/image +61 -0
- data/_includes/layout/blog_search.html +18 -0
- data/_includes/layout/data.liquid +3 -0
- data/_includes/layout/disqus.html +30 -0
- data/_includes/layout/footer.html +34 -0
- data/_includes/layout/giscus.html +21 -0
- data/_includes/layout/google_analytics.html +11 -0
- data/_includes/layout/head.html +59 -0
- data/_includes/layout/header.html +143 -0
- data/_includes/layout/maintenance.html +30 -0
- data/_includes/layout/paginator.html +35 -0
- data/_includes/socials +22 -0
- data/_includes/tabs +94 -0
- data/_includes/toc +160 -0
- data/_includes/video +10 -0
- data/_layouts/blog.html +46 -0
- data/_layouts/contact.html +285 -0
- data/_layouts/default.html +248 -0
- data/_layouts/error.html +15 -0
- data/_layouts/home.html +58 -0
- data/_layouts/page.html +9 -0
- data/_layouts/post.html +103 -0
- data/_layouts/resume.html +260 -0
- data/_layouts/tag.html +22 -0
- data/_layouts/tag_posts.html +27 -0
- data/_sass/base/_index.scss +63 -0
- data/_sass/base/_reset.scss +10 -0
- data/_sass/base/_typography.scss +0 -0
- data/_sass/components/_badges.scss +24 -0
- data/_sass/components/_button.scss +17 -0
- data/_sass/components/_forms.scss +42 -0
- data/_sass/components/_gifs.scss +5 -0
- data/_sass/components/_index.scss +5 -0
- data/_sass/components/_markdown.scss +453 -0
- data/_sass/includes/_footer.scss +45 -0
- data/_sass/includes/_header.scss +240 -0
- data/_sass/includes/_highlight.scss +87 -0
- data/_sass/includes/_index.scss +9 -0
- data/_sass/includes/_maintenance.scss +16 -0
- data/_sass/includes/_paginator.scss +22 -0
- data/_sass/includes/_rouge-dark.scss +81 -0
- data/_sass/includes/_rouge-light.scss +121 -0
- data/_sass/includes/_terminal.scss +208 -0
- data/_sass/layouts/_blog.scss +96 -0
- data/_sass/layouts/_contact.scss +55 -0
- data/_sass/layouts/_default.scss +14 -0
- data/_sass/layouts/_error.scss +18 -0
- data/_sass/layouts/_home.scss +19 -0
- data/_sass/layouts/_index.scss +10 -0
- data/_sass/layouts/_page.scss +5 -0
- data/_sass/layouts/_post.scss +109 -0
- data/_sass/layouts/_resume.scss +330 -0
- data/_sass/layouts/_tag-posts.scss +48 -0
- data/_sass/layouts/_tag.scss +22 -0
- data/_sass/main.scss +128 -0
- data/_sass/theme/_dark.scss +79 -0
- data/_sass/theme/_index.scss +13 -0
- data/_sass/theme/_light.scss +56 -0
- data/assets/css/style.scss +5 -0
- data/assets/images/avatar_back.png +0 -0
- data/assets/images/avatar_dark.png +0 -0
- data/assets/images/avatar_light.png +0 -0
- data/assets/images/favicon.png +0 -0
- data/assets/js/avatar.js +50 -0
- data/assets/js/blog_search.js +102 -0
- data/assets/js/default.js +148 -0
- data/assets/js/terminal.js +15 -0
- data/assets/js/toc.js +20 -0
- data/assets/json/blog_search.json +16 -0
- data/assets/vendor/bootstrap/css/bootstrap-grid.css +4124 -0
- data/assets/vendor/bootstrap/css/bootstrap-grid.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap-grid.min.css +7 -0
- data/assets/vendor/bootstrap/css/bootstrap-grid.min.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap-grid.rtl.css +4123 -0
- data/assets/vendor/bootstrap/css/bootstrap-grid.rtl.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap-grid.rtl.min.css +7 -0
- data/assets/vendor/bootstrap/css/bootstrap-grid.rtl.min.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap-reboot.css +488 -0
- data/assets/vendor/bootstrap/css/bootstrap-reboot.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap-reboot.min.css +7 -0
- data/assets/vendor/bootstrap/css/bootstrap-reboot.min.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap-reboot.rtl.css +485 -0
- data/assets/vendor/bootstrap/css/bootstrap-reboot.rtl.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap-reboot.rtl.min.css +7 -0
- data/assets/vendor/bootstrap/css/bootstrap-reboot.rtl.min.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap-utilities.css +4266 -0
- data/assets/vendor/bootstrap/css/bootstrap-utilities.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap-utilities.min.css +7 -0
- data/assets/vendor/bootstrap/css/bootstrap-utilities.min.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap-utilities.rtl.css +4257 -0
- data/assets/vendor/bootstrap/css/bootstrap-utilities.rtl.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap-utilities.rtl.min.css +7 -0
- data/assets/vendor/bootstrap/css/bootstrap-utilities.rtl.min.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap.css +10878 -0
- data/assets/vendor/bootstrap/css/bootstrap.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap.min.css +7 -0
- data/assets/vendor/bootstrap/css/bootstrap.min.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap.rtl.css +10842 -0
- data/assets/vendor/bootstrap/css/bootstrap.rtl.css.map +1 -0
- data/assets/vendor/bootstrap/css/bootstrap.rtl.min.css +7 -0
- data/assets/vendor/bootstrap/css/bootstrap.rtl.min.css.map +1 -0
- data/assets/vendor/bootstrap/js/bootstrap.bundle.js +7075 -0
- data/assets/vendor/bootstrap/js/bootstrap.bundle.js.map +1 -0
- data/assets/vendor/bootstrap/js/bootstrap.bundle.min.js +7 -0
- data/assets/vendor/bootstrap/js/bootstrap.bundle.min.js.map +1 -0
- data/assets/vendor/bootstrap/js/bootstrap.esm.js +5202 -0
- data/assets/vendor/bootstrap/js/bootstrap.esm.js.map +1 -0
- data/assets/vendor/bootstrap/js/bootstrap.esm.min.js +7 -0
- data/assets/vendor/bootstrap/js/bootstrap.esm.min.js.map +1 -0
- data/assets/vendor/bootstrap/js/bootstrap.js +5249 -0
- data/assets/vendor/bootstrap/js/bootstrap.js.map +1 -0
- data/assets/vendor/bootstrap/js/bootstrap.min.js +7 -0
- data/assets/vendor/bootstrap/js/bootstrap.min.js.map +1 -0
- data/assets/vendor/simple-jekyll-search.js +433 -0
- data/assets/vendor/simple-jekyll-search.min.js +6 -0
- data/lib/rawfeed/draft.rb +31 -0
- data/lib/rawfeed/installer.rb +37 -0
- data/lib/rawfeed/layout.rb +138 -0
- data/lib/rawfeed/page.rb +33 -0
- data/lib/rawfeed/post.rb +60 -0
- data/lib/rawfeed/resume.rb +59 -0
- data/lib/rawfeed/utils.rb +74 -0
- data/lib/rawfeed/version.rb +1 -1
- data/lib/rawfeed.rb +5 -7
- metadata +145 -2
|
@@ -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
|
+
}());
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Simple-Jekyll-Search
|
|
3
|
+
* Copyright 2015-2020, Christian Fei
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
!function(){"use strict";var f={compile:function(r){return i.template.replace(i.pattern,function(t,e){var n=i.middleware(e,r[e],i.template);return void 0!==n?n:r[e]||t})},setOptions:function(t){i.pattern=t.pattern||i.pattern,i.template=t.template||i.template,"function"==typeof t.middleware&&(i.middleware=t.middleware)}};const i={pattern:/\{(.*?)\}/g,template:"",middleware:function(){}};var n=function(t,e){var n=e.length,r=t.length;if(n<r)return!1;if(r===n)return t===e;t:for(var i=0,o=0;i<r;i++){for(var u=t.charCodeAt(i);o<n;)if(e.charCodeAt(o++)===u)continue t;return!1}return!0},e=new function(){this.matches=function(t,e){return n(e.toLowerCase(),t.toLowerCase())}},r=new function(){this.matches=function(e,t){return!!e&&(e=e.trim().toLowerCase(),(t=t.trim().toLowerCase()).split(" ").filter(function(t){return 0<=e.indexOf(t)}).length===t.split(" ").length)}},d={put:function(t){if(l(t))return a(t);if(function(t){return Boolean(t)&&"[object Array]"===Object.prototype.toString.call(t)}(t))return function(n){const r=[];s();for(let t=0,e=n.length;t<e;t++)l(n[t])&&r.push(a(n[t]));return r}(t);return undefined},clear:s,search:function(t){return t?function(e,n,r,i){const o=[];for(let t=0;t<e.length&&o.length<i.limit;t++){var u=function(t,e,n,r){for(const i in t)if(!function(n,r){for(let t=0,e=r.length;t<e;t++){var i=r[t];if(new RegExp(i).test(n))return!0}return!1}(t[i],r.exclude)&&n.matches(t[i],e))return t}(e[t],n,r,i);u&&o.push(u)}return o}(u,t,c.searchStrategy,c).sort(c.sort):[]},setOptions:function(t){c=t||{},c.fuzzy=t.fuzzy||!1,c.limit=t.limit||10,c.searchStrategy=t.fuzzy?e:r,c.sort=t.sort||o,c.exclude=t.exclude||[]}};function o(){return 0}const u=[];let c={};function s(){return u.length=0,u}function l(t){return Boolean(t)&&"[object Object]"===Object.prototype.toString.call(t)}function a(t){return u.push(t),u}c.fuzzy=!1,c.limit=10,c.searchStrategy=c.fuzzy?e:r,c.sort=o,c.exclude=[];var p={load:function(t,e){const n=window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");n.open("GET",t,!0),n.onreadystatechange=h(n,e),n.send()}};function h(e,n){return function(){if(4===e.readyState&&200===e.status)try{n(null,JSON.parse(e.responseText))}catch(t){n(t,null)}}}var m=function y(t){if(!(e=t)||!("undefined"!=typeof e.required&&e.required instanceof Array))throw new Error("-- OptionsValidator: required options missing");var e;if(!(this instanceof y))return new y(t);const r=t.required;this.getRequiredOptions=function(){return r},this.validate=function(e){const n=[];return r.forEach(function(t){"undefined"==typeof e[t]&&n.push(t)}),n}},w={merge:function(t,e){const n={};for(const r in t)n[r]=t[r],"undefined"!=typeof e[r]&&(n[r]=e[r]);return n},isJSON:function(t){try{return t instanceof Object&&JSON.parse(JSON.stringify(t))?!0:!1}catch(e){return!1}}};!function(t){let i={searchInput:null,resultsContainer:null,json:[],success:Function.prototype,searchResultTemplate:'<li><a href="{url}" title="{desc}">{title}</a></li>',templateMiddleware:Function.prototype,sortMiddleware:function(){return 0},noResultsText:"No results found",limit:10,fuzzy:!1,debounceTime:null,exclude:[]},n;const e=function(t,e){e?(clearTimeout(n),n=setTimeout(t,e)):t.call()};var r=["searchInput","resultsContainer","json"];const o=m({required:r});function u(t){d.put(t),i.searchInput.addEventListener("input",function(t){-1===[13,16,20,37,38,39,40,91].indexOf(t.which)&&(c(),e(function(){l(t.target.value)},i.debounceTime))})}function c(){i.resultsContainer.innerHTML=""}function s(t){i.resultsContainer.innerHTML+=t}function l(t){var e;(e=t)&&0<e.length&&(c(),function(e,n){var r=e.length;if(0===r)return s(i.noResultsText);for(let t=0;t<r;t++)e[t].query=n,s(f.compile(e[t]))}(d.search(t),t))}function a(t){throw new Error("SimpleJekyllSearch --- "+t)}t.SimpleJekyllSearch=function(t){var n;0<o.validate(t).length&&a("You must specify the following required options: "+r),i=w.merge(i,t),f.setOptions({template:i.searchResultTemplate,middleware:i.templateMiddleware}),d.setOptions({fuzzy:i.fuzzy,limit:i.limit,sort:i.sortMiddleware,exclude:i.exclude}),w.isJSON(i.json)?u(i.json):(n=i.json,p.load(n,function(t,e){t&&a("failed to get JSON ("+n+")"),u(e)}));t={search:l};return"function"==typeof i.success&&i.success.call(t),t}}(window)}();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require "colorize"
|
|
4
|
+
require_relative "utils"
|
|
5
|
+
|
|
6
|
+
module Rawfeed
|
|
7
|
+
class Draft
|
|
8
|
+
def self.draft_create
|
|
9
|
+
array = Rawfeed::Utils.enginer(Rawfeed::CONFIG['DRAFTS_DIR'], 'Enter new draft title:', 'draft')
|
|
10
|
+
|
|
11
|
+
puts "Creating new draft: #{array[3]}"
|
|
12
|
+
|
|
13
|
+
File.open(array[3], 'w') do |file|
|
|
14
|
+
file.puts("---")
|
|
15
|
+
file.puts("layout: post")
|
|
16
|
+
file.puts("title: \"#{array[0]}\"")
|
|
17
|
+
file.puts("description: \"Description of your post\"")
|
|
18
|
+
file.puts("author: \"Your Name\"")
|
|
19
|
+
file.puts("date: #{array[2]}")
|
|
20
|
+
file.puts("update_date: ")
|
|
21
|
+
file.puts("comments: false")
|
|
22
|
+
file.puts("tags: [tag1, tag2]")
|
|
23
|
+
file.puts("---")
|
|
24
|
+
file.puts("")
|
|
25
|
+
file.puts "<!-- Write from here your post !!! -->"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
puts "Created successfully!"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# require "fileutils"
|
|
2
|
+
# require "rubygems"
|
|
3
|
+
|
|
4
|
+
# # overwrite: FORCE=true bundle exec rake theme:install_full
|
|
5
|
+
|
|
6
|
+
# module Rawfeed
|
|
7
|
+
# class Installer
|
|
8
|
+
# def self.install_template(name = "full", dest = Dir.pwd, force: false)
|
|
9
|
+
# spec = Gem::Specification.find_by_name("rawfeed")
|
|
10
|
+
# theme_path = spec.gem_dir
|
|
11
|
+
|
|
12
|
+
# src = File.join(theme_path, "lib", "templates", name)
|
|
13
|
+
|
|
14
|
+
# unless Dir.exist?(src)
|
|
15
|
+
# puts "[x] Template '#{name}' not found in #{src}."
|
|
16
|
+
# return
|
|
17
|
+
# end
|
|
18
|
+
|
|
19
|
+
# Dir.glob("#{src}/**/*", File::FNM_DOTMATCH).each do |file|
|
|
20
|
+
# next if File.directory?(file)
|
|
21
|
+
|
|
22
|
+
# rel_path = file.sub(/^#{Regexp.escape(src)}\//, "")
|
|
23
|
+
# target = File.join(dest, rel_path)
|
|
24
|
+
|
|
25
|
+
# if File.exist?(target) && !force
|
|
26
|
+
# puts "[!] #{rel_path} already exists, not overwriting.".yellow
|
|
27
|
+
# else
|
|
28
|
+
# FileUtils.mkdir_p(File.dirname(target))
|
|
29
|
+
# FileUtils.cp(file, target)
|
|
30
|
+
# # puts "Copied #{rel_path}".green
|
|
31
|
+
# end
|
|
32
|
+
# end
|
|
33
|
+
|
|
34
|
+
# # puts "[*] Template '#{name}' installed.".green
|
|
35
|
+
# end
|
|
36
|
+
# end
|
|
37
|
+
# end
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'yaml'
|
|
4
|
+
require "colorize"
|
|
5
|
+
|
|
6
|
+
module Rawfeed
|
|
7
|
+
class Layout
|
|
8
|
+
CONFIG_PATH = Rawfeed::CONFIG['CONFIG_YML']
|
|
9
|
+
BACKUP_PATH = "_config.yml.bak"
|
|
10
|
+
|
|
11
|
+
def self.home_about(verbose)
|
|
12
|
+
file = "index.md"
|
|
13
|
+
content = File.read(file)
|
|
14
|
+
updated = content.gsub(/^layout:\s*\S+$/, "layout: home")
|
|
15
|
+
File.write(file, updated)
|
|
16
|
+
|
|
17
|
+
if verbose
|
|
18
|
+
puts "Home page changed to 'about' successfully!".green
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
def self.home_blog
|
|
22
|
+
file = "index.md"
|
|
23
|
+
content = File.read(file)
|
|
24
|
+
updated = content.gsub(/^layout:\s*\S+$/, "layout: blog")
|
|
25
|
+
File.write(file, updated)
|
|
26
|
+
|
|
27
|
+
puts "Home page changed to 'blog' successfully!".green
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.change_yml(section, key, new_value, path_match = nil)
|
|
31
|
+
raise "File #{CONFIG_PATH} not found" unless File.exist?(CONFIG_PATH)
|
|
32
|
+
|
|
33
|
+
yaml_value = case new_value
|
|
34
|
+
when true then "true"
|
|
35
|
+
when false then "false"
|
|
36
|
+
else
|
|
37
|
+
s = new_value.to_s
|
|
38
|
+
s =~ /\A[-+]?\d+(\.\d+)?\z/ ? s : "\"#{s.gsub('"', '\"')}\""
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
lines = File.readlines(CONFIG_PATH)
|
|
42
|
+
modified = false
|
|
43
|
+
|
|
44
|
+
# === CASE 1: defaults → scope.path ===
|
|
45
|
+
if section == "defaults"
|
|
46
|
+
path_indices = lines.each_index.select { |i| lines[i] =~ /^\s*path:\s*["']?#{Regexp.escape(path_match)}["']?/ }
|
|
47
|
+
path_indices.each do |path_i|
|
|
48
|
+
start_i = (0..path_i).to_a.reverse.find { |j| lines[j] =~ /^\s*-\s*scope:/ }
|
|
49
|
+
next unless start_i
|
|
50
|
+
|
|
51
|
+
values_i = ((start_i + 1)..[lines.length - 1, start_i + 40].min)
|
|
52
|
+
.find { |k| lines[k] =~ /^\s*values:\s*$/ }
|
|
53
|
+
next unless values_i
|
|
54
|
+
|
|
55
|
+
dash_indent = lines[start_i][/^\s*/].size
|
|
56
|
+
published_i = nil
|
|
57
|
+
m = values_i + 1
|
|
58
|
+
while m < lines.length
|
|
59
|
+
line = lines[m]
|
|
60
|
+
break if line =~ /^\s*-\s*scope:/ && line[/^\s*/].size == dash_indent
|
|
61
|
+
break if line =~ /^\S/ && line[/^\s*/].size <= dash_indent
|
|
62
|
+
if line =~ /^\s*#{key}\s*:/
|
|
63
|
+
published_i = m
|
|
64
|
+
break
|
|
65
|
+
end
|
|
66
|
+
m += 1
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
if published_i
|
|
70
|
+
indent = lines[published_i][/^\s*/]
|
|
71
|
+
end_comment = lines[published_i][/#.*/] ? " " + lines[published_i][/#.*/] : ""
|
|
72
|
+
lines[published_i] = "#{indent}#{key}: #{yaml_value}#{end_comment}\n"
|
|
73
|
+
modified = true
|
|
74
|
+
else
|
|
75
|
+
values_indent = lines[values_i][/^\s*/]
|
|
76
|
+
insert_indent = values_indent + " "
|
|
77
|
+
lines.insert(values_i + 1, "#{insert_indent}#{key}: #{yaml_value}\n")
|
|
78
|
+
modified = true
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# === CASE 2: Simple section, e.g. pagination.enabled ===
|
|
83
|
+
else
|
|
84
|
+
section_i = lines.find_index { |l| l =~ /^#{section}:\s*$/ }
|
|
85
|
+
if section_i
|
|
86
|
+
indent_section = lines[section_i][/^\s*/]
|
|
87
|
+
key_indent = indent_section + " "
|
|
88
|
+
key_i = nil
|
|
89
|
+
m = section_i + 1
|
|
90
|
+
while m < lines.length
|
|
91
|
+
line = lines[m]
|
|
92
|
+
break if line =~ /^\S/ # new top-level section
|
|
93
|
+
if line =~ /^\s*#{key}\s*:/
|
|
94
|
+
key_i = m
|
|
95
|
+
break
|
|
96
|
+
end
|
|
97
|
+
m += 1
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
if key_i
|
|
101
|
+
indent = lines[key_i][/^\s*/]
|
|
102
|
+
end_comment = lines[key_i][/#.*/] ? " " + lines[key_i][/#.*/] : ""
|
|
103
|
+
lines[key_i] = "#{indent}#{key}: #{yaml_value}#{end_comment}\n"
|
|
104
|
+
modified = true
|
|
105
|
+
else
|
|
106
|
+
lines.insert(section_i + 1, "#{key_indent}#{key}: #{yaml_value}\n")
|
|
107
|
+
modified = true
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
unless modified
|
|
113
|
+
return { changed: false, message: "Nothing changed (structure not found)" }
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
File.write(BACKUP_PATH, File.read(CONFIG_PATH))
|
|
117
|
+
File.open(CONFIG_PATH, "w") { |f| f.write(lines.join) }
|
|
118
|
+
|
|
119
|
+
{ changed: true, backup: BACKUP_PATH, path: CONFIG_PATH }
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def self.blog_index(value)
|
|
123
|
+
file = "blog/index.md"
|
|
124
|
+
content = File.read(file)
|
|
125
|
+
updated_published = content.gsub(/^published:\s*\S+$/, "published: #{value}")
|
|
126
|
+
updated = updated_published.gsub(/^ enabled:\s*\S+$/, " enabled: #{value}")
|
|
127
|
+
File.write(file, updated)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def self.tags_index(value)
|
|
131
|
+
file = "blog/tags/index.md"
|
|
132
|
+
content = File.read(file)
|
|
133
|
+
updated = content.gsub(/^published:\s*\S+$/, "published: #{value}")
|
|
134
|
+
File.write(file, updated)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
end
|
|
138
|
+
end
|
data/lib/rawfeed/page.rb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require "colorize"
|
|
4
|
+
require_relative "utils"
|
|
5
|
+
|
|
6
|
+
module Rawfeed
|
|
7
|
+
class Page
|
|
8
|
+
def self.page_create
|
|
9
|
+
array = Rawfeed::Utils.enginer(Rawfeed::CONFIG['PAGES_DIR'], 'Enter new page title:', 'page')
|
|
10
|
+
puts ":: Creating new page: #{array[3]}"
|
|
11
|
+
|
|
12
|
+
permalink = array[0].downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
|
13
|
+
|
|
14
|
+
File.open(array[3], 'w') do |file|
|
|
15
|
+
file.puts("---")
|
|
16
|
+
file.puts("layout: page")
|
|
17
|
+
file.puts("order: #number")
|
|
18
|
+
file.puts("title: \"#{array[0]}\"")
|
|
19
|
+
file.puts("author: \"Your Name\"")
|
|
20
|
+
file.puts("date: #{array[2]}")
|
|
21
|
+
file.puts("update_date: ")
|
|
22
|
+
file.puts("published: false")
|
|
23
|
+
file.puts("permalink: /#{permalink}/")
|
|
24
|
+
file.puts("---")
|
|
25
|
+
file.puts("")
|
|
26
|
+
file.puts "<!-- Write from here your page !!! -->"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
puts "[*] Created successfully!".green
|
|
30
|
+
puts "[!] Note: Remember to set \"published\" to \"true\" to publish.".yellow
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|