-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
527 lines (505 loc) · 13.6 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
const os = require('os'); // Import the os module
const debug = false
/// intesity: means how much the macro should be used in the search query, meaning how much it will lag the search
const Keywords = [
// [
// [':'],
// ['Search for All the volumes'],
// ["intensity", 0],
// ],
// Start commands
// [
// ['>'],
// ['Run a command'],
// ["intensity", -1],
// ["start", true],
// ["startSpaceMatters", false],
// ],
[
['!'],
['Search for files From the Recent Files'],
["intensity", -1],
["start", true],
["startSpaceMatters", false],
],
[
['g'],
['Search for web using Google'],
["intensity", -1],
["start", true],
["startSpaceMatters", true],
],
[
['y'],
['Search for web using Yahoo'],
["intensity", -1],
["start", true],
["startSpaceMatters", true],
],
[
['b'],
['Search for web using Bing'],
["intensity", -1],
["start", true],
["startSpaceMatters", true],
],
[
['d'],
['Search for web using DuckDuckGo'],
["intensity", -1],
["start", true],
["startSpaceMatters", true],
],
[
['w'],
['Search for web using Wikipedia'],
["intensity", -1],
["start", true],
["startSpaceMatters", true],
],
[
['r:'],
['Search for the Recent files'],
["intensity", -1],
["start", true],
],
[
['p:'],
['Search for the programs'],
["intensity", -1],
["start", false],
],
[
['pu:'],
['Search for the programs in User'],
["intensity", -1],
["start", false],
],
[
['pp:'],
['Search for the programs in ProgramData'],
["intensity", -1],
["start", false],
],
[
['quot:'],
['Literal double quote "'],
["intensity", -1],
],
[
['apos:'],
['Literal apostrophe \''],
["intensity", -1],
],
[
['amp:'],
['Literal ampersand &'],
["intensity", -1],
],
[
['lt:'],
['Literal less than <'],
["intensity", -1],
],
[
['gt:'],
['Literal greater than >'],
["intensity", -1],
],
[
['#<n>'],
['Literal unicode character <n> in decimal.'],
["intensity", -1],
],
[
['#x<n>'],
['Literal unicode character <n> in hexadecimal.'],
["intensity", -1],
],
[
['<', '>', '>=', '<=', '==', '!='],
['Comparison operators.'],
["intensity", -1],
],
[
['audio:'],
['Search for audio files.'],
["intensity", 0],
],
[
['zip:'],
['Search for compressed files.'],
["intensity", 0],
],
[
['doc:'],
['Search for document files.'],
["intensity", 0],
],
[
['exe:'],
['Search for executable files.'],
["intensity", 0],
],
[
['pic:'],
['Search for picture files.'],
["intensity", 0],
],
[
['video:'],
['Search for video files.'],
["intensity", 0],
],
// Modifiers
[
['ascii:', 'utf8:', 'noascii:'],
['Enable or disable fast ASCII case comparisons.'],
["intensity", 0],
],
[
['case:', 'nocase:'],
['Match or ignore case. Default is to ignore case.'],
["intensity", 0],
],
[
['diacritics:', 'nodiacritics:'],
['Match or ignore accent marks.'],
["intensity", 0],
],
[
['file:', 'files:', 'nofileonly:'],
['Match files only.'],
["intensity", 0],
],
[
['folder:', 'folders:', 'nofolderonly:'],
['Match folders only.'],
["intensity", 0],
],
[
['path:', 'nopath:'],
['Match the full path and file name or just the filename.'],
["intensity", 0],
],
[
['regex:', 'noregex:'],
['Enable or disable regex.'],
["intensity", 0],
],
[
['wfn:', 'wholefilename:', 'nowfn:', 'nowholefilename:'],
['Match the whole filename or match anywhere in the filename.'],
["intensity", 0],
],
[
['wholeword:', 'ww:', 'nowholeword:', 'noww:'],
['Match whole words or match anywhere in the filename.'],
["intensity", 0],
],
[
['wildcards:', 'nowildcards:'],
['Enable or disable wildcards.'],
["intensity", 0],
],
// Functions
[
['dupe:', 'attribdupe:', 'sizedupe:', 'dadupe:', 'dcdupe:', 'dmdupe:'],
['Search for duplicated files.'],
["intensity", 0],
],
[
['namepartdupe:'],
['Search for duplicated files.'],
["intensity", 50],
],
[
['album:'],
['Search for the ID3 or FLAC album.'],
["intensity", 100],
],
[
['artist:'],
['Search for the ID3 or FLAC artist.'],
["intensity", 100],
],
[
['attrib:', 'attributes:'],
['Search for files and folders with the specified file attributes.'],
["intensity", 100],
],
[
['bitdepth:'],
['Find images with the specified bits per pixel.'],
["intensity", 100],
],
[
['child:'],
['Search for folders that contain a child file or folder with a matching filename.'],
["intensity", 0],
],
[
['childcount:'],
['Search for folders that contain the specified number of subfolders and files.'],
["intensity", 0],
],
[
['childfilecount:'],
['Search for folders that contain the specified number of files.'],
["intensity", 0],
],
[
['childfoldercount:'],
['Search for folders that contain the specified number of subfolders.'],
["intensity", 0],
],
[
['comment:'],
['Search for the ID3 or FLAC comment.'],
["intensity", 100],
],
[
['content:', 'ansicontent:', 'utf8content:', 'utf16content:', 'utf16becontent:'],
['Search file content.'],
["intensity", 100],
],
[
['dateaccessed:', 'da:'],
['Search for files and folders with the specified date accessed.'],
["intensity", 100],
],
[
['datecreated:', 'dc:'],
['Search for files and folders with the specified date created.'],
["intensity", 100],
],
[
['datemodified:', 'dm:'],
['Search for files and folders with the specified date modified.'],
["intensity", 0],
],
[
['daterun:', 'dr:'],
['Search for files and folders with the specified date run.'],
["intensity", 0],
],
[
['depth:', 'parents:'],
['Search for files and folders with the specified folder depth.'],
["intensity", 0],
],
[
['dimension:'],
['Find images with the specified width and height.'],
["intensity", 100],
],
[
['empty:'],
['Search for empty folders.'],
["intensity", 0],
],
[
['endwith:'],
['Filenames (including extension) ending with text.'],
["intensity", 0],
],
[
['ext:'],
['Search for files with a matching extension in the specified semicolon delimited extension list.'],
["intensity", 0],
],
[
['filelist:'],
['Search for a list of file names in the specified pipe (|) delimited file list.'],
["intensity", 0],
],
[
['filelistfilename:'],
['Search for files and folders belonging to the file list filename.'],
["intensity", 0],
],
[
['frn:'],
['Search for files and folders with the specified semicolon delimited File Reference Numbers.'],
["intensity", 0],
],
[
['fsi:'],
['Search for files and folders in the specified zero based internal file system index.'],
["intensity", 0],
],
[
['genre:'],
['Search for the ID3 or FLAC genre.'],
["intensity", 100],
],
[
['width:'],
['Search for images with the specified width in pixels.'],
["intensity", 100],
],
[
['height:'],
['Search for images with the specified height in pixels.'],
["intensity", 100],
],
[
['len:'],
['Search for files and folders that match the specified filename length.'],
["intensity", 0],
],
[
['orientation:'],
['Search for images with the specified orientation (landscape or portrait).'],
["intensity", 100],
],
[
['parent:', 'infolder:', 'nosubfolders:'],
['Search for files and folders in the specified path, excluding subfolders.'],
["intensity", 0],
],
[
['recentchange:', 'rc:'],
['Search for files and folders with the specified recently changed date.'],
["intensity", 0],
],
[
['root:'],
['Search for files and folders with no parent folder.'],
["intensity", 0],
],
[
['count:'],
['Search for files and folders with the specified file count.'],
["intensity", 0],
],
[
['runcount:'],
['Search for files and folders with the specified run count.'],
["intensity", 0],
],
[
['shell:'],
['Search for a known shell folder name, including subfolders and files.'],
["intensity", 0],
],
[
['size:'],
['Search for files with the specified size in bytes.'],
["intensity", 0],
],
[
['startwith:'],
['Search for filenames starting with text.'],
["intensity", 0],
],
[
['title:'],
['Search for the ID3 or FLAC title.'],
["intensity", 100],
],
[
['type:'],
['Search for files and folders with the specified file type.'],
["intensity", 0],
]
];
const SizeInfo = [
[
`size[kb|mb|gb]
Size Constants:
empty
tiny 0 KB < size <= 10 KB
small 10 KB < size <= 100 KB
medium 100 KB < size <= 1 MB
large 1 MB < size <= 16 MB
huge 16 MB < size <= 128 MB
gigantic size > 128 MB
Example:
size:medium
size:<1mb
size:small
size:empty`,
]
]
const DateInfo = [
`year
month/year or year/month depending on locale settings
day/month/year, month/day/year or year/month/day depending on locale settings
YYYY[-MM[-DD[Thh[:mm[:ss[.sss]]]]]]
YYYYMM[DD[Thh[mm[ss[.sss]]]]]
Date Constants:
today
yesterday
<last|past|prev|current|this|coming|next><year|month|week>
<last|past|prev|coming|next><x><years|months|weeks>
<last|past|prev|coming|next><x><hours|minutes|mins|seconds|secs>
january|february|march|april|may|june|july|august|september|october|november|december
jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec
sunday|monday|tuesday|wednesday|thursday|friday|saturday
sun|mon|tue|wed|thu|fri|sat
unknown
Example:
datemodified:today`,
]
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/ /g, " ");
}
function highlightResults(input, highlight) {
// find highlight in input and wrap it in <span class="highlight"> tags
// return the modified input
// hightlight example: "num query going here"
// remove the number from the start
highlight = highlight.substring(highlight.indexOf(' ') + 1);
if (!input || !highlight) {
return input;
}
// Escape special characters in the highlight string to safely use it in regex
const escapeRegExp = (string) => {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
};
const escapedHighlight = escapeRegExp(highlight);
const regex = new RegExp(`(${escapedHighlight})`, 'gi');
return input.replace(regex, '<span class="highlight">$1</span>');
}
function contructBlock(path, name, type, displayName, infoName, originalQuery, isPerma, image) {
console.log("path: ", path);
let betterPath = path.replace(/"/g, '"');
console.log("betterPath: ", betterPath);
let escapedType = type.replace(/"/g, '"');
let escapedDisplayName = displayName.replace(/"/g, '"');
let escapedInfoName = infoName.replace(/"/g, '"');
let escapedOriginalQuery = originalQuery.replace(/"/g, '"');
let idName = "block";
if (type === "Web") {
idName = "web";
}
let perma = "";
if (isPerma) {
perma = " perma";
}
return `<div id="${idName}" class="block${perma}" data-type="${escapedType}" data-path="${betterPath}" onclick="openFile('${betterPath}', '${escapedType}')">
<img src="${image}">
<div class="info">
<!-- <h2 class="name"> ${highlightResults(escapedDisplayName, escapedOriginalQuery)} </h2> -->
<!-- <p class="path"> ${highlightResults(escapedInfoName, escapedOriginalQuery)} </p> -->
<h2 class="name"> ${escapeHtml(escapedDisplayName)} </h2>
<p class="path"> ${escapeHtml(escapedInfoName)} </p>
</div>
</div>`;
}
function getUsername() {
return os.userInfo().username;
}
module.exports = {
debug,
Keywords,
SizeInfo,
DateInfo,
contructBlock,
getUsername,
};