ed. 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,129 @@
1
+ .highlight .hll { background-color: #ffc; }
2
+ .highlight .c { color: #999; } /* Comment */
3
+ .highlight .err { color: #a00; background-color: #faa } /* Error */
4
+ .highlight .k { color: #069; } /* Keyword */
5
+ .highlight .o { color: #555 } /* Operator */
6
+ .highlight .cm { color: #09f; font-style: italic } /* Comment.Multiline */
7
+ .highlight .cp { color: #099 } /* Comment.Preproc */
8
+ .highlight .c1 { color: #999; } /* Comment.Single */
9
+ .highlight .cs { color: #999; } /* Comment.Special */
10
+ .highlight .gd { background-color: #fcc; border: 1px solid #c00 } /* Generic.Deleted */
11
+ .highlight .ge { font-style: italic } /* Generic.Emph */
12
+ .highlight .gr { color: #f00 } /* Generic.Error */
13
+ .highlight .gh { color: #030; } /* Generic.Heading */
14
+ .highlight .gi { background-color: #cfc; border: 1px solid #0c0 } /* Generic.Inserted */
15
+ .highlight .go { color: #aaa } /* Generic.Output */
16
+ .highlight .gp { color: #009; } /* Generic.Prompt */
17
+ .highlight .gs { } /* Generic.Strong */
18
+ .highlight .gu { color: #030; } /* Generic.Subheading */
19
+ .highlight .gt { color: #9c6 } /* Generic.Traceback */
20
+ .highlight .kc { color: #069; } /* Keyword.Constant */
21
+ .highlight .kd { color: #069; } /* Keyword.Declaration */
22
+ .highlight .kn { color: #069; } /* Keyword.Namespace */
23
+ .highlight .kp { color: #069 } /* Keyword.Pseudo */
24
+ .highlight .kr { color: #069; } /* Keyword.Reserved */
25
+ .highlight .kt { color: #078; } /* Keyword.Type */
26
+ .highlight .m { color: #f60 } /* Literal.Number */
27
+ .highlight .s { color: #d44950 } /* Literal.String */
28
+ .highlight .na { color: #4f9fcf } /* Name.Attribute */
29
+ .highlight .nb { color: #366 } /* Name.Builtin */
30
+ .highlight .nc { color: #0a8; } /* Name.Class */
31
+ .highlight .no { color: #360 } /* Name.Constant */
32
+ .highlight .nd { color: #99f } /* Name.Decorator */
33
+ .highlight .ni { color: #999; } /* Name.Entity */
34
+ .highlight .ne { color: #c00; } /* Name.Exception */
35
+ .highlight .nf { color: #c0f } /* Name.Function */
36
+ .highlight .nl { color: #99f } /* Name.Label */
37
+ .highlight .nn { color: #0cf; } /* Name.Namespace */
38
+ .highlight .nt { color: #2f6f9f; } /* Name.Tag */
39
+ .highlight .nv { color: #033 } /* Name.Variable */
40
+ .highlight .ow { color: #000; } /* Operator.Word */
41
+ .highlight .w { color: #bbb } /* Text.Whitespace */
42
+ .highlight .mf { color: #f60 } /* Literal.Number.Float */
43
+ .highlight .mh { color: #f60 } /* Literal.Number.Hex */
44
+ .highlight .mi { color: #f60 } /* Literal.Number.Integer */
45
+ .highlight .mo { color: #f60 } /* Literal.Number.Oct */
46
+ .highlight .sb { color: #c30 } /* Literal.String.Backtick */
47
+ .highlight .sc { color: #c30 } /* Literal.String.Char */
48
+ .highlight .sd { color: #c30; font-style: italic } /* Literal.String.Doc */
49
+ .highlight .s2 { color: #c30 } /* Literal.String.Double */
50
+ .highlight .se { color: #c30; } /* Literal.String.Escape */
51
+ .highlight .sh { color: #c30 } /* Literal.String.Heredoc */
52
+ .highlight .si { color: #a00 } /* Literal.String.Interpol */
53
+ .highlight .sx { color: #c30 } /* Literal.String.Other */
54
+ .highlight .sr { color: #3aa } /* Literal.String.Regex */
55
+ .highlight .s1 { color: #c30 } /* Literal.String.Single */
56
+ .highlight .ss { color: #fc3 } /* Literal.String.Symbol */
57
+ .highlight .bp { color: #366 } /* Name.Builtin.Pseudo */
58
+ .highlight .vc { color: #033 } /* Name.Variable.Class */
59
+ .highlight .vg { color: #033 } /* Name.Variable.Global */
60
+ .highlight .vi { color: #033 } /* Name.Variable.Instance */
61
+ .highlight .il { color: #f60 } /* Literal.Number.Integer.Long */
62
+
63
+ .css .o,
64
+ .css .o + .nt,
65
+ .css .nt + .nt { color: #999; }
66
+
67
+ /* Transfered from poole.css */
68
+ /* Code */
69
+ code,
70
+ pre {
71
+ font-family: Menlo, Monaco, "Courier New", monospace;
72
+ }
73
+ code {
74
+ padding: .25em .5em;
75
+ font-size: 85%;
76
+ color: #bf616a;
77
+ background-color: #f9f9f9;
78
+ border-radius: 3px;
79
+ }
80
+ pre {
81
+ display: block;
82
+ margin-top: 0;
83
+ margin-bottom: 1rem;
84
+ padding: 1rem;
85
+ font-size: .8rem;
86
+ line-height: 1.4;
87
+ white-space: pre;
88
+ white-space: pre-wrap;
89
+ word-break: break-all;
90
+ word-wrap: break-word;
91
+ background-color: #f9f9f9;
92
+ }
93
+ pre code {
94
+ padding: 0;
95
+ font-size: 100%;
96
+ color: inherit;
97
+ background-color: transparent;
98
+ }
99
+
100
+ /* Gist via GitHub Pages */
101
+ .gist .gist-file {
102
+ font-family: Menlo, Monaco, "Courier New", monospace !important;
103
+ }
104
+ .gist .markdown-body {
105
+ padding: 15px;
106
+ }
107
+ .gist pre {
108
+ padding: 0;
109
+ background-color: transparent;
110
+ }
111
+ .gist .gist-file .gist-data {
112
+ font-size: .8rem !important;
113
+ line-height: 1.4;
114
+ }
115
+ .gist code {
116
+ padding: 0;
117
+ color: inherit;
118
+ background-color: transparent;
119
+ border-radius: 0;
120
+ }
121
+
122
+ /* Pygments via Jekyll */
123
+ .highlight {
124
+ margin-bottom: 1rem;
125
+ border-radius: 4px;
126
+ }
127
+ .highlight pre {
128
+ margin-bottom: 0;
129
+ }
@@ -0,0 +1,6 @@
1
+ ---
2
+ sitemap: false
3
+ ---
4
+
5
+ @import "ed";
6
+ @import "syntax";
Binary file
@@ -0,0 +1,10 @@
1
+ /**
2
+ * elasticlunr - http://weixsong.github.io
3
+ * Lightweight full-text search engine in Javascript for browser search and offline search. - 0.8.8
4
+ *
5
+ * Copyright (C) 2016 Oliver Nightingale
6
+ * Copyright (C) 2016 Wei Song
7
+ * MIT Licensed
8
+ * @license
9
+ */
10
+ !function(){var e=function(t){var n=new e.Index;return n.pipeline.add(e.trimmer,e.stopWordFilter,e.stemmer),t&&t.call(n,n),n};e.version="0.8.8",e.utils={},e.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),e.utils.toString=function(e){return void 0===e||null===e?"":e.toString()},e.EventEmitter=function(){this.events={}},e.EventEmitter.prototype.addListener=function(){var e=Array.prototype.slice.call(arguments),t=e.pop(),n=e;if("function"!=typeof t)throw new TypeError("last argument must be a function");n.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},e.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);-1!=n&&(this.events[e].splice(n,1),0==this.events[e].length&&delete this.events[e])}},e.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){var t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)})}},e.EventEmitter.prototype.hasHandler=function(e){return e in this.events},e.tokenizer=function(t){if(!arguments.length||null===t||void 0===t)return[];if(Array.isArray(t)){var n=t.filter(function(e){return null===e||void 0===e?!1:!0});n=n.map(function(t){return e.utils.toString(t).toLowerCase()});var i=[];return n.forEach(function(t){var n=t.split(e.tokenizer.seperator);i=i.concat(n)},this),i}return t.toString().trim().toLowerCase().split(e.tokenizer.seperator)},e.tokenizer.defaultSeperator=/[\s\-]+/,e.tokenizer.seperator=e.tokenizer.defaultSeperator,e.tokenizer.setSeperator=function(t){null!==t&&void 0!==t&&"object"==typeof t&&(e.tokenizer.seperator=t)},e.tokenizer.resetSeperator=function(){e.tokenizer.seperator=e.tokenizer.defaultSeperator},e.tokenizer.getSeperator=function(){return e.tokenizer.seperator},e.Pipeline=function(){this._queue=[]},e.Pipeline.registeredFunctions={},e.Pipeline.registerFunction=function(t,n){n in e.Pipeline.registeredFunctions&&e.utils.warn("Overwriting existing registered function: "+n),t.label=n,e.Pipeline.registeredFunctions[n]=t},e.Pipeline.getRegisteredFunction=function(t){return t in e.Pipeline.registeredFunctions!=!0?null:e.Pipeline.registeredFunctions[t]},e.Pipeline.warnIfFunctionNotRegistered=function(t){var n=t.label&&t.label in this.registeredFunctions;n||e.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",t)},e.Pipeline.load=function(t){var n=new e.Pipeline;return t.forEach(function(t){var i=e.Pipeline.getRegisteredFunction(t);if(!i)throw new Error("Cannot load un-registered function: "+t);n.add(i)}),n},e.Pipeline.prototype.add=function(){var t=Array.prototype.slice.call(arguments);t.forEach(function(t){e.Pipeline.warnIfFunctionNotRegistered(t),this._queue.push(t)},this)},e.Pipeline.prototype.after=function(t,n){e.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(t);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i+1,0,n)},e.Pipeline.prototype.before=function(t,n){e.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(t);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i,0,n)},e.Pipeline.prototype.remove=function(e){var t=this._queue.indexOf(e);-1!==t&&this._queue.splice(t,1)},e.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,i=this._queue.length,o=0;n>o;o++){for(var r=e[o],s=0;i>s&&(r=this._queue[s](r,o,e),void 0!==r&&null!==r);s++);void 0!==r&&null!==r&&t.push(r)}return t},e.Pipeline.prototype.reset=function(){this._queue=[]},e.Pipeline.prototype.get=function(){return this._queue},e.Pipeline.prototype.toJSON=function(){return this._queue.map(function(t){return e.Pipeline.warnIfFunctionNotRegistered(t),t.label})},e.Index=function(){this._fields=[],this._ref="id",this.pipeline=new e.Pipeline,this.documentStore=new e.DocumentStore,this.index={},this.eventEmitter=new e.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},e.Index.prototype.on=function(){var e=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},e.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},e.Index.load=function(t){t.version!==e.version&&e.utils.warn("version mismatch: current "+e.version+" importing "+t.version);var n=new this;n._fields=t.fields,n._ref=t.ref,n.documentStore=e.DocumentStore.load(t.documentStore),n.pipeline=e.Pipeline.load(t.pipeline),n.index={};for(var i in t.index)n.index[i]=e.InvertedIndex.load(t.index[i]);return n},e.Index.prototype.addField=function(t){return this._fields.push(t),this.index[t]=new e.InvertedIndex,this},e.Index.prototype.setRef=function(e){return this._ref=e,this},e.Index.prototype.saveDocument=function(t){return this.documentStore=new e.DocumentStore(t),this},e.Index.prototype.addDoc=function(t,n){if(t){var n=void 0===n?!0:n,i=t[this._ref];this.documentStore.addDoc(i,t),this._fields.forEach(function(n){var o=this.pipeline.run(e.tokenizer(t[n]));this.documentStore.addFieldLength(i,n,o.length);var r={};o.forEach(function(e){e in r?r[e]+=1:r[e]=1},this);for(var s in r){var u=r[s];u=Math.sqrt(u),this.index[n].addToken(s,{ref:i,tf:u})}},this),n&&this.eventEmitter.emit("add",t,this)}},e.Index.prototype.removeDocByRef=function(t){if(t){if(0==this.documentStore.isDocStored())return void e.utils.warn("remove doc by ref is not allowed, because currectly not storing documents in DocumentStore");if(this.documentStore.hasDoc(t)){var n=this.documentStore.getDoc(t);this.removeDoc(n)}}},e.Index.prototype.removeDoc=function(t,n){if(t){var n=void 0===n?!0:n,i=t[this._ref];this.documentStore.hasDoc(i)&&(this.documentStore.removeDoc(i),this._fields.forEach(function(n){var o=this.pipeline.run(e.tokenizer(t[n]));o.forEach(function(e){this.index[n].removeToken(e,i)},this)},this),n&&this.eventEmitter.emit("remove",t,this))}},e.Index.prototype.update=function(e,t){var t=void 0===t?!0:t;this.removeDoc(e,!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},e.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;if(Object.prototype.hasOwnProperty.call(this._idfCache,n))return this._idfCache[n];var i=this.index[t].getDocFreq(e),o=1+Math.log(this.documentStore.length/(i+1));return this._idfCache[n]=o,o},e.Index.prototype.getFields=function(){return this._fields.slice()},e.Index.prototype.search=function(t,n){if(!t)return[];var i=null;null!=n&&(i=JSON.stringify(n));var o=new e.Configuration(i,this.getFields()).get(),r=this.pipeline.run(e.tokenizer(t)),s={};for(var u in o){var a=this.fieldSearch(r,u,o),l=o[u].boost;for(var d in a)a[d]=a[d]*l;for(var d in a)d in s?s[d]+=a[d]:s[d]=a[d]}var c=[];for(var d in s)c.push({ref:d,score:s[d]});return c.sort(function(e,t){return t.score-e.score}),c},e.Index.prototype.fieldSearch=function(e,t,n){var i=n[t].bool,o=n[t].expand,r={},s={};return e.forEach(function(e){var n=[e];1==o&&(n=this.index[t].expandToken(e)),n.forEach(function(n){var i=this.index[t].getDocs(n),o=this.idf(n,t);for(var u in i){var a=this.index[t].getTermFrequency(n,u),l=this.documentStore.getFieldLength(u,t),d=1;0!=l&&(d=1/Math.sqrt(l));var c=1;n!=e?c=.15*(1-(n.length-e.length)/n.length):this.fieldSearchStats(s,n,i);var f=a*o*d*c;u in r?r[u]+=f:r[u]=f}},this)},this),"AND"==i&&(r=this.intersect(r,s,e.length)),r=this.coordNorm(r,s,e.length)},e.Index.prototype.fieldSearchStats=function(e,t,n){for(var i in n)i in e?e[i].push(t):e[i]=[t]},e.Index.prototype.intersect=function(e,t,n){var i={};for(var o in e)o in t&&t[o].length==n&&(i[o]=e[o]);return i},e.Index.prototype.coordNorm=function(e,t,n){for(var i in e)if(i in t){var o=t[i].length;e[i]=e[i]*o/n}return e},e.Index.prototype.toJSON=function(){var t={};return this._fields.forEach(function(e){t[e]=this.index[e].toJSON()},this),{version:e.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),index:t,pipeline:this.pipeline.toJSON()}},e.Index.prototype.use=function(e){var t=Array.prototype.slice.call(arguments,1);t.unshift(this),e.apply(this,t)},e.DocumentStore=function(e){this._save=null===e||void 0===e?!0:e,this.docs={},this.docInfo={},this.length=0},e.DocumentStore.load=function(e){var t=new this;return t.length=e.length,t.docs=e.docs,t.docInfo=e.docInfo,t._save=e.save,t},e.DocumentStore.prototype.isDocStored=function(){return this._save},e.DocumentStore.prototype.addDoc=function(e,t){this.hasDoc(e)||this.length++,this.docs[e]=this._save===!0?t:null},e.DocumentStore.prototype.getDoc=function(e){return this.hasDoc(e)===!1?null:this.docs[e]},e.DocumentStore.prototype.hasDoc=function(e){return e in this.docs},e.DocumentStore.prototype.removeDoc=function(e){this.hasDoc(e)&&(delete this.docs[e],delete this.docInfo[e],this.length--)},e.DocumentStore.prototype.addFieldLength=function(e,t,n){null!==e&&void 0!==e&&0!=this.hasDoc(e)&&(this.docInfo[e]||(this.docInfo[e]={}),this.docInfo[e][t]=n)},e.DocumentStore.prototype.updateFieldLength=function(e,t,n){null!==e&&void 0!==e&&0!=this.hasDoc(e)&&this.addFieldLength(e,t,n)},e.DocumentStore.prototype.getFieldLength=function(e,t){return null===e||void 0===e?0:e in this.docs&&t in this.docInfo[e]?this.docInfo[e][t]:0},e.DocumentStore.prototype.toJSON=function(){return{docs:this.docs,docInfo:this.docInfo,length:this.length,save:this._save}},e.stemmer=function(){var e={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},t={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},n="[^aeiou]",i="[aeiouy]",o=n+"[^aeiouy]*",r=i+"[aeiou]*",s="^("+o+")?"+r+o,u="^("+o+")?"+r+o+"("+r+")?$",a="^("+o+")?"+r+o+r+o,l="^("+o+")?"+i,d=new RegExp(s),c=new RegExp(a),f=new RegExp(u),h=new RegExp(l),p=/^(.+?)(ss|i)es$/,v=/^(.+?)([^s])s$/,g=/^(.+?)eed$/,m=/^(.+?)(ed|ing)$/,y=/.$/,x=/(at|bl|iz)$/,w=new RegExp("([^aeiouylsz])\\1$"),I=new RegExp("^"+o+i+"[^aeiouwxy]$"),S=/^(.+?[^aeiou])y$/,b=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,E=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,D=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,F=/^(.+?)(s|t)(ion)$/,_=/^(.+?)e$/,P=/ll$/,k=new RegExp("^"+o+i+"[^aeiouwxy]$"),z=function(n){var i,o,r,s,u,a,l;if(n.length<3)return n;if(r=n.substr(0,1),"y"==r&&(n=r.toUpperCase()+n.substr(1)),s=p,u=v,s.test(n)?n=n.replace(s,"$1$2"):u.test(n)&&(n=n.replace(u,"$1$2")),s=g,u=m,s.test(n)){var z=s.exec(n);s=d,s.test(z[1])&&(s=y,n=n.replace(s,""))}else if(u.test(n)){var z=u.exec(n);i=z[1],u=h,u.test(i)&&(n=i,u=x,a=w,l=I,u.test(n)?n+="e":a.test(n)?(s=y,n=n.replace(s,"")):l.test(n)&&(n+="e"))}if(s=S,s.test(n)){var z=s.exec(n);i=z[1],n=i+"i"}if(s=b,s.test(n)){var z=s.exec(n);i=z[1],o=z[2],s=d,s.test(i)&&(n=i+e[o])}if(s=E,s.test(n)){var z=s.exec(n);i=z[1],o=z[2],s=d,s.test(i)&&(n=i+t[o])}if(s=D,u=F,s.test(n)){var z=s.exec(n);i=z[1],s=c,s.test(i)&&(n=i)}else if(u.test(n)){var z=u.exec(n);i=z[1]+z[2],u=c,u.test(i)&&(n=i)}if(s=_,s.test(n)){var z=s.exec(n);i=z[1],s=c,u=f,a=k,(s.test(i)||u.test(i)&&!a.test(i))&&(n=i)}return s=P,u=c,s.test(n)&&u.test(n)&&(s=y,n=n.replace(s,"")),"y"==r&&(n=r.toLowerCase()+n.substr(1)),n};return z}(),e.Pipeline.registerFunction(e.stemmer,"stemmer"),e.stopWordFilter=function(t){return t&&e.stopWordFilter.stopWords[t]!==!0?t:void 0},e.clearStopWords=function(){e.stopWordFilter.stopWords={}},e.addStopWords=function(t){null!=t&&Array.isArray(t)!==!1&&t.forEach(function(t){e.stopWordFilter.stopWords[t]=!0},this)},e.resetStopWords=function(){e.stopWordFilter.stopWords=e.defaultStopWords},e.defaultStopWords={"":!0,a:!0,able:!0,about:!0,across:!0,after:!0,all:!0,almost:!0,also:!0,am:!0,among:!0,an:!0,and:!0,any:!0,are:!0,as:!0,at:!0,be:!0,because:!0,been:!0,but:!0,by:!0,can:!0,cannot:!0,could:!0,dear:!0,did:!0,"do":!0,does:!0,either:!0,"else":!0,ever:!0,every:!0,"for":!0,from:!0,get:!0,got:!0,had:!0,has:!0,have:!0,he:!0,her:!0,hers:!0,him:!0,his:!0,how:!0,however:!0,i:!0,"if":!0,"in":!0,into:!0,is:!0,it:!0,its:!0,just:!0,least:!0,let:!0,like:!0,likely:!0,may:!0,me:!0,might:!0,most:!0,must:!0,my:!0,neither:!0,no:!0,nor:!0,not:!0,of:!0,off:!0,often:!0,on:!0,only:!0,or:!0,other:!0,our:!0,own:!0,rather:!0,said:!0,say:!0,says:!0,she:!0,should:!0,since:!0,so:!0,some:!0,than:!0,that:!0,the:!0,their:!0,them:!0,then:!0,there:!0,these:!0,they:!0,"this":!0,tis:!0,to:!0,too:!0,twas:!0,us:!0,wants:!0,was:!0,we:!0,were:!0,what:!0,when:!0,where:!0,which:!0,"while":!0,who:!0,whom:!0,why:!0,will:!0,"with":!0,would:!0,yet:!0,you:!0,your:!0},e.stopWordFilter.stopWords=e.defaultStopWords,e.Pipeline.registerFunction(e.stopWordFilter,"stopWordFilter"),e.trimmer=function(e){if(null===e||void 0===e)throw new Error("token should not be undefined");return e.replace(/^\W+/,"").replace(/\W+$/,"")},e.Pipeline.registerFunction(e.trimmer,"trimmer"),e.InvertedIndex=function(){this.root={docs:{},df:0},this.length=0},e.InvertedIndex.load=function(e){var t=new this;return t.root=e.root,t.length=e.length,t},e.InvertedIndex.prototype.addToken=function(e,t,n){for(var n=n||this.root,i=0;i<=e.length-1;){var o=e[i];o in n||(n[o]={docs:{},df:0}),i+=1,n=n[o]}var r=t.ref;n.docs[r]?n.docs[r]={tf:t.tf}:(n.docs[r]={tf:t.tf},n.df+=1,this.length+=1)},e.InvertedIndex.prototype.hasToken=function(e){if(!e)return!1;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return!1;t=t[e[n]]}return!0},e.InvertedIndex.prototype.getNode=function(e){if(!e)return null;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return null;t=t[e[n]]}return t},e.InvertedIndex.prototype.getDocs=function(e){var t=this.getNode(e);return null==t?{}:t.docs},e.InvertedIndex.prototype.getTermFrequency=function(e,t){var n=this.getNode(e);return null==n?0:t in n.docs?n.docs[t].tf:0},e.InvertedIndex.prototype.getDocFreq=function(e){var t=this.getNode(e);return null==t?0:t.df},e.InvertedIndex.prototype.removeToken=function(e,t){if(e){var n=this.getNode(e);null!=n&&t in n.docs&&(delete n.docs[t],n.df-=1)}},e.InvertedIndex.prototype.expandToken=function(e,t,n){if(null==e||""==e)return[];var t=t||[];if(void 0==n&&(n=this.getNode(e),null==n))return t;n.df>0&&t.push(e);for(var i in n)"docs"!==i&&"df"!==i&&this.expandToken(e+i,t,n[i]);return t},e.InvertedIndex.prototype.toJSON=function(){return{root:this.root,length:this.length}},e.Configuration=function(t,n){var t=t||"";if(void 0==n||null==n)throw new Error("fields should not be null");this.config={};var i;try{i=JSON.parse(t),this.buildUserConfig(i,n)}catch(o){e.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(n)}},e.Configuration.prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},e.Configuration.prototype.buildUserConfig=function(t,n){var i="OR",o=!1;if(this.reset(),"bool"in t&&(i=t.bool||i),"expand"in t&&(o=t.expand||o),"fields"in t)for(var r in t.fields)if(n.indexOf(r)>-1){var s=t.fields[r],u=o;void 0!=s.expand&&(u=s.expand),this.config[r]={boost:s.boost||1,bool:s.bool||i,expand:u}}else e.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(i,o,n)},e.Configuration.prototype.addAllFields2UserConfig=function(e,t,n){n.forEach(function(n){this.config[n]={boost:1,bool:e,expand:t}},this)},e.Configuration.prototype.get=function(){return this.config},e.Configuration.prototype.reset=function(){this.config={}},function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.elasticlunr=t()}(this,function(){return e})}();
@@ -0,0 +1,78 @@
1
+ ---
2
+
3
+ ---
4
+ // Based on a script by Kathie Decora : katydecorah.com/code/lunr-and-jekyll/
5
+
6
+ //Create the lunr index for the search
7
+
8
+ var index = elasticlunr(function () {
9
+ this.addField('title')
10
+ this.addField('author')
11
+ this.addField('layout')
12
+ this.addField('content')
13
+ this.setRef('id')
14
+ });
15
+
16
+ //Add to this index the proper metadata from the Jekyll content
17
+
18
+
19
+ {% assign count = 0 %}{% for text in site.texts %}
20
+ index.addDoc({
21
+ title: {{text.title | jsonify}},
22
+ author: {{text.author | jsonify}},
23
+ layout: {{text.layout | jsonify}},
24
+ content: {{text.content | jsonify | strip_html}},
25
+ id: {{count}}
26
+ });{% assign count = count | plus: 1 %}{% endfor %}
27
+ console.log( jQuery.type(index) );
28
+
29
+ // Builds reference data (maybe not necessary for us, to check)
30
+
31
+
32
+ var store = [{% for text in site.texts %}{
33
+ "title": {{text.title | jsonify}},
34
+ "author": {{text.author | jsonify}},
35
+ "layout": {{ text.layout | jsonify }},
36
+ "link": {{text.url | jsonify}},
37
+ }
38
+ {% unless forloop.last %},{% endunless %}{% endfor %}]
39
+
40
+ //Query
41
+
42
+ var qd = {}; //Gets values from the URL
43
+ location.search.substr(1).split("&").forEach(function(item) {
44
+ var s = item.split("="),
45
+ k = s[0],
46
+ v = s[1] && decodeURIComponent(s[1]);
47
+ (k in qd) ? qd[k].push(v) : qd[k] = [v]
48
+ });
49
+
50
+ function doSearch() {
51
+ var resultdiv = $('#results');
52
+ var query = $('input#search').val();
53
+
54
+ //The search is then launched on the index built with Lunr
55
+ var result = index.search(query);
56
+ resultdiv.empty();
57
+ if (result.length == 0) {
58
+ resultdiv.append('<p class="">No results found.</p>');
59
+ } else if (result.length == 1) {
60
+ resultdiv.append('<p class="">Found '+result.length+' result</p>');
61
+ } else {
62
+ resultdiv.append('<p class="">Found '+result.length+' results</p>');
63
+ }
64
+ //Loop through, match, and add results
65
+ for (var item in result) {
66
+ var ref = result[item].ref;
67
+ var searchitem = '<div class="result"><p><a href="{{ site.baseurl }}'+store[ref].link+'?q='+query+'">'+store[ref].title+'</a></p></div>';
68
+ resultdiv.append(searchitem);
69
+ }
70
+ }
71
+
72
+ $(document).ready(function() {
73
+ if (qd.q) {
74
+ $('input#search').val(qd.q[0]);
75
+ doSearch();
76
+ }
77
+ $('input#search').on('keyup', doSearch);
78
+ });
Binary file
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ed.
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alex Gil
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description:
56
+ email:
57
+ - colibri.alex@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - LICENSE.md
63
+ - README.md
64
+ - _includes/head.html
65
+ - _includes/sidebar-toc.html
66
+ - _includes/sidebar.html
67
+ - _layouts/default.html
68
+ - _layouts/drama.html
69
+ - _layouts/narrative.html
70
+ - _layouts/page.html
71
+ - _layouts/poem.html
72
+ - _layouts/post.html
73
+ - _sass/_ed.scss
74
+ - _sass/_syntax.scss
75
+ - assets/apple-touch-icon-precomposed.png
76
+ - assets/css/style.scss
77
+ - assets/favicon.ico
78
+ - assets/js/elasticlunr.min.js
79
+ - assets/js/search.js
80
+ - assets/open-graph-logo.png
81
+ homepage: http://elotroalex.github.io/ed/
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.5.2
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: A Jekyll theme for minimal editions
105
+ test_files: []