diff options
Diffstat (limited to 'static/js')
| -rw-r--r-- | static/js/pagefind-entry.json | 2 | ||||
| -rw-r--r-- | static/js/pagefind.index.cjs (renamed from static/js/pagefind.index.js) | 0 | ||||
| -rw-r--r-- | static/js/pagefind.search.js | 22 | ||||
| -rw-r--r-- | static/js/searchChange.js | 68 | ||||
| -rw-r--r-- | static/js/search_stork.min.js | 1 | ||||
| -rw-r--r-- | static/js/stork.js | 2 | ||||
| -rw-r--r-- | static/js/stork_config.js | 25 |
7 files changed, 18 insertions, 102 deletions
diff --git a/static/js/pagefind-entry.json b/static/js/pagefind-entry.json index 360b8f8..905880c 100644 --- a/static/js/pagefind-entry.json +++ b/static/js/pagefind-entry.json @@ -1 +1 @@ -{"version":"1.1.0","languages":{"fr":{"hash":"fr_b34dd2c23f","wasm":"fr","page_count":11},"en":{"hash":"en_88e373ea1f","wasm":"en","page_count":15},"es":{"hash":"es_7556d6166a","wasm":"es","page_count":2}}}
\ No newline at end of file +{"version":"1.1.0","languages":{"en":{"hash":"en_9a3bf9aefa","wasm":"en","page_count":15},"fr":{"hash":"fr_6374b78f36","wasm":"fr","page_count":10},"es":{"hash":"es_f4a7172a38","wasm":"es","page_count":2}}}
\ No newline at end of file diff --git a/static/js/pagefind.index.js b/static/js/pagefind.index.cjs index 8a685c0..8a685c0 100644 --- a/static/js/pagefind.index.js +++ b/static/js/pagefind.index.cjs diff --git a/static/js/pagefind.search.js b/static/js/pagefind.search.js index 3a61dc3..5936281 100644 --- a/static/js/pagefind.search.js +++ b/static/js/pagefind.search.js @@ -1,9 +1,6 @@ window.onload = function () { if (document.body.contains(document.goSearch)) { - options({ - basePath: "/js/" - }); - init(); + var loaded = false; document.goSearch.onsubmit = function () { return goSearchNow() }; /* @@ -60,17 +57,32 @@ window.onload = function () { document.addEventListener("keydown", inputFocus); document.addEventListener("click", function (event) { suggestions.contains(event.target) || suggestions.classList.add("d-none") }); + document.getElementById('searchinput').onfocus = function() { + if (!loaded) { + lazyLoad(); + loaded = true; + document.body.contains(document.goSearch) && (document.goSearch.onsubmit = function() { return goSearchNow() }) + } + document.getElementById('searchinput').onfocus = ''; + } + var lang = document.documentElement.getAttribute("lang"); var langOnly = lang.substring(0, 2); var baseUrl = document.querySelector("meta[name='base']").getAttribute("content"); if (baseUrl.slice(-1) == "/") { baseUrl = baseUrl.slice(0, -1); } + options({ + basePath: baseUrl + '/js/' + }); var index; searchinput.addEventListener('input', show_results, true); suggestions.addEventListener('click', accept_suggestion, true); + async function lazyLoad() { + await init(); + } // in page results when press enter or click search icon from search box function closeSearchNow() { @@ -244,4 +256,4 @@ window.onload = function () { document.goSearch.onsubmit = function () { return goSearchNow() }; }()); } -};
\ No newline at end of file +}; diff --git a/static/js/searchChange.js b/static/js/searchChange.js deleted file mode 100644 index 8f776ae..0000000 --- a/static/js/searchChange.js +++ /dev/null @@ -1,68 +0,0 @@ -const fs = require('fs'); -const path = require("path"); -// Path for config.toml -const configTomlPath = path.join(__dirname, "../../config.toml"); - -async function main() { - const { replaceInFileSync } = await import('replace-in-file'); - // Process arguments to determine the search mode - const args = process.argv.slice(2); // Remove the first two default arguments - - if (args.length > 0) { - // Check the search mode based on the argument provided - switch (args[0]) { - case '--pagefind': - console.log('Pagefind search mode activated.'); - await swapToPagefind(replaceInFileSync); - break; - case '--elasticlunr': - console.log('Elasticlunr search mode activated.'); - await swapToElasticlunr(replaceInFileSync); - break; - default: - console.log('Unknown search mode. Please use --pagefind or --elasticlunr.'); - } - } else { - console.log('No search mode specified. Please use --pagefind or --elasticlunr.'); - } -} - -main(); - -async function swapToPagefind(replaceInFileSync) { - // Edit the config.toml file - replaceInFileSync({ - files: configTomlPath, - from: /search_library = ['|"]\w+['|"]/g, - to: 'search_library = "pagefind"', - }); - replaceInFileSync({ - files: configTomlPath, - from: /online_indexformat = ['|"]\w+['|"]/g, - to: 'online_indexformat = "fuse_json"', - }); - replaceInFileSync({ - files: configTomlPath, - from: /index_format = ['|"]\w+['|"]/g, - to: 'index_format = "fuse_json"', - }); -} - -async function swapToElasticlunr(replaceInFileSync) { - // Edit the config.toml file - replaceInFileSync({ - files: configTomlPath, - from: /search_library = ['|"]\w+['|"]/g, - to: 'search_library = "elasticlunr"', - }); - replaceInFileSync({ - files: configTomlPath, - from: /online_indexformat = ['|"]\w+['|"]/g, - to: 'online_indexformat = "elasticlunr_json"', - }); - replaceInFileSync({ - files: configTomlPath, - from: /index_format = ['|"]\w+['|"]/g, - to: 'index_format = "elasticlunr_json"', - }); -}
\ No newline at end of file diff --git a/static/js/search_stork.min.js b/static/js/search_stork.min.js deleted file mode 100644 index 7e7c7df..0000000 --- a/static/js/search_stork.min.js +++ /dev/null @@ -1 +0,0 @@ -function loadStork(){var e=document.querySelector("meta[name='base']").getAttribute("content");"/"==e.slice(-1)&&(e=e.slice(0,-1)),stork.initialize(e+"/stork.wasm").then(()=>{}).catch(e=>{}),stork.register("stork",e+"/stork.st")}(()=>{function r(e){var t=o[e];return void 0!==t||(t=o[e]={exports:{}},n[e].call(t.exports,t,t.exports,r)),t.exports}var n={214:(e,t,r)=>{function o(e){return s[e]}function d(){return n=null!==n&&n.buffer===p.memory.buffer?n:new Uint8Array(p.memory.buffer)}function h(n,r,t){if(void 0===t){let e=l.encode(n),t=r(e.length);return d().subarray(t,t+e.length).set(e),m=e.length,t}let o=n.length,s=r(o);var i=d();let a=0;for(;a<o;a++){let e=n.charCodeAt(a);if(127<e)break;i[s+a]=e}if(a!==o){0!==a&&(n=n.slice(a)),s=t(s,o,o=a+3*n.length);let e=d().subarray(s+a,s+o);a+=u(n,e).written}return m=a,s}function f(){return a=null!==a&&a.buffer===p.memory.buffer?a:new Int32Array(p.memory.buffer)}function g(e,t){return c.decode(d().subarray(e,e+t))}let p,s=(r.r(t),r.d(t,{default:()=>v,wasm_register_index:()=>function(e,t){try{var n=p.__wbindgen_add_to_stack_pointer(-16),r=h(e,p.__wbindgen_malloc,p.__wbindgen_realloc),o=m,s=(u=t,c=(0,p.__wbindgen_malloc)(+u.length),d().set(u,+c),m=u.length,c),i=m,a=(p.wasm_register_index(n,r,o,s,i),f()[n/4+0]),l=f()[n/4+1];return g(a,l)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(a,l)}var u,c},wasm_search:()=>function(e,t){try{var n=p.__wbindgen_add_to_stack_pointer(-16),r=h(e,p.__wbindgen_malloc,p.__wbindgen_realloc),o=m,s=h(t,p.__wbindgen_malloc,p.__wbindgen_realloc),i=m,a=(p.wasm_search(n,r,o,s,i),f()[n/4+0]),l=f()[n/4+1];return g(a,l)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(a,l)}},wasm_stork_version:()=>function(){try{var e=p.__wbindgen_add_to_stack_pointer(-16),t=(p.wasm_stork_version(e),f()[e/4+0]),n=f()[e/4+1];return g(t,n)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(t,n)}}}),Array(32).fill(void 0)),i=(s.push(void 0,null,!0,!1),s.length),m=0,n=null,l=new TextEncoder("utf-8"),u="function"==typeof l.encodeInto?function(e,t){return l.encodeInto(e,t)}:function(e,t){var n=l.encode(e);return t.set(n),{read:e.length,written:n.length}},a=null,c=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),v=(c.decode(),async function e(t){void 0===t&&(t=new URL("stork_bg.wasm",function(){var e=r.p;let t="";return e&&~e.indexOf("://")||(t+=window.location.protocol+"//"+window.location.host),(t+=e||"/")+"node_modules/stork-search/stork.js"}()));var n={wbg:{}},{instance:t,module:n}=(n.wbg.__wbg_new_693216e109162396=function(){return e=Error(),i===s.length&&s.push(s.length+1),t=i,i=s[t],s[t]=e,t;var e,t},n.wbg.__wbg_stack_0ddaca5d1abfb52f=function(e,t){var t=h(o(t).stack,p.__wbindgen_malloc,p.__wbindgen_realloc),n=m;f()[e/4+1]=n,f()[e/4+0]=t},n.wbg.__wbg_error_09919627ac0992f5=function(e,t){p.__wbindgen_free(e,t)},n.wbg.__wbindgen_object_drop_ref=function(e){o(e),(e=e)<36||(s[e]=i,i=e)},await async function(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if("application/wasm"==e.headers.get("Content-Type"))throw t}var n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}(await(t="string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL?fetch(t):t),n));return p=t.exports,e.__wbindgen_wasm_module=n,p})},914:(e,l,t)=>{Object.defineProperty(l,"__esModule",{value:!0}),l.calculateOverriddenConfig=l.defaultConfig=void 0;var u=t(445),c=t(466);l.defaultConfig={showProgress:!0,printIndexInfo:!1,showScores:!1,showCloseButton:!0,minimumQueryLength:3,forceOverwrite:!1,resultNoun:{singular:"file",plural:"files"},onQueryUpdate:void 0,onResultSelected:void 0,onResultsHidden:void 0,onInputCleared:void 0,transformResultUrl:function(e){return e}},l.calculateOverriddenConfig=function(e){var t,n=(0,c.difference)(Object.keys(e),Object.keys(l.defaultConfig));if(0<n.length)return t=(0,c.plural)(n.length,"key","keys"),n=JSON.stringify(n),new u.default("Invalid ".concat(t," in config object: ").concat(n));for(var r=Object.assign({},l.defaultConfig),o=0,s=Object.keys(l.defaultConfig);o<s.length;o++){var i=s[o],a=e[i];void 0!==a&&(r[i]=a)}return r}},227:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.existsBeyondContainerBounds=t.setText=t.clear=t.add=t.create=void 0,t.create=function(e,t){e=document.createElement(e);return t.classNames&&e.setAttribute("class",t.classNames.join(" ")),e},t.add=function(e,t,n){n.insertAdjacentElement(t,e)},t.clear=function(e){for(;e&&e.firstChild;)e.removeChild(e.firstChild)},t.setText=function(e,t){t=document.createTextNode(t);e&&e.firstChild?e.replaceChild(t,e.firstChild):e&&e.appendChild(t)},t.existsBeyondContainerBounds=function(e,t){e=e.getBoundingClientRect(),t=t.getBoundingClientRect();return e.bottom>t.bottom||e.top<t.top}},934:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Entity=void 0;var r=n(139),o=n(771),s=n(214),i=n(445);function a(e,t,n){var r=this;this._state="initialized",this.downloadProgress=0,this.results=[],this.totalResultCount=0,this.eventListenerFunctions={},this.highlightedResult=0,this.resultsVisible=!1,this.hoverSelectEnabled=!0,this.setDownloadProgress=function(e){r.state="loading",r.downloadProgress=e,r.config.showProgress&&r.render()},this.name=e,this.url=t,this.config=n}Object.defineProperty(a.prototype,"state",{get:function(){return this._state},set:function(e){this._state=e,this.render()},enumerable:!1,configurable:!0}),a.prototype.getCurrentMessage=function(){var e;return this.domManager?(e=this.domManager.getQuery(),"error"===this.state?"Error! Check the browser console.":"ready"!=this.state?"Loading...":(null==e?void 0:e.length)<this.config.minimumQueryLength?"Filtering...":this.results?0===this.totalResultCount?"No ".concat(this.config.resultNoun.plural," found."):1===this.totalResultCount?"1 ".concat(this.config.resultNoun.singular," found."):"".concat(this.totalResultCount," ").concat(this.config.resultNoun.plural," found."):null):null},a.prototype.generateRenderConfig=function(){return{results:this.results,resultsVisible:!0,showScores:this.config.showScores,message:this.getCurrentMessage(),showProgress:this.config.showProgress,progress:this.downloadProgress,state:this.state}},a.prototype.render=function(){this.domManager&&this.domManager.render(this.generateRenderConfig())},a.prototype.registerIndex=function(r){var o=this;return new Promise(function(e,t){var n=JSON.parse((0,s.wasm_register_index)(o.name,r));n.error?t(new i.default(n.error)):(o.config.printIndexInfo,o.state="ready",e(n))})},a.prototype.attachToDom=function(){this.domManager=new o.EntityDom(this.name,this),this.render()},a.prototype.injestSearchData=function(e){var r=this,o=(this.results=e.results,this.totalResultCount=e.total_hit_count,this.highlightedResult=0,e.url_prefix||"");this.results.map(function(e){var t="",n=e.excerpts.map(function(e){return e.internal_annotations}).filter(function(e){return!!e})[0];n&&n[0]&&"string"==typeof(n=n[0]).a&&(t+=n.a),e.excerpts&&e.excerpts[0]&&e.excerpts[0].internal_annotations&&e.excerpts[0].internal_annotations[0]&&e.excerpts[0].internal_annotations[0].a&&"string"==typeof e.excerpts[0].internal_annotations[0].a&&(t=e.excerpts[0].internal_annotations[0].a),e.entry.url=r.config.transformResultUrl("".concat(o).concat(e.entry.url).concat(t))}),this.render()},a.prototype.getSanitizedResults=function(){var e=this.results;return e.map(function(e){delete e.title_highlight_ranges,e.excerpts.map(function(e){delete e.highlight_ranges,delete e.internal_annotations})}),e},a.prototype.setDownloadError=function(){this.state="error"},a.prototype.performSearch=function(e){if("ready"===this.state)if(e.length<this.config.minimumQueryLength)this.results=[],this.render();else try{var t=(0,r.resolveSearch)(this.name,e);t&&(this.injestSearchData(t),this.config.onQueryUpdate)&&this.config.onQueryUpdate(e,this.getSanitizedResults())}catch(e){}else this.render()},t.Entity=a},771:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EntityDom=void 0;var a=n(227),i=n(9),o={results:[],resultsVisible:!1,showScores:!1,message:null,showProgress:!1,progress:1,state:"ready"};function r(n,e){var r=this,e=(this.scrollAnchorPoint="end",this.entity=e,[{selector:'input[data-stork="'.concat(n,'"]'),elementName:"input"},{selector:'div[data-stork="'.concat(n,'-output"]'),elementName:"output"}].map(function(e){var t=document.querySelector(e.selector);if(t)return t;throw Error('Could not register search box "'.concat(n,'": ').concat(e.elementName," element not found. Make sure an element matches the query selector `").concat(e.selector,"`"))})),t=e[0];this.elements={input:t,output:e[1],list:(0,a.create)("ul",{classNames:["stork-results"]}),attribution:(0,a.create)("div",{classNames:["stork-attribution"]}),progress:(0,a.create)("div",{classNames:["stork-progress"]}),message:(0,a.create)("div",{classNames:["stork-message"]}),closeButton:(0,a.create)("button",{classNames:["stork-close-button"]})},this.elements.input.removeEventListener("input",this.entity.eventListenerFunctions.inputInputEvent),this.elements.input.removeEventListener("keydown",this.entity.eventListenerFunctions.inputKeydownEvent),this.entity.eventListenerFunctions={inputInputEvent:function(e){r.handleInputEvent(e)},inputKeydownEvent:function(e){r.handleKeyDownEvent(e)}},this.elements.input.addEventListener("input",this.entity.eventListenerFunctions.inputInputEvent),this.elements.input.addEventListener("keydown",this.entity.eventListenerFunctions.inputKeydownEvent),null!=(t=this.elements.list)&&t.addEventListener("mousemove",function(){r.hoverSelectEnabled=!0}),this.elements.attribution.innerHTML='Powered by <a href="https://stork-search.net">Stork</a>',this.elements.closeButton.innerHTML='\n<svg height="0.8em" viewBox="0 0 23 24" xmlns="http://www.w3.org/2000/svg">\n<g fill="none" fill-rule="evenodd" stroke-linecap="round">\n<g transform="translate(-700 -149)" stroke="currentcolor" stroke-width="4">\n<line id="a" x1="702.5" x2="720" y1="152.5" y2="170"/>\n<line transform="translate(711 161) rotate(-90) translate(-711 -161)" x1="702.5" x2="720" y1="152.5" y2="170"/>\n</g>\n</g>\n</svg>',this.entity.config.showProgress&&(0,a.add)(this.elements.progress,"afterend",this.elements.input),null!=(e=this.elements.closeButton)&&e.addEventListener("click",function(){r.elements.input.value="",r.elements.input.focus(),r.render(o);var e=[r.entity.config.onInputCleared,r.entity.config.onResultsHidden],t=e[0],e=e[1];t&&t(),e&&e()})}r.prototype.clearDom=function(){var e;(0,a.clear)(this.elements.output),(0,a.clear)(this.elements.list),null!=(e=this.elements.closeButton)&&e.remove(),this.elements.output.classList.remove("stork-output-visible")},r.prototype.render=function(r){var e,o=this,t=this.elements.input.value;if(this.clearDom(),(this.lastRenderState=r).showProgress&&((e=function(){switch(r.state){case"ready":case"error":return 1;case"initialized":case"loading":return.9*r.progress+.05}}())<1?(this.elements.progress.style.width="".concat(100*e,"%"),this.elements.progress.style.opacity="1"):(this.elements.progress.style.width="100%",this.elements.progress.style.opacity="0")),"error"===r.state&&this.elements.input.classList.add("stork-error"),0<this.getQuery().length&&r.resultsVisible&&(this.elements.output.classList.add("stork-output-visible"),(0,a.add)(this.elements.message,"beforeend",this.elements.output)),r.message&&(0,a.setText)(this.elements.message,r.message),0<(null==(e=r.results)?void 0:e.length)&&r.resultsVisible){(0,a.add)(this.elements.list,"beforeend",this.elements.output);for(var s=this,n=0;n<r.results.length;n++)!function(e){var t=r.results[e],n={selected:e===s.highlightedResult,showScores:r.showScores},t=(0,i.resultToListItem)(t,n);(0,a.add)(t,"beforeend",s.elements.list),t.addEventListener("mousemove",function(){o.hoverSelectEnabled&&e!==o.highlightedResult&&o.changeHighlightedResult({to:e,shouldScrollTo:!1})}),t.addEventListener("mouseleave",function(){o.hoverSelectEnabled&&e===o.highlightedResult&&o.changeHighlightedResult({to:-1,shouldScrollTo:!1})}),t.addEventListener("click",function(e){e.preventDefault(),o.selectResult()})}(n);(0,a.add)(this.elements.attribution,"beforeend",this.elements.output)}0<((null==t?void 0:t.length)||0)&&this.entity.config.showCloseButton&&(0,a.add)(this.elements.closeButton,"afterend",this.elements.input)},r.prototype.selectResult=function(){var e;null!=this.highlightedResult&&(e=this.entity.results[this.highlightedResult],this.entity.config.onResultSelected?Promise.resolve(this.entity.config.onResultSelected(this.getQuery(),e)).finally(function(){window.location.assign(e.entry.url)}):window.location.assign(e.entry.url))},r.prototype.changeHighlightedResult=function(e){var t=this.highlightedResult,n=Math.max(-1,Math.min(this.entity.results.length-1,e.to));this.highlightedResult=n,this.scrollAnchorPoint=(t||0)<n?"end":"start";for(var r=null,o=0;o<this.entity.results.length;o++){var s,i=null==(i=this.elements.list)?void 0:i.children[o];i&&(s="selected",o==n?(i.classList.add(s),r=i):i.classList.remove(s))}return e.shouldScrollTo&&(this.hoverSelectEnabled=!1,r)&&(0,a.existsBeyondContainerBounds)(r,this.elements.list)&&r.scrollIntoView({behavior:"smooth",block:this.scrollAnchorPoint,inline:"nearest"}),n},r.prototype.handleKeyDownEvent=function(e){switch(e.keyCode){case 40:var t;null==this.highlightedResult?this.changeHighlightedResult({to:0,shouldScrollTo:!0}):(t=Math.min(this.highlightedResult+1,this.entity.results.length-1),this.changeHighlightedResult({to:t,shouldScrollTo:!0}));break;case 38:null!=this.highlightedResult&&(t=Math.max(0,this.highlightedResult-1),this.changeHighlightedResult({to:t,shouldScrollTo:!0}));break;case 13:this.selectResult();break;case 27:var n;this.lastRenderState.resultsVisible?(this.render(o),(n=this.entity.config.onResultsHidden)&&n()):0<this.elements.input.value.length&&(this.elements.input.value="",this.render(o),n=this.entity.config.onInputCleared)&&n();break;default:return}},r.prototype.handleInputEvent=function(e){this.entity.performSearch(e.target.value)},r.prototype.getQuery=function(){return this.elements.input.value},t.EntityDom=r},129:function(e,t,n){var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])!{}.hasOwnProperty.call(t,o)||(e[o]=t[o]);return e}).apply(this,arguments)},a=(Object.defineProperty(t,"__esModule",{value:!0}),t.debug=t.entityIsReady=t.attachToDom=t.register=void 0,n(934)),l=n(914),u=n(794),c=n(258),d=n(445),h={};t.register=function(o,s,i){return new Promise(function(t,n){var r,e=(0,l.calculateOverriddenConfig)(i);e instanceof d.default?n(e):(h[o]&&!e.forceOverwrite&&n(new d.default("You're registering an index named `".concat(o,"`, but that already exists. If this is expected, set forceOverwrite to true in your Javascript config to allow overwriting indexes."))),r=new a.Entity(o,s,e),h[o]=r,(0,u.loadIndexFromUrl)(s,{progress:function(e){r.setDownloadProgress(e)},load:function(e){(0,c.runAfterWasmLoaded)(function(){r.registerIndex(new Uint8Array(e)).then(t).catch(n)},function(){r.state="error"})},error:function(){r.setDownloadError(),n()}}))})},t.attachToDom=function(e){if(!h[e])throw Error("Index ".concat(e," has not been registered!"));h[e].attachToDom()},t.entityIsReady=function(e){return"ready"===(null==(e=h[e])?void 0:e.state)},t.debug=function(){return{entities:r({},h),entitiesCount:h.length}}},794:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.loadIndexFromUrl=void 0,t.loadIndexFromUrl=function(e,r){var t=new XMLHttpRequest;t.addEventListener("load",function(e){var t=e.target,n=t.status,t=t.response;0!==n?n<200||299<n?r.error():r.load(t):r.progress(e.loaded/e.total)}),t.addEventListener("error",function(){r.error()}),t.addEventListener("progress",function(e){r.progress(e.loaded/e.total)}),t.responseType="arraybuffer",t.open("GET",e),t.send()}},480:function(e,t,n){function o(e){return(0,l.loadWasm)(e=void 0===e?null:e).then(function(){})}function s(r,o,s){return void 0===s&&(s={}),new Promise(function(e,t){var n=(0,d.validateIndexParams)(r,o);n?t(n):(0,a.register)(r,o,s).then(e).catch(t)})}function i(e){try{(0,a.attachToDom)(e)}catch(e){throw new c.default(e.message)}}var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])!{}.hasOwnProperty.call(t,o)||(e[o]=t[o]);return e}).apply(this,arguments)},a=(Object.defineProperty(t,"__esModule",{value:!0}),t.debug=t.register=t.search=t.attach=t.downloadIndex=t.initialize=void 0,n(129)),l=n(258),u=n(139),c=n(445),d=n(34),h=n(214);t.initialize=o,t.downloadIndex=s,t.attach=i,t.register=function(e,t,n){void 0===n&&(n={});var r=o(),t=s(e,t,n);return i(e),Promise.all([r,t]).then()},t.search=function(e,t){if(!e||!t)throw new c.default("Make sure to call stork.search() with two arguments: the index name and the search query.");if((0,a.entityIsReady)(e))return(0,u.resolveSearch)(e,t);throw new c.default("Couldn't find index. Make sure the stork.downloadIndex() promise has resolved before calling stork.search().")},t.debug=function(){return r(r(r({},(0,l.debug)()),(0,a.debug)()),{jsStorkVersion:"1.5.0",wasmStorkVersion:h.wasm_stork_version})}},112:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.highlight=void 0,t.highlight=function(e,t){function n(e,t,n){return e.substr(0,t)+n+e.substr(t)}for(var r=0,o=0,s=t;o<s.length;o++){var i=s[o],a='<mark class="stork-highlight">',l="</mark>";e=n(e,i.beginning+r,a),e=n(e,i.end+(r+=30),l),r+=7}return e}},9:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.resultToListItem=void 0;var r=n(112);t.resultToListItem=function(e,t){var n=document.createElement("template");return n.innerHTML='\n<li class="stork-result'.concat(t.selected?" selected":"",'">\n <a href="').concat(e.entry.url,'">\n <div class="stork-title">\n <p>').concat((0,r.highlight)(e.entry.title,e.title_highlight_ranges||[]),"</p>\n ").concat(t.showScores?"<code><b>".concat(e.score,"</b></code>"):"","\n </div>\n ").concat(0<e.excerpts.length?'<div class="stork-excerpt-container" />':"","\n ").concat(e.excerpts.map(function(e){return'<div class="stork-excerpt"><p>\n ...'.concat((0,r.highlight)(e.text,e.highlight_ranges||[]),"...\n </p>\n ").concat(t.showScores?"<code>".concat(e.score,"</code>"):"","\n </div>")}).join(""),"\n ").concat(0<e.excerpts.length?"</div>":"","\n </a>\n</li>"),n.content.firstElementChild}},139:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.resolveSearch=void 0;var o=n(214),s=n(445);t.resolveSearch=function(e,t){var n=null,r=null;try{r=JSON.parse(n=(0,o.wasm_search)(e,t))}catch(e){throw new s.default("Could not parse data from wasm_search. If you see this, please file a bug: https://jil.im/storkbug "+n)}if(!r)throw new s.default("Data was an empty object");if(r.error)throw new s.default("Could not perform search: the WASM binary failed to return search results.\n You might not be serving your search index properly.\n If you think this is an error, please file a bug: https://jil.im/storkbug\n \n The WASM binary came back with:\n ".concat(r.error));return r}},445:function(e,t){var r,n,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var n in t)!{}.hasOwnProperty.call(t,n)||(e[n]=t[n])}))(e,t)},function(e,t){function n(){this.constructor=e}if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+t+" is not a constructor or null");r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=(Object.defineProperty(t,"__esModule",{value:!0}),o(s,n=Error),s);function s(e){e=n.call(this,e)||this;return e.name="StorkError",e}t.default=o},466:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.plural=t.difference=t.htmlToElement=void 0,t.htmlToElement=function(e){var t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content.firstChild},t.difference=function(e,t){var n=new Set(t);return Array.from(new Set(Array.from(new Set(e)).filter(function(e){return!n.has(e)})))},t.plural=function(e,t,n){return 1==e?t:n}},34:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validateIndexParams=void 0;var r=n(445);t.validateIndexParams=function(e,t){return"string"!=typeof e?new r.default("Index registration name must be a string."):"string"!=typeof t?new r.default("URL must be a string."):null}},258:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.debug=t.loadWasm=t.runAfterWasmLoaded=void 0;var r=n(214),o=n(445),s=null,i=null,a=[],l=[],u=(t.loadWasm=function(e){var t;return i||(t=(e=void 0===e?null:e)||"https://files.stork-search.net/releases/v1.5.0/stork.wasm",s=t,e=(0,r.default)(t).then(function(){return u(),t}).catch(function(){throw c(),new o.default("Error while loading WASM at ".concat(t))}),i=e)},t.runAfterWasmLoaded=function(e,t){return i?(i.then(function(){return e()}).catch(function(){return t()}),i):(a.push(e),l.push(t),null)},function(){a.forEach(function(e){e()}),a=[]}),c=function(){l.forEach(function(e){e()}),l=[]};t.debug=function(){return{wasmSourceUrl:s,wasmLoadPromise:i,queueLength:a.length}}}},o={};r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("","return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>({}).hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.g.importScripts&&(e=r.g.location+"");var e,t=r.g.document;if(e||!t||(e=t.currentScript?t.currentScript.src:e)||(t=t.getElementsByTagName("script")).length&&(e=t[t.length-1].src),!e)throw Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=e;t=r(480);stork=t})();var stork,loaded=!1;window.onload=function(){document.body.contains(document.goSearch)&&(document.goSearch.onsubmit=function(){return goSearchNow()}),document.getElementById("searchinput").onfocus=function(){loaded||(loadStork(),loaded=!0,document.body.contains(document.goSearch)&&(document.goSearch.onsubmit=function(){return goSearchNow()})),document.getElementById("searchinput").onfocus=""}};
\ No newline at end of file diff --git a/static/js/stork.js b/static/js/stork.js deleted file mode 100644 index b464ecd..0000000 --- a/static/js/stork.js +++ /dev/null @@ -1,2 +0,0 @@ -var stork;(()=>{"use strict";var e={214:(e,t,n)=>{let r;n.r(t),n.d(t,{default:()=>_,wasm_register_index:()=>v,wasm_search:()=>y,wasm_stork_version:()=>w});const o=new Array(32).fill(void 0);function s(e){return o[e]}o.push(void 0,null,!0,!1);let i=o.length;let a=0,l=null;function u(){return null!==l&&l.buffer===r.memory.buffer||(l=new Uint8Array(r.memory.buffer)),l}let c=new TextEncoder("utf-8");const d="function"==typeof c.encodeInto?function(e,t){return c.encodeInto(e,t)}:function(e,t){const n=c.encode(e);return t.set(n),{read:e.length,written:n.length}};function h(e,t,n){if(void 0===n){const n=c.encode(e),r=t(n.length);return u().subarray(r,r+n.length).set(n),a=n.length,r}let r=e.length,o=t(r);const s=u();let i=0;for(;i<r;i++){const t=e.charCodeAt(i);if(t>127)break;s[o+i]=t}if(i!==r){0!==i&&(e=e.slice(i)),o=n(o,r,r=i+3*e.length);const t=u().subarray(o+i,o+r);i+=d(e,t).written}return a=i,o}let f=null;function g(){return null!==f&&f.buffer===r.memory.buffer||(f=new Int32Array(r.memory.buffer)),f}let p=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});function m(e,t){return p.decode(u().subarray(e,e+t))}function v(e,t){try{const d=r.__wbindgen_add_to_stack_pointer(-16);var n=h(e,r.__wbindgen_malloc,r.__wbindgen_realloc),o=a,s=function(e,t){const n=t(1*e.length);return u().set(e,n/1),a=e.length,n}(t,r.__wbindgen_malloc),i=a;r.wasm_register_index(d,n,o,s,i);var l=g()[d/4+0],c=g()[d/4+1];return m(l,c)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(l,c)}}function y(e,t){try{const c=r.__wbindgen_add_to_stack_pointer(-16);var n=h(e,r.__wbindgen_malloc,r.__wbindgen_realloc),o=a,s=h(t,r.__wbindgen_malloc,r.__wbindgen_realloc),i=a;r.wasm_search(c,n,o,s,i);var l=g()[c/4+0],u=g()[c/4+1];return m(l,u)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(l,u)}}function w(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.wasm_stork_version(n);var e=g()[n/4+0],t=g()[n/4+1];return m(e,t)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(e,t)}}p.decode();const _=async function e(t){void 0===t&&(t=new URL("stork_bg.wasm",function(e){const t=n.p;let r="";return(!t||t.indexOf("://")<0)&&(r+=window.location.protocol+"//"+window.location.host),r+=t||"/",r+e}("node_modules/stork-search/stork.js")));const l={wbg:{}};l.wbg.__wbg_new_693216e109162396=function(){return function(e){i===o.length&&o.push(o.length+1);const t=i;return i=o[t],o[t]=e,t}(new Error)},l.wbg.__wbg_stack_0ddaca5d1abfb52f=function(e,t){var n=h(s(t).stack,r.__wbindgen_malloc,r.__wbindgen_realloc),o=a;g()[e/4+1]=o,g()[e/4+0]=n},l.wbg.__wbg_error_09919627ac0992f5=function(e,t){try{console.error(m(e,t))}finally{r.__wbindgen_free(e,t)}},l.wbg.__wbindgen_object_drop_ref=function(e){!function(e){const t=s(e);(function(e){e<36||(o[e]=i,i=e)})(e)}(e)},("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t));const{instance:u,module:c}=await async function(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if("application/wasm"==e.headers.get("Content-Type"))throw t;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t)}const n=await e.arrayBuffer();return await WebAssembly.instantiate(n,t)}{const n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}}(await t,l);return r=u.exports,e.__wbindgen_wasm_module=c,r}},914:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.calculateOverriddenConfig=t.defaultConfig=void 0;var r=n(445),o=n(466);t.defaultConfig={showProgress:!0,printIndexInfo:!1,showScores:!1,showCloseButton:!0,minimumQueryLength:3,forceOverwrite:!1,resultNoun:{singular:"file",plural:"files"},onQueryUpdate:void 0,onResultSelected:void 0,onResultsHidden:void 0,onInputCleared:void 0,transformResultUrl:function(e){return e}},t.calculateOverriddenConfig=function(e){var n=(0,o.difference)(Object.keys(e),Object.keys(t.defaultConfig));if(n.length>0){var s=(0,o.plural)(n.length,"key","keys"),i=JSON.stringify(n);return new r.default("Invalid ".concat(s," in config object: ").concat(i))}for(var a=Object.assign({},t.defaultConfig),l=0,u=Object.keys(t.defaultConfig);l<u.length;l++){var c=u[l],d=e[c];void 0!==d&&(a[c]=d)}return a}},227:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.existsBeyondContainerBounds=t.setText=t.clear=t.add=t.create=void 0,t.create=function(e,t){var n=document.createElement(e);return t.classNames&&n.setAttribute("class",t.classNames.join(" ")),n},t.add=function(e,t,n){n.insertAdjacentElement(t,e)},t.clear=function(e){for(;e&&e.firstChild;)e.removeChild(e.firstChild)},t.setText=function(e,t){var n=document.createTextNode(t);e&&e.firstChild?e.replaceChild(n,e.firstChild):e&&e.appendChild(n)},t.existsBeyondContainerBounds=function(e,t){var n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.bottom>r.bottom||n.top<r.top}},934:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Entity=void 0;var r=n(139),o=n(771),s=n(214),i=n(445),a=function(){function e(e,t,n){var r=this;this._state="initialized",this.downloadProgress=0,this.results=[],this.totalResultCount=0,this.eventListenerFunctions={},this.highlightedResult=0,this.resultsVisible=!1,this.hoverSelectEnabled=!0,this.setDownloadProgress=function(e){r.state="loading",r.downloadProgress=e,r.config.showProgress&&r.render()},this.name=e,this.url=t,this.config=n}return Object.defineProperty(e.prototype,"state",{get:function(){return this._state},set:function(e){this._state=e,this.render()},enumerable:!1,configurable:!0}),e.prototype.getCurrentMessage=function(){if(!this.domManager)return null;var e=this.domManager.getQuery();return"error"===this.state?"Error! Check the browser console.":"ready"!=this.state?"Loading...":(null==e?void 0:e.length)<this.config.minimumQueryLength?"Filtering...":this.results?0===this.totalResultCount?"No ".concat(this.config.resultNoun.plural," found."):1===this.totalResultCount?"1 ".concat(this.config.resultNoun.singular," found."):"".concat(this.totalResultCount," ").concat(this.config.resultNoun.plural," found."):null},e.prototype.generateRenderConfig=function(){return{results:this.results,resultsVisible:!0,showScores:this.config.showScores,message:this.getCurrentMessage(),showProgress:this.config.showProgress,progress:this.downloadProgress,state:this.state}},e.prototype.render=function(){this.domManager&&this.domManager.render(this.generateRenderConfig())},e.prototype.registerIndex=function(e){var t=this;return new Promise((function(n,r){var o=JSON.parse((0,s.wasm_register_index)(t.name,e));o.error?r(new i.default(o.error)):(t.config.printIndexInfo&&console.log(o),t.state="ready",n(o))}))},e.prototype.attachToDom=function(){this.domManager=new o.EntityDom(this.name,this),this.render()},e.prototype.injestSearchData=function(e){var t=this;this.results=e.results,this.totalResultCount=e.total_hit_count,this.highlightedResult=0;var n=e.url_prefix||"";this.results.map((function(e){var r="",o=e.excerpts.map((function(e){return e.internal_annotations})).filter((function(e){return!!e}))[0];if(o&&o[0]){var s=o[0];"string"==typeof s.a&&(r+=s.a)}e.excerpts&&e.excerpts[0]&&e.excerpts[0].internal_annotations&&e.excerpts[0].internal_annotations[0]&&e.excerpts[0].internal_annotations[0].a&&"string"==typeof e.excerpts[0].internal_annotations[0].a&&(r=e.excerpts[0].internal_annotations[0].a),e.entry.url=t.config.transformResultUrl("".concat(n).concat(e.entry.url).concat(r))})),this.render()},e.prototype.getSanitizedResults=function(){var e=this.results;return e.map((function(e){delete e.title_highlight_ranges,e.excerpts.map((function(e){delete e.highlight_ranges,delete e.internal_annotations}))})),e},e.prototype.setDownloadError=function(){this.state="error"},e.prototype.performSearch=function(e){if("ready"===this.state){if(e.length<this.config.minimumQueryLength)return this.results=[],void this.render();try{var t=(0,r.resolveSearch)(this.name,e);if(!t)return;this.injestSearchData(t),this.config.onQueryUpdate&&this.config.onQueryUpdate(e,this.getSanitizedResults())}catch(e){console.error(e)}}else this.render()},e}();t.Entity=a},771:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EntityDom=void 0;var r=n(227),o=n(9),s={results:[],resultsVisible:!1,showScores:!1,message:null,showProgress:!1,progress:1,state:"ready"},i=function(){function e(e,t){var n,o,i=this;this.scrollAnchorPoint="end",this.entity=t;var a=[{selector:'input[data-stork="'.concat(e,'"]'),elementName:"input"},{selector:'div[data-stork="'.concat(e,'-output"]'),elementName:"output"}].map((function(t){var n=document.querySelector(t.selector);if(!n)throw new Error('Could not register search box "'.concat(e,'": ').concat(t.elementName," element not found. Make sure an element matches the query selector `").concat(t.selector,"`"));return n})),l=a[0],u=a[1];this.elements={input:l,output:u,list:(0,r.create)("ul",{classNames:["stork-results"]}),attribution:(0,r.create)("div",{classNames:["stork-attribution"]}),progress:(0,r.create)("div",{classNames:["stork-progress"]}),message:(0,r.create)("div",{classNames:["stork-message"]}),closeButton:(0,r.create)("button",{classNames:["stork-close-button"]})},this.elements.input.removeEventListener("input",this.entity.eventListenerFunctions.inputInputEvent),this.elements.input.removeEventListener("keydown",this.entity.eventListenerFunctions.inputKeydownEvent),this.entity.eventListenerFunctions={inputInputEvent:function(e){i.handleInputEvent(e)},inputKeydownEvent:function(e){i.handleKeyDownEvent(e)}},this.elements.input.addEventListener("input",this.entity.eventListenerFunctions.inputInputEvent),this.elements.input.addEventListener("keydown",this.entity.eventListenerFunctions.inputKeydownEvent),null===(n=this.elements.list)||void 0===n||n.addEventListener("mousemove",(function(){i.hoverSelectEnabled=!0})),this.elements.attribution.innerHTML='Powered by <a href="https://stork-search.net">Stork</a>',this.elements.closeButton.innerHTML='\n<svg height="0.8em" viewBox="0 0 23 24" xmlns="http://www.w3.org/2000/svg">\n<g fill="none" fill-rule="evenodd" stroke-linecap="round">\n<g transform="translate(-700 -149)" stroke="currentcolor" stroke-width="4">\n<line id="a" x1="702.5" x2="720" y1="152.5" y2="170"/>\n<line transform="translate(711 161) rotate(-90) translate(-711 -161)" x1="702.5" x2="720" y1="152.5" y2="170"/>\n</g>\n</g>\n</svg>',this.entity.config.showProgress&&(0,r.add)(this.elements.progress,"afterend",this.elements.input),null===(o=this.elements.closeButton)||void 0===o||o.addEventListener("click",(function(){i.elements.input.value="",i.elements.input.focus(),i.render(s);var e=[i.entity.config.onInputCleared,i.entity.config.onResultsHidden],t=e[0],n=e[1];t&&t(),n&&n()}))}return e.prototype.clearDom=function(){var e;(0,r.clear)(this.elements.output),(0,r.clear)(this.elements.list),null===(e=this.elements.closeButton)||void 0===e||e.remove(),this.elements.output.classList.remove("stork-output-visible")},e.prototype.render=function(e){var t,n=this,s=this.elements.input.value;if(this.clearDom(),this.lastRenderState=e,e.showProgress){var i=function(){switch(e.state){case"ready":case"error":return 1;case"initialized":case"loading":return.9*e.progress+.05}}();i<1?(this.elements.progress.style.width="".concat(100*i,"%"),this.elements.progress.style.opacity="1"):(this.elements.progress.style.width="100%",this.elements.progress.style.opacity="0")}if("error"===e.state&&this.elements.input.classList.add("stork-error"),this.getQuery().length>0&&e.resultsVisible&&(this.elements.output.classList.add("stork-output-visible"),(0,r.add)(this.elements.message,"beforeend",this.elements.output)),e.message&&(0,r.setText)(this.elements.message,e.message),(null===(t=e.results)||void 0===t?void 0:t.length)>0&&e.resultsVisible){(0,r.add)(this.elements.list,"beforeend",this.elements.output);for(var a=function(t){var s=e.results[t],i={selected:t===l.highlightedResult,showScores:e.showScores},a=(0,o.resultToListItem)(s,i);(0,r.add)(a,"beforeend",l.elements.list),a.addEventListener("mousemove",(function(){n.hoverSelectEnabled&&t!==n.highlightedResult&&n.changeHighlightedResult({to:t,shouldScrollTo:!1})})),a.addEventListener("mouseleave",(function(){n.hoverSelectEnabled&&t===n.highlightedResult&&n.changeHighlightedResult({to:-1,shouldScrollTo:!1})})),a.addEventListener("click",(function(e){e.preventDefault(),n.selectResult()}))},l=this,u=0;u<e.results.length;u++)a(u);(0,r.add)(this.elements.attribution,"beforeend",this.elements.output)}((null==s?void 0:s.length)||0)>0&&this.entity.config.showCloseButton&&(0,r.add)(this.elements.closeButton,"afterend",this.elements.input)},e.prototype.selectResult=function(){if(null!=this.highlightedResult){var e=this.entity.results[this.highlightedResult];this.entity.config.onResultSelected?Promise.resolve(this.entity.config.onResultSelected(this.getQuery(),e)).finally((function(){window.location.assign(e.entry.url)})):window.location.assign(e.entry.url)}},e.prototype.changeHighlightedResult=function(e){var t,n=this.highlightedResult,o=Math.max(-1,Math.min(this.entity.results.length-1,e.to));this.highlightedResult=o,this.scrollAnchorPoint=(n||0)<o?"end":"start";for(var s=null,i=0;i<this.entity.results.length;i++){var a=null===(t=this.elements.list)||void 0===t?void 0:t.children[i];if(a){var l="selected";i==o?(a.classList.add(l),s=a):a.classList.remove(l)}}return e.shouldScrollTo&&(this.hoverSelectEnabled=!1,s&&(0,r.existsBeyondContainerBounds)(s,this.elements.list)&&s.scrollIntoView({behavior:"smooth",block:this.scrollAnchorPoint,inline:"nearest"})),o},e.prototype.handleKeyDownEvent=function(e){switch(e.keyCode){case 40:if(null==this.highlightedResult)this.changeHighlightedResult({to:0,shouldScrollTo:!0});else{var t=Math.min(this.highlightedResult+1,this.entity.results.length-1);this.changeHighlightedResult({to:t,shouldScrollTo:!0})}break;case 38:null!=this.highlightedResult&&(t=Math.max(0,this.highlightedResult-1),this.changeHighlightedResult({to:t,shouldScrollTo:!0}));break;case 13:this.selectResult();break;case 27:if(this.lastRenderState.resultsVisible)this.render(s),(n=this.entity.config.onResultsHidden)&&n();else if(this.elements.input.value.length>0){var n;this.elements.input.value="",this.render(s),(n=this.entity.config.onInputCleared)&&n()}break;default:return}},e.prototype.handleInputEvent=function(e){this.entity.performSearch(e.target.value)},e.prototype.getQuery=function(){return this.elements.input.value},e}();t.EntityDom=i},129:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.debug=t.entityIsReady=t.attachToDom=t.register=void 0;var o=n(934),s=n(914),i=n(794),a=n(258),l=n(445),u={};t.register=function(e,t,n){return new Promise((function(r,c){var d=(0,s.calculateOverriddenConfig)(n);if(d instanceof l.default)c(d);else{u[e]&&!d.forceOverwrite&&c(new l.default("You're registering an index named `".concat(e,"`, but that already exists. If this is expected, set forceOverwrite to true in your Javascript config to allow overwriting indexes.")));var h=new o.Entity(e,t,d);u[e]=h,(0,i.loadIndexFromUrl)(t,{progress:function(e){h.setDownloadProgress(e)},load:function(e){(0,a.runAfterWasmLoaded)((function(){h.registerIndex(new Uint8Array(e)).then(r).catch(c)}),(function(){h.state="error"}))},error:function(){h.setDownloadError(),c()}})}}))},t.attachToDom=function(e){if(!u[e])throw new Error("Index ".concat(e," has not been registered!"));u[e].attachToDom()},t.entityIsReady=function(e){var t;return"ready"===(null===(t=u[e])||void 0===t?void 0:t.state)},t.debug=function(){return{entities:r({},u),entitiesCount:u.length}}},794:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.loadIndexFromUrl=void 0,t.loadIndexFromUrl=function(e,t){var n=new XMLHttpRequest;n.addEventListener("load",(function(e){var n=e.target,r=n.status,o=n.response;0!==r?r<200||r>299?t.error():t.load(o):t.progress(e.loaded/e.total)})),n.addEventListener("error",(function(){t.error()})),n.addEventListener("progress",(function(e){t.progress(e.loaded/e.total)})),n.responseType="arraybuffer",n.open("GET",e),n.send()}},480:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.debug=t.register=t.search=t.attach=t.downloadIndex=t.initialize=void 0;var o=n(129),s=n(258),i=n(139),a=n(445),l=n(34),u=n(214);function c(e){return void 0===e&&(e=null),(0,s.loadWasm)(e).then((function(){}))}function d(e,t,n){return void 0===n&&(n={}),new Promise((function(r,s){var i=(0,l.validateIndexParams)(e,t);i?s(i):(0,o.register)(e,t,n).then(r).catch(s)}))}function h(e){try{(0,o.attachToDom)(e)}catch(e){throw new a.default(e.message)}}t.initialize=c,t.downloadIndex=d,t.attach=h,t.register=function(e,t,n){void 0===n&&(n={});var r=c(),o=d(e,t,n);return h(e),Promise.all([r,o]).then()},t.search=function(e,t){if(!e||!t)throw new a.default("Make sure to call stork.search() with two arguments: the index name and the search query.");if(!(0,o.entityIsReady)(e))throw new a.default("Couldn't find index. Make sure the stork.downloadIndex() promise has resolved before calling stork.search().");return(0,i.resolveSearch)(e,t)},t.debug=function(){return r(r(r({},(0,s.debug)()),(0,o.debug)()),{jsStorkVersion:"1.5.0",wasmStorkVersion:u.wasm_stork_version})}},112:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.highlight=void 0,t.highlight=function(e,t){function n(e,t,n){return e.substr(0,t)+n+e.substr(t)}for(var r=0,o=0,s=t;o<s.length;o++){var i=s[o],a='<mark class="stork-highlight">',l="</mark>";e=n(e,i.beginning+r,a),r+=a.length,e=n(e,i.end+r,l),r+=l.length}return e}},9:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.resultToListItem=void 0;var r=n(112);t.resultToListItem=function(e,t){var n=document.createElement("template");return n.innerHTML='\n<li class="stork-result'.concat(t.selected?" selected":"",'">\n <a href="').concat(e.entry.url,'">\n <div class="stork-title">\n <p>').concat((0,r.highlight)(e.entry.title,e.title_highlight_ranges||[]),"</p>\n ").concat(t.showScores?"<code><b>".concat(e.score,"</b></code>"):"","\n </div>\n ").concat(e.excerpts.length>0?'<div class="stork-excerpt-container" />':"","\n ").concat(e.excerpts.map((function(e){return'<div class="stork-excerpt"><p>\n ...'.concat((0,r.highlight)(e.text,e.highlight_ranges||[]),"...\n </p>\n ").concat(t.showScores?"<code>".concat(e.score,"</code>"):"","\n </div>")})).join(""),"\n ").concat(e.excerpts.length>0?"</div>":"","\n </a>\n</li>"),n.content.firstElementChild}},139:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.resolveSearch=void 0;var r=n(214),o=n(445);t.resolveSearch=function(e,t){var n=null,s=null;try{n=(0,r.wasm_search)(e,t),s=JSON.parse(n)}catch(e){throw new o.default("Could not parse data from wasm_search. If you see this, please file a bug: https://jil.im/storkbug "+n)}if(!s)throw new o.default("Data was an empty object");if(s.error)throw new o.default("Could not perform search: the WASM binary failed to return search results.\n You might not be serving your search index properly.\n If you think this is an error, please file a bug: https://jil.im/storkbug\n \n The WASM binary came back with:\n ".concat(s.error));return s}},445:function(e,t){var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var n=e.call(this,t)||this;return n.name="StorkError",n}return r(t,e),t}(Error);t.default=o},466:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.plural=t.difference=t.htmlToElement=void 0,t.htmlToElement=function(e){var t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content.firstChild},t.difference=function(e,t){var n=new Set(e),r=new Set(t),o=new Set(Array.from(n).filter((function(e){return!r.has(e)})));return Array.from(o)},t.plural=function(e,t,n){return 1==e?t:n}},34:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validateIndexParams=void 0;var r=n(445);t.validateIndexParams=function(e,t){return"string"!=typeof e?new r.default("Index registration name must be a string."):"string"!=typeof t?new r.default("URL must be a string."):null}},258:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.debug=t.loadWasm=t.runAfterWasmLoaded=void 0;var r=n(214),o=n(445),s="https://files.stork-search.net/releases/v".concat("1.5.0","/stork.wasm"),i=null,a=null,l=[],u=[];t.loadWasm=function(e){if(void 0===e&&(e=null),a)return a;var t=e||s;i=t;var n=(0,r.default)(t).then((function(){return c(),t})).catch((function(){throw d(),new o.default("Error while loading WASM at ".concat(t))}));return a=n,n},t.runAfterWasmLoaded=function(e,t){return a?(a.then((function(){return e()})).catch((function(){return t()})),a):(l.push(e),u.push(t),null)};var c=function(){l.forEach((function(e){e()})),l=[]},d=function(){u.forEach((function(e){e()})),u=[]};t.debug=function(){return{wasmSourceUrl:i,wasmLoadPromise:a,queueLength:l.length}}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),s.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");r.length&&(e=r[r.length-1].src)}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})();var r=n(480);stork=r})(); -//# sourceMappingURL=stork.js.map
\ No newline at end of file diff --git a/static/js/stork_config.js b/static/js/stork_config.js deleted file mode 100644 index 3c589c2..0000000 --- a/static/js/stork_config.js +++ /dev/null @@ -1,25 +0,0 @@ -function loadStork() { - var baseUrl = document.querySelector("meta[name='base']").getAttribute("content"); - if (baseUrl.slice(-1) == "/") { - baseUrl = baseUrl.slice(0, -1); - } - stork.initialize(baseUrl + "/stork.wasm").then(() => { - console.log("Finished downloading WASM"); - }) - .catch(e => { - console.error(e); - }); // download WASM - stork.register("stork",baseUrl + "/stork.st"); -} -var loaded = false; -window.onload = function() { - document.body.contains(document.goSearch) && (document.goSearch.onsubmit = function() { return goSearchNow() }) - document.getElementById('searchinput').onfocus = function() { - if (!loaded) { - loadStork(); - loaded = true; - document.body.contains(document.goSearch) && (document.goSearch.onsubmit = function() { return goSearchNow() }) - } - document.getElementById('searchinput').onfocus = ''; - } -}; |
