jekyll-lunr-js-search 0.3.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8549f4421b1923702c2cd07b0645bcd59b4f52ac
4
- data.tar.gz: 9cfead5005fba347c31b7d86b7bd9853c7b6b075
3
+ metadata.gz: 979da0a34a415c3a4b3d0fc74870b249df516953
4
+ data.tar.gz: 65384945a1a0b23e3e43186699fed85520f8c61d
5
5
  SHA512:
6
- metadata.gz: f79be81e269e77cfd0ef259438193377cd5ec78a77f57c9b6879ded59f8a2c060a6e7adce19318312065f849534b8f1658af6d75d721a3293fef7cd46859dd79
7
- data.tar.gz: d2c249656c5d449efebb3851c8d85332ff9b7b44f4474ab9ce1bfc144f4ffe56bd3596f6932897e84ad1d30d26d07fd7dde40376bbeeac301d14efc9cf61a8a7
6
+ metadata.gz: de51530aafc276892b063f3212874f66fa342932272e4694a83f78da4edb612cc39a5484bbc787d1550bb7f479b919225f774f032c13d87e3b2c36020227e5a3
7
+ data.tar.gz: 2965db530a3534801945f2a0f1ee0a8518df7b3708f7071c8bbbbb4aa82a6c7046eb60988f664dc0b088b1aa4d5d1c30179107663c248950e0e0565b0bba3f04
@@ -46,5 +46,5 @@ function(e,t){"object"==typeof exports?module.exports=t(require("./punycode"),re
46
46
  * MIT Licensed
47
47
  * @license
48
48
  */
49
- var lunr=function(e){var t=new lunr.Index;return t.pipeline.add(lunr.stopWordFilter,lunr.stemmer),e&&e.call(t,t),t};lunr.version="0.4.5","undefined"!=typeof module&&(module.exports=lunr),lunr.utils={},lunr.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),lunr.utils.zeroFillArray=function(){var e=[0];return function(t){for(;t>e.length;)e=e.concat(e);return e.slice(0,t)}}(),lunr.EventEmitter=function(){this.events={}},lunr.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)},lunr.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);this.events[e].splice(n,1),this.events[e].length||delete this.events[e]}},lunr.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)})}},lunr.EventEmitter.prototype.hasHandler=function(e){return e in this.events},lunr.tokenizer=function(e){if(!arguments.length||null==e||void 0==e)return[];if(Array.isArray(e))return e.map(function(e){return e.toLowerCase()});for(var t=(""+e).replace(/^\s+/,""),n=t.length-1;n>=0;n--)if(/\S/.test(t.charAt(n))){t=t.substring(0,n+1);break}return t.split(/\s+/).map(function(e){return e.replace(/^\W+/,"").replace(/\W+$/,"").toLowerCase()})},lunr.Pipeline=function(){this._stack=[]},lunr.Pipeline.registeredFunctions={},lunr.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&lunr.utils.warn("Overwriting existing registered function: "+t),e.label=t,lunr.Pipeline.registeredFunctions[e.label]=e},lunr.Pipeline.warnIfFunctionNotRegistered=function(e){var t=e.label&&e.label in this.registeredFunctions;t||lunr.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},lunr.Pipeline.load=function(e){var t=new lunr.Pipeline;return e.forEach(function(e){var n=lunr.Pipeline.registeredFunctions[e];if(!n)throw Error("Cannot load un-registered function: "+e);t.add(n)}),t},lunr.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){lunr.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},lunr.Pipeline.prototype.after=function(e,t){lunr.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e)+1;this._stack.splice(n,0,t)},lunr.Pipeline.prototype.before=function(e,t){lunr.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e);this._stack.splice(n,0,t)},lunr.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);this._stack.splice(t,1)},lunr.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,r=this._stack.length,i=0;n>i;i++){for(var o=e[i],s=0;r>s&&(o=this._stack[s](o,i,e),void 0!==o);s++);void 0!==o&&t.push(o)}return t},lunr.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return lunr.Pipeline.warnIfFunctionNotRegistered(e),e.label})},lunr.Vector=function(e){this.elements=e},lunr.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;for(var e,t=0,n=this.elements,r=n.length,i=0;r>i;i++)e=n[i],t+=e*e;return this._magnitude=Math.sqrt(t)},lunr.Vector.prototype.dot=function(e){for(var t=this.elements,n=e.elements,r=t.length,i=0,o=0;r>o;o++)i+=t[o]*n[o];return i},lunr.Vector.prototype.similarity=function(e){return this.dot(e)/(this.magnitude()*e.magnitude())},lunr.Vector.prototype.toArray=function(){return this.elements},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(e){~this.indexOf(e)||this.elements.splice(this.locationFor(e),0,e)},this),this.length=this.elements.length},lunr.SortedSet.prototype.toArray=function(){return this.elements.slice()},lunr.SortedSet.prototype.map=function(e,t){return this.elements.map(e,t)},lunr.SortedSet.prototype.forEach=function(e,t){return this.elements.forEach(e,t)},lunr.SortedSet.prototype.indexOf=function(e,t,n){var t=t||0,n=n||this.elements.length,r=n-t,i=t+Math.floor(r/2),o=this.elements[i];return 1>=r?o===e?i:-1:e>o?this.indexOf(e,i,n):o>e?this.indexOf(e,t,i):o===e?i:void 0},lunr.SortedSet.prototype.locationFor=function(e,t,n){var t=t||0,n=n||this.elements.length,r=n-t,i=t+Math.floor(r/2),o=this.elements[i];if(1>=r){if(o>e)return i;if(e>o)return i+1}return e>o?this.locationFor(e,i,n):o>e?this.locationFor(e,t,i):void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,r=0,i=this.length,o=e.length,s=this.elements,a=e.elements;!(n>i-1||r>o-1);)s[n]!==a[r]?s[n]<a[r]?n++:s[n]>a[r]&&r++:(t.add(s[n]),n++,r++);return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){var t,n,r;return this.length>=e.length?(t=this,n=e):(t=e,n=this),r=t.clone(),r.add.apply(r,n.toArray()),r},lunr.SortedSet.prototype.toJSON=function(){return this.toArray()},lunr.Index=function(){this._fields=[],this._ref="id",this.pipeline=new lunr.Pipeline,this.documentStore=new lunr.Store,this.tokenStore=new lunr.TokenStore,this.corpusTokens=new lunr.SortedSet,this.eventEmitter=new lunr.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},lunr.Index.prototype.on=function(){var e=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},lunr.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},lunr.Index.load=function(e){e.version!==lunr.version&&lunr.utils.warn("version mismatch: current "+lunr.version+" importing "+e.version);var t=new this;return t._fields=e.fields,t._ref=e.ref,t.documentStore=lunr.Store.load(e.documentStore),t.tokenStore=lunr.TokenStore.load(e.tokenStore),t.corpusTokens=lunr.SortedSet.load(e.corpusTokens),t.pipeline=lunr.Pipeline.load(e.pipeline),t},lunr.Index.prototype.field=function(e,t){var t=t||{},n={name:e,boost:t.boost||1};return this._fields.push(n),this},lunr.Index.prototype.ref=function(e){return this._ref=e,this},lunr.Index.prototype.add=function(e,t){var n={},r=new lunr.SortedSet,i=e[this._ref],t=void 0===t?!0:t;this._fields.forEach(function(t){var i=this.pipeline.run(lunr.tokenizer(e[t.name]));n[t.name]=i,lunr.SortedSet.prototype.add.apply(r,i)},this),this.documentStore.set(i,r),lunr.SortedSet.prototype.add.apply(this.corpusTokens,r.toArray());for(var o=0;r.length>o;o++){var s=r.elements[o],a=this._fields.reduce(function(e,t){var r=n[t.name].length;if(!r)return e;var i=n[t.name].filter(function(e){return e===s}).length;return e+i/r*t.boost},0);this.tokenStore.add(s,{ref:i,tf:a})}t&&this.eventEmitter.emit("add",e,this)},lunr.Index.prototype.remove=function(e,t){var n=e[this._ref],t=void 0===t?!0:t;if(this.documentStore.has(n)){var r=this.documentStore.get(n);this.documentStore.remove(n),r.forEach(function(e){this.tokenStore.remove(e,n)},this),t&&this.eventEmitter.emit("remove",e,this)}},lunr.Index.prototype.update=function(e,t){var t=void 0===t?!0:t;this.remove(e,!1),this.add(e,!1),t&&this.eventEmitter.emit("update",e,this)},lunr.Index.prototype.idf=function(e){var t="@"+e;if(Object.prototype.hasOwnProperty.call(this._idfCache,t))return this._idfCache[t];var n=this.tokenStore.count(e),r=1;return n>0&&(r=1+Math.log(this.tokenStore.length/n)),this._idfCache[t]=r},lunr.Index.prototype.search=function(e){var t=this.pipeline.run(lunr.tokenizer(e)),n=lunr.utils.zeroFillArray(this.corpusTokens.length),r=[],i=this._fields.reduce(function(e,t){return e+t.boost},0),o=t.some(function(e){return this.tokenStore.has(e)},this);if(!o)return[];t.forEach(function(e,t,o){var s=1/o.length*this._fields.length*i,a=this,u=this.tokenStore.expand(e).reduce(function(t,r){var i=a.corpusTokens.indexOf(r),o=a.idf(r),u=1,l=new lunr.SortedSet;if(r!==e){var c=Math.max(3,r.length-e.length);u=1/Math.log(c)}return i>-1&&(n[i]=s*o*u),Object.keys(a.tokenStore.get(r)).forEach(function(e){l.add(e)}),t.union(l)},new lunr.SortedSet);r.push(u)},this);var s=r.reduce(function(e,t){return e.intersect(t)}),a=new lunr.Vector(n);return s.map(function(e){return{ref:e,score:a.similarity(this.documentVector(e))}},this).sort(function(e,t){return t.score-e.score})},lunr.Index.prototype.documentVector=function(e){for(var t=this.documentStore.get(e),n=t.length,r=lunr.utils.zeroFillArray(this.corpusTokens.length),i=0;n>i;i++){var o=t.elements[i],s=this.tokenStore.get(o)[e].tf,a=this.idf(o);r[this.corpusTokens.indexOf(o)]=s*a}return new lunr.Vector(r)},lunr.Index.prototype.toJSON=function(){return{version:lunr.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),tokenStore:this.tokenStore.toJSON(),corpusTokens:this.corpusTokens.toJSON(),pipeline:this.pipeline.toJSON()}},lunr.Store=function(){this.store={},this.length=0},lunr.Store.load=function(e){var t=new this;return t.length=e.length,t.store=Object.keys(e.store).reduce(function(t,n){return t[n]=lunr.SortedSet.load(e.store[n]),t},{}),t},lunr.Store.prototype.set=function(e,t){this.store[e]=t,this.length=Object.keys(this.store).length},lunr.Store.prototype.get=function(e){return this.store[e]},lunr.Store.prototype.has=function(e){return e in this.store},lunr.Store.prototype.remove=function(e){this.has(e)&&(delete this.store[e],this.length--)},lunr.Store.prototype.toJSON=function(){return{store:this.store,length:this.length}},lunr.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]",r="[aeiouy]",i=n+"[^aeiouy]*",o=r+"[aeiou]*",s="^("+i+")?"+o+i,a="^("+i+")?"+o+i+"("+o+")?$",u="^("+i+")?"+o+i+o+i,l="^("+i+")?"+r;return function(n){var o,c,p,h,f,d,m;if(3>n.length)return n;if(p=n.substr(0,1),"y"==p&&(n=p.toUpperCase()+n.substr(1)),h=/^(.+?)(ss|i)es$/,f=/^(.+?)([^s])s$/,h.test(n)?n=n.replace(h,"$1$2"):f.test(n)&&(n=n.replace(f,"$1$2")),h=/^(.+?)eed$/,f=/^(.+?)(ed|ing)$/,h.test(n)){var g=h.exec(n);h=RegExp(s),h.test(g[1])&&(h=/.$/,n=n.replace(h,""))}else if(f.test(n)){var g=f.exec(n);o=g[1],f=RegExp(l),f.test(o)&&(n=o,f=/(at|bl|iz)$/,d=RegExp("([^aeiouylsz])\\1$"),m=RegExp("^"+i+r+"[^aeiouwxy]$"),f.test(n)?n+="e":d.test(n)?(h=/.$/,n=n.replace(h,"")):m.test(n)&&(n+="e"))}if(h=/^(.+?)y$/,h.test(n)){var g=h.exec(n);o=g[1],h=RegExp(l),h.test(o)&&(n=o+"i")}if(h=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,h.test(n)){var g=h.exec(n);o=g[1],c=g[2],h=RegExp(s),h.test(o)&&(n=o+e[c])}if(h=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,h.test(n)){var g=h.exec(n);o=g[1],c=g[2],h=RegExp(s),h.test(o)&&(n=o+t[c])}if(h=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,f=/^(.+?)(s|t)(ion)$/,h.test(n)){var g=h.exec(n);o=g[1],h=RegExp(u),h.test(o)&&(n=o)}else if(f.test(n)){var g=f.exec(n);o=g[1]+g[2],f=RegExp(u),f.test(o)&&(n=o)}if(h=/^(.+?)e$/,h.test(n)){var g=h.exec(n);o=g[1],h=RegExp(u),f=RegExp(a),d=RegExp("^"+i+r+"[^aeiouwxy]$"),(h.test(o)||f.test(o)&&!d.test(o))&&(n=o)}return h=/ll$/,f=RegExp(u),h.test(n)&&f.test(n)&&(h=/.$/,n=n.replace(h,"")),"y"==p&&(n=p.toLowerCase()+n.substr(1)),n}}(),lunr.Pipeline.registerFunction(lunr.stemmer,"stemmer"),lunr.stopWordFilter=function(e){return-1===lunr.stopWordFilter.stopWords.indexOf(e)?e:void 0},lunr.stopWordFilter.stopWords=new lunr.SortedSet,lunr.stopWordFilter.stopWords.length=119,lunr.stopWordFilter.stopWords.elements=["","a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"],lunr.Pipeline.registerFunction(lunr.stopWordFilter,"stopWordFilter"),lunr.TokenStore=function(){this.root={docs:{}},this.length=0},lunr.TokenStore.load=function(e){var t=new this;return t.root=e.root,t.length=e.length,t},lunr.TokenStore.prototype.add=function(e,t,n){var n=n||this.root,r=e[0],i=e.slice(1);return r in n||(n[r]={docs:{}}),0===i.length?(n[r].docs[t.ref]=t,void(this.length+=1)):this.add(i,t,n[r])},lunr.TokenStore.prototype.has=function(e){if(!e)return!1;for(var t=this.root,n=0;e.length>n;n++){if(!t[e[n]])return!1;t=t[e[n]]}return!0},lunr.TokenStore.prototype.getNode=function(e){if(!e)return{};for(var t=this.root,n=0;e.length>n;n++){if(!t[e[n]])return{};t=t[e[n]]}return t},lunr.TokenStore.prototype.get=function(e,t){return this.getNode(e,t).docs||{}},lunr.TokenStore.prototype.count=function(e,t){return Object.keys(this.get(e,t)).length},lunr.TokenStore.prototype.remove=function(e,t){if(e){for(var n=this.root,r=0;e.length>r;r++){if(!(e[r]in n))return;n=n[e[r]]}delete n.docs[t]}},lunr.TokenStore.prototype.expand=function(e,t){var n=this.getNode(e),r=n.docs||{},t=t||[];return Object.keys(r).length&&t.push(e),Object.keys(n).forEach(function(n){"docs"!==n&&t.concat(this.expand(e+n,t))},this),t},lunr.TokenStore.prototype.toJSON=function(){return{root:this.root,length:this.length}},function(e){var t=function(e){var t,n=Array.prototype.slice;return function(){var r=n.call(arguments),i=this;clearTimeout(t),t=setTimeout(function(){e.apply(i,r)},100)}},n=function(e){var t=e.match(/(\d+)/g);return new Date(t[0],t[1]-1,t[2])},r=function(){function r(t,n){this.$elem=t,this.$results=e(n.results),this.$entries=e(n.entries,this.$results),this.indexDataUrl=n.indexUrl,this.template=this.compileTemplate(e(n.template)),this.initialize()}return r.prototype.initialize=function(){var t=this;this.loadIndexData(function(n){t.entries=e.map(n.docs,t.createEntry),t.index=lunr.Index.load(n.index),t.populateSearchFromQuery(),t.bindKeypress()})},r.prototype.compileTemplate=function(e){var t=e.text();return Mustache.parse(t),function(e,n){return Mustache.render(t,e,n)}},r.prototype.loadIndexData=function(t){e.getJSON(this.indexDataUrl,t)},r.prototype.createEntry=function(t,r){var i=e.extend({id:r+1},t);return t.date&&e.extend(i,{date:n(t.date),pubdate:function(){return dateFormat(n(t.date),"yyyy-mm-dd")},displaydate:function(){return dateFormat(n(t.date),"mmm dd, yyyy")}}),i},r.prototype.bindKeypress=function(){var e=this,n=this.$elem.val();this.$elem.bind("keyup",t(function(){var t=e.$elem.val();t!==n&&e.search(t),n=t}))},r.prototype.search=function(t){var n=this.entries;if(t.length<3)this.$results.hide(),this.$entries.empty();else{var r=e.map(this.index.search(t),function(t){return e.grep(n,function(e){return e.id===parseInt(t.ref,10)})[0]});this.displayResults(r)}},r.prototype.displayResults=function(e){var t=this.$entries,n=this.$results;t.empty(),t.append(0===e.length?"<p>Nothing found.</p>":this.template({entries:e})),n.show()},r.prototype.populateSearchFromQuery=function(){var e=new URI(window.location.search.toString()),t=e.search(!0);t.hasOwnProperty("q")&&(this.$elem.val(t.q),this.search(t.q.toString()))},r}();e.fn.lunrSearch=function(t){return t=e.extend({},e.fn.lunrSearch.defaults,t),new r(this,t),this},e.fn.lunrSearch.defaults={indexUrl:"/js/index.json",results:"#search-results",entries:".entries",template:"#search-results-template"}}(jQuery);
49
+ var lunr=function(e){var t=new lunr.Index;return t.pipeline.add(lunr.stopWordFilter,lunr.stemmer),e&&e.call(t,t),t};lunr.version="0.4.5","undefined"!=typeof module&&(module.exports=lunr),lunr.utils={},lunr.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),lunr.utils.zeroFillArray=function(){var e=[0];return function(t){for(;t>e.length;)e=e.concat(e);return e.slice(0,t)}}(),lunr.EventEmitter=function(){this.events={}},lunr.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)},lunr.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);this.events[e].splice(n,1),this.events[e].length||delete this.events[e]}},lunr.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)})}},lunr.EventEmitter.prototype.hasHandler=function(e){return e in this.events},lunr.tokenizer=function(e){if(!arguments.length||null==e||void 0==e)return[];if(Array.isArray(e))return e.map(function(e){return e.toLowerCase()});for(var t=(""+e).replace(/^\s+/,""),n=t.length-1;n>=0;n--)if(/\S/.test(t.charAt(n))){t=t.substring(0,n+1);break}return t.split(/\s+/).map(function(e){return e.replace(/^\W+/,"").replace(/\W+$/,"").toLowerCase()})},lunr.Pipeline=function(){this._stack=[]},lunr.Pipeline.registeredFunctions={},lunr.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&lunr.utils.warn("Overwriting existing registered function: "+t),e.label=t,lunr.Pipeline.registeredFunctions[e.label]=e},lunr.Pipeline.warnIfFunctionNotRegistered=function(e){var t=e.label&&e.label in this.registeredFunctions;t||lunr.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},lunr.Pipeline.load=function(e){var t=new lunr.Pipeline;return e.forEach(function(e){var n=lunr.Pipeline.registeredFunctions[e];if(!n)throw Error("Cannot load un-registered function: "+e);t.add(n)}),t},lunr.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){lunr.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},lunr.Pipeline.prototype.after=function(e,t){lunr.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e)+1;this._stack.splice(n,0,t)},lunr.Pipeline.prototype.before=function(e,t){lunr.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e);this._stack.splice(n,0,t)},lunr.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);this._stack.splice(t,1)},lunr.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,r=this._stack.length,i=0;n>i;i++){for(var o=e[i],s=0;r>s&&(o=this._stack[s](o,i,e),void 0!==o);s++);void 0!==o&&t.push(o)}return t},lunr.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return lunr.Pipeline.warnIfFunctionNotRegistered(e),e.label})},lunr.Vector=function(e){this.elements=e},lunr.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;for(var e,t=0,n=this.elements,r=n.length,i=0;r>i;i++)e=n[i],t+=e*e;return this._magnitude=Math.sqrt(t)},lunr.Vector.prototype.dot=function(e){for(var t=this.elements,n=e.elements,r=t.length,i=0,o=0;r>o;o++)i+=t[o]*n[o];return i},lunr.Vector.prototype.similarity=function(e){return this.dot(e)/(this.magnitude()*e.magnitude())},lunr.Vector.prototype.toArray=function(){return this.elements},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(e){~this.indexOf(e)||this.elements.splice(this.locationFor(e),0,e)},this),this.length=this.elements.length},lunr.SortedSet.prototype.toArray=function(){return this.elements.slice()},lunr.SortedSet.prototype.map=function(e,t){return this.elements.map(e,t)},lunr.SortedSet.prototype.forEach=function(e,t){return this.elements.forEach(e,t)},lunr.SortedSet.prototype.indexOf=function(e,t,n){var t=t||0,n=n||this.elements.length,r=n-t,i=t+Math.floor(r/2),o=this.elements[i];return 1>=r?o===e?i:-1:e>o?this.indexOf(e,i,n):o>e?this.indexOf(e,t,i):o===e?i:void 0},lunr.SortedSet.prototype.locationFor=function(e,t,n){var t=t||0,n=n||this.elements.length,r=n-t,i=t+Math.floor(r/2),o=this.elements[i];if(1>=r){if(o>e)return i;if(e>o)return i+1}return e>o?this.locationFor(e,i,n):o>e?this.locationFor(e,t,i):void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,r=0,i=this.length,o=e.length,s=this.elements,a=e.elements;!(n>i-1||r>o-1);)s[n]!==a[r]?s[n]<a[r]?n++:s[n]>a[r]&&r++:(t.add(s[n]),n++,r++);return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){var t,n,r;return this.length>=e.length?(t=this,n=e):(t=e,n=this),r=t.clone(),r.add.apply(r,n.toArray()),r},lunr.SortedSet.prototype.toJSON=function(){return this.toArray()},lunr.Index=function(){this._fields=[],this._ref="id",this.pipeline=new lunr.Pipeline,this.documentStore=new lunr.Store,this.tokenStore=new lunr.TokenStore,this.corpusTokens=new lunr.SortedSet,this.eventEmitter=new lunr.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},lunr.Index.prototype.on=function(){var e=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},lunr.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},lunr.Index.load=function(e){e.version!==lunr.version&&lunr.utils.warn("version mismatch: current "+lunr.version+" importing "+e.version);var t=new this;return t._fields=e.fields,t._ref=e.ref,t.documentStore=lunr.Store.load(e.documentStore),t.tokenStore=lunr.TokenStore.load(e.tokenStore),t.corpusTokens=lunr.SortedSet.load(e.corpusTokens),t.pipeline=lunr.Pipeline.load(e.pipeline),t},lunr.Index.prototype.field=function(e,t){var t=t||{},n={name:e,boost:t.boost||1};return this._fields.push(n),this},lunr.Index.prototype.ref=function(e){return this._ref=e,this},lunr.Index.prototype.add=function(e,t){var n={},r=new lunr.SortedSet,i=e[this._ref],t=void 0===t?!0:t;this._fields.forEach(function(t){var i=this.pipeline.run(lunr.tokenizer(e[t.name]));n[t.name]=i,lunr.SortedSet.prototype.add.apply(r,i)},this),this.documentStore.set(i,r),lunr.SortedSet.prototype.add.apply(this.corpusTokens,r.toArray());for(var o=0;r.length>o;o++){var s=r.elements[o],a=this._fields.reduce(function(e,t){var r=n[t.name].length;if(!r)return e;var i=n[t.name].filter(function(e){return e===s}).length;return e+i/r*t.boost},0);this.tokenStore.add(s,{ref:i,tf:a})}t&&this.eventEmitter.emit("add",e,this)},lunr.Index.prototype.remove=function(e,t){var n=e[this._ref],t=void 0===t?!0:t;if(this.documentStore.has(n)){var r=this.documentStore.get(n);this.documentStore.remove(n),r.forEach(function(e){this.tokenStore.remove(e,n)},this),t&&this.eventEmitter.emit("remove",e,this)}},lunr.Index.prototype.update=function(e,t){var t=void 0===t?!0:t;this.remove(e,!1),this.add(e,!1),t&&this.eventEmitter.emit("update",e,this)},lunr.Index.prototype.idf=function(e){var t="@"+e;if(Object.prototype.hasOwnProperty.call(this._idfCache,t))return this._idfCache[t];var n=this.tokenStore.count(e),r=1;return n>0&&(r=1+Math.log(this.tokenStore.length/n)),this._idfCache[t]=r},lunr.Index.prototype.search=function(e){var t=this.pipeline.run(lunr.tokenizer(e)),n=lunr.utils.zeroFillArray(this.corpusTokens.length),r=[],i=this._fields.reduce(function(e,t){return e+t.boost},0),o=t.some(function(e){return this.tokenStore.has(e)},this);if(!o)return[];t.forEach(function(e,t,o){var s=1/o.length*this._fields.length*i,a=this,u=this.tokenStore.expand(e).reduce(function(t,r){var i=a.corpusTokens.indexOf(r),o=a.idf(r),u=1,l=new lunr.SortedSet;if(r!==e){var c=Math.max(3,r.length-e.length);u=1/Math.log(c)}return i>-1&&(n[i]=s*o*u),Object.keys(a.tokenStore.get(r)).forEach(function(e){l.add(e)}),t.union(l)},new lunr.SortedSet);r.push(u)},this);var s=r.reduce(function(e,t){return e.intersect(t)}),a=new lunr.Vector(n);return s.map(function(e){return{ref:e,score:a.similarity(this.documentVector(e))}},this).sort(function(e,t){return t.score-e.score})},lunr.Index.prototype.documentVector=function(e){for(var t=this.documentStore.get(e),n=t.length,r=lunr.utils.zeroFillArray(this.corpusTokens.length),i=0;n>i;i++){var o=t.elements[i],s=this.tokenStore.get(o)[e].tf,a=this.idf(o);r[this.corpusTokens.indexOf(o)]=s*a}return new lunr.Vector(r)},lunr.Index.prototype.toJSON=function(){return{version:lunr.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),tokenStore:this.tokenStore.toJSON(),corpusTokens:this.corpusTokens.toJSON(),pipeline:this.pipeline.toJSON()}},lunr.Store=function(){this.store={},this.length=0},lunr.Store.load=function(e){var t=new this;return t.length=e.length,t.store=Object.keys(e.store).reduce(function(t,n){return t[n]=lunr.SortedSet.load(e.store[n]),t},{}),t},lunr.Store.prototype.set=function(e,t){this.store[e]=t,this.length=Object.keys(this.store).length},lunr.Store.prototype.get=function(e){return this.store[e]},lunr.Store.prototype.has=function(e){return e in this.store},lunr.Store.prototype.remove=function(e){this.has(e)&&(delete this.store[e],this.length--)},lunr.Store.prototype.toJSON=function(){return{store:this.store,length:this.length}},lunr.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]",r="[aeiouy]",i=n+"[^aeiouy]*",o=r+"[aeiou]*",s="^("+i+")?"+o+i,a="^("+i+")?"+o+i+"("+o+")?$",u="^("+i+")?"+o+i+o+i,l="^("+i+")?"+r;return function(n){var o,c,p,h,f,d,m;if(3>n.length)return n;if(p=n.substr(0,1),"y"==p&&(n=p.toUpperCase()+n.substr(1)),h=/^(.+?)(ss|i)es$/,f=/^(.+?)([^s])s$/,h.test(n)?n=n.replace(h,"$1$2"):f.test(n)&&(n=n.replace(f,"$1$2")),h=/^(.+?)eed$/,f=/^(.+?)(ed|ing)$/,h.test(n)){var g=h.exec(n);h=RegExp(s),h.test(g[1])&&(h=/.$/,n=n.replace(h,""))}else if(f.test(n)){var g=f.exec(n);o=g[1],f=RegExp(l),f.test(o)&&(n=o,f=/(at|bl|iz)$/,d=RegExp("([^aeiouylsz])\\1$"),m=RegExp("^"+i+r+"[^aeiouwxy]$"),f.test(n)?n+="e":d.test(n)?(h=/.$/,n=n.replace(h,"")):m.test(n)&&(n+="e"))}if(h=/^(.+?)y$/,h.test(n)){var g=h.exec(n);o=g[1],h=RegExp(l),h.test(o)&&(n=o+"i")}if(h=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,h.test(n)){var g=h.exec(n);o=g[1],c=g[2],h=RegExp(s),h.test(o)&&(n=o+e[c])}if(h=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,h.test(n)){var g=h.exec(n);o=g[1],c=g[2],h=RegExp(s),h.test(o)&&(n=o+t[c])}if(h=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,f=/^(.+?)(s|t)(ion)$/,h.test(n)){var g=h.exec(n);o=g[1],h=RegExp(u),h.test(o)&&(n=o)}else if(f.test(n)){var g=f.exec(n);o=g[1]+g[2],f=RegExp(u),f.test(o)&&(n=o)}if(h=/^(.+?)e$/,h.test(n)){var g=h.exec(n);o=g[1],h=RegExp(u),f=RegExp(a),d=RegExp("^"+i+r+"[^aeiouwxy]$"),(h.test(o)||f.test(o)&&!d.test(o))&&(n=o)}return h=/ll$/,f=RegExp(u),h.test(n)&&f.test(n)&&(h=/.$/,n=n.replace(h,"")),"y"==p&&(n=p.toLowerCase()+n.substr(1)),n}}(),lunr.Pipeline.registerFunction(lunr.stemmer,"stemmer"),lunr.stopWordFilter=function(e){return-1===lunr.stopWordFilter.stopWords.indexOf(e)?e:void 0},lunr.stopWordFilter.stopWords=new lunr.SortedSet,lunr.stopWordFilter.stopWords.length=119,lunr.stopWordFilter.stopWords.elements=["","a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"],lunr.Pipeline.registerFunction(lunr.stopWordFilter,"stopWordFilter"),lunr.TokenStore=function(){this.root={docs:{}},this.length=0},lunr.TokenStore.load=function(e){var t=new this;return t.root=e.root,t.length=e.length,t},lunr.TokenStore.prototype.add=function(e,t,n){var n=n||this.root,r=e[0],i=e.slice(1);return r in n||(n[r]={docs:{}}),0===i.length?(n[r].docs[t.ref]=t,void(this.length+=1)):this.add(i,t,n[r])},lunr.TokenStore.prototype.has=function(e){if(!e)return!1;for(var t=this.root,n=0;e.length>n;n++){if(!t[e[n]])return!1;t=t[e[n]]}return!0},lunr.TokenStore.prototype.getNode=function(e){if(!e)return{};for(var t=this.root,n=0;e.length>n;n++){if(!t[e[n]])return{};t=t[e[n]]}return t},lunr.TokenStore.prototype.get=function(e,t){return this.getNode(e,t).docs||{}},lunr.TokenStore.prototype.count=function(e,t){return Object.keys(this.get(e,t)).length},lunr.TokenStore.prototype.remove=function(e,t){if(e){for(var n=this.root,r=0;e.length>r;r++){if(!(e[r]in n))return;n=n[e[r]]}delete n.docs[t]}},lunr.TokenStore.prototype.expand=function(e,t){var n=this.getNode(e),r=n.docs||{},t=t||[];return Object.keys(r).length&&t.push(e),Object.keys(n).forEach(function(n){"docs"!==n&&t.concat(this.expand(e+n,t))},this),t},lunr.TokenStore.prototype.toJSON=function(){return{root:this.root,length:this.length}},function(e){var t=function(e){var t,n=Array.prototype.slice;return function(){var r=n.call(arguments),i=this;clearTimeout(t),t=setTimeout(function(){e.apply(i,r)},100)}},n=function(e){var t=e.match(/(\d+)/g);return new Date(t[0],t[1]-1,t[2])},r=function(){function r(t,n){this.$elem=t,this.$results=e(n.results),this.$entries=e(n.entries,this.$results),this.indexDataUrl=n.indexUrl,this.template=this.compileTemplate(e(n.template)),this.emptyMsg=n.emptyMsg,this.initialize()}return r.prototype.initialize=function(){var t=this;this.loadIndexData(function(n){t.entries=e.map(n.docs,t.createEntry),t.index=lunr.Index.load(n.index),t.populateSearchFromQuery(),t.bindKeypress()})},r.prototype.compileTemplate=function(e){var t=e.text();return Mustache.parse(t),function(e,n){return Mustache.render(t,e,n)}},r.prototype.loadIndexData=function(t){e.getJSON(this.indexDataUrl,t)},r.prototype.createEntry=function(t,r){var i=e.extend({id:r+1},t);return t.date&&e.extend(i,{date:n(t.date),pubdate:function(){return dateFormat(n(t.date),"yyyy-mm-dd")},displaydate:function(){return dateFormat(n(t.date),"mmm dd, yyyy")}}),i},r.prototype.bindKeypress=function(){var e=this,n=this.$elem.val();this.$elem.bind("keyup",t(function(){var t=e.$elem.val();t!==n&&e.search(t),n=t}))},r.prototype.search=function(t){var n=this.entries;if(t.length<3)this.$results.hide(),this.$entries.empty();else{var r=e.map(this.index.search(t),function(t){return e.grep(n,function(e){return e.id===parseInt(t.ref,10)})[0]});this.displayResults(r)}},r.prototype.displayResults=function(e){var t=this.$entries,n=this.$results;t.empty(),t.append(0===e.length?"<p>"+this.emptyMsg+"</p>":this.template({entries:e})),n.show()},r.prototype.populateSearchFromQuery=function(){var e=new URI(window.location.search.toString()),t=e.search(!0);t.hasOwnProperty("q")&&(this.$elem.val(t.q),this.search(t.q.toString()))},r}();e.fn.lunrSearch=function(t){return t=e.extend({},e.fn.lunrSearch.defaults,t),new r(this,t),this},e.fn.lunrSearch.defaults={indexUrl:"/js/index.json",results:"#search-results",entries:".entries",template:"#search-results-template",emptyMsg:"Nothing found."}}(jQuery);
50
50
  //# sourceMappingURL=search.js.map
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module LunrJsSearch
3
- VERSION = "0.3.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-lunr-js-search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-15 00:00:00.000000000 Z
11
+ date: 2015-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  requirements: []
118
118
  rubyforge_project:
119
- rubygems_version: 2.4.6
119
+ rubygems_version: 2.4.5.1
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Jekyll + lunr.js = static websites with powerful full-text search using JavaScript