diff --git a/content/01-cyanine-theme/04-mdfixes.md b/content/01-cyanine-theme/04-mdfixes.md deleted file mode 100644 index 4de2e62..0000000 --- a/content/01-cyanine-theme/04-mdfixes.md +++ /dev/null @@ -1,11 +0,0 @@ -# mdfixes - -Content and some more. -## This is headline second order -This is a little bit of text that we need to have nothing - -Some more text. - -# And a headline first order - -With some more text below. \ No newline at end of file diff --git a/content/01-cyanine-theme/04-mdfixes.txt b/content/01-cyanine-theme/04-mdfixes.txt deleted file mode 100644 index 21d0607..0000000 --- a/content/01-cyanine-theme/04-mdfixes.txt +++ /dev/null @@ -1 +0,0 @@ -["# mdfixes","Content and some more. Danke","## This is headline second order","This is a little bit of text that we need to have nothing","Some more text.","# And a headline first order","With some more text below."] \ No newline at end of file diff --git a/content/01-cyanine-theme/04-mdfixes.yaml b/content/01-cyanine-theme/04-mdfixes.yaml deleted file mode 100644 index a216cc2..0000000 --- a/content/01-cyanine-theme/04-mdfixes.yaml +++ /dev/null @@ -1,9 +0,0 @@ -meta: - title: mdfixes - description: "Content and some more. This is headline second order\nThis is a little bit of text that we need to have." - owner: trendschau - author: 'Sebastian Schürmanns' - created: '2020-10-01' - time: 20-40-00 - navtitle: mdfixes - modified: '2020-10-01' diff --git a/plugins/blurbbox/blurbbox.php b/plugins/blurbbox/blurbbox.php deleted file mode 100644 index 0e068df..0000000 --- a/plugins/blurbbox/blurbbox.php +++ /dev/null @@ -1,26 +0,0 @@ - 'onPageReady', - ); - } - - public function onPageReady($page) - { - $pageData = $page->getData($page); - - $pageData['widgets']['blurbbox'] = '

Notes on (mostly) daily perceptions and experiences by Joseph Zitt, an American immigrant to Israel.

' . - '

Buy the book.

' . - '

Subscribe to the weekly newsletter.

'; - - $page->setData($pageData); - } -} \ No newline at end of file diff --git a/plugins/blurbbox/blurbbox.yaml b/plugins/blurbbox/blurbbox.yaml deleted file mode 100644 index 0e4ae08..0000000 --- a/plugins/blurbbox/blurbbox.yaml +++ /dev/null @@ -1,8 +0,0 @@ -name: Blurbbox -version: 1.0.0 -description: Add a search to your website with lunr.js. -author: Trendschau -homepage: https://typemill.net -licence: MIT -paypal: https://paypal.me/typemill -amount: 10 \ No newline at end of file diff --git a/plugins/blurbbox/index.php b/plugins/blurbbox/index.php deleted file mode 100644 index 74ff7ec..0000000 --- a/plugins/blurbbox/index.php +++ /dev/null @@ -1,87 +0,0 @@ -getFile('cache', 'index.json'); - if(!$index) - { - $this->createIndex(); - $index = $write->getFile('cache', 'index.json'); - } - - return $this->returnJson($index); - } - - private function createIndex() - { - $write = new WriteCache(); - - # get content structure - $structure = $write->getCache('cache', 'structure.txt'); - - # get data for search-index - $index = $this->getAllContent($structure, $write); - - # store the index file here - $write->writeFile('cache', 'index.json', json_encode($index, JSON_UNESCAPED_SLASHES)); - } - - private function getAllContent($structure, $write, $index = NULL) - { - foreach($structure as $item) - { - if($item->elementType == "folder") - { - if($item->fileType == 'md') - { - $page = $write->getFileWithPath('content' . $item->path . DIRECTORY_SEPARATOR . 'index.md'); - $pageArray = $this->getPageContentArray($page, $item->urlAbs); - $index[$pageArray['url']] = $pageArray; - } - - $index = $this->getAllContent($item->folderContent, $write, $index); - } - else - { - $page = $write->getFileWithPath('content' . $item->path); - $pageArray = $this->getPageContentArray($page, $item->urlAbs); - $index[$pageArray['url']] = $pageArray; - } - } - return $index; - } - - private function getPageContentArray($page, $url) - { - $parts = explode("\n", $page, 2); - - # get the title / headline - $title = trim($parts[0], '# '); - $title = str_replace(["\r\n", "\n", "\r"],' ', $title); - - # get and cleanup the content - $content = $parts[1]; - $content = strip_tags($content); - $content = str_replace(["\r\n", "\n", "\r"],' ', $content); - - $pageContent = [ - 'title' => $title, - 'content' => $content, - 'url' => $url - ]; - - return $pageContent; - } -} \ No newline at end of file diff --git a/plugins/blurbbox/public/lunr-licence.md b/plugins/blurbbox/public/lunr-licence.md deleted file mode 100644 index 93bece9..0000000 --- a/plugins/blurbbox/public/lunr-licence.md +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) 2013 by Oliver Nightingale - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file diff --git a/plugins/blurbbox/public/lunr.min.js b/plugins/blurbbox/public/lunr.min.js deleted file mode 100644 index 34b279d..0000000 --- a/plugins/blurbbox/public/lunr.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.6 - * Copyright (C) 2019 Oliver Nightingale - * @license MIT - */ -!function(){var e=function(t){var r=new e.Builder;return r.pipeline.add(e.trimmer,e.stopWordFilter,e.stemmer),r.searchPipeline.add(e.stemmer),t.call(r,r),r.build()};e.version="2.3.6",e.utils={},e.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),e.utils.asString=function(e){return void 0===e||null===e?"":e.toString()},e.utils.clone=function(e){if(null===e||void 0===e)return e;for(var t=Object.create(null),r=Object.keys(e),i=0;i0){var c=e.utils.clone(r)||{};c.position=[a,l],c.index=s.length,s.push(new e.Token(i.slice(a,o),c))}a=o+1}}return s},e.tokenizer.separator=/[\s\-]+/,e.Pipeline=function(){this._stack=[]},e.Pipeline.registeredFunctions=Object.create(null),e.Pipeline.registerFunction=function(t,r){r in this.registeredFunctions&&e.utils.warn("Overwriting existing registered function: "+r),t.label=r,e.Pipeline.registeredFunctions[t.label]=t},e.Pipeline.warnIfFunctionNotRegistered=function(t){var r=t.label&&t.label in this.registeredFunctions;r||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 r=new e.Pipeline;return t.forEach(function(t){var i=e.Pipeline.registeredFunctions[t];if(!i)throw new Error("Cannot load unregistered function: "+t);r.add(i)}),r},e.Pipeline.prototype.add=function(){var t=Array.prototype.slice.call(arguments);t.forEach(function(t){e.Pipeline.warnIfFunctionNotRegistered(t),this._stack.push(t)},this)},e.Pipeline.prototype.after=function(t,r){e.Pipeline.warnIfFunctionNotRegistered(r);var i=this._stack.indexOf(t);if(i==-1)throw new Error("Cannot find existingFn");i+=1,this._stack.splice(i,0,r)},e.Pipeline.prototype.before=function(t,r){e.Pipeline.warnIfFunctionNotRegistered(r);var i=this._stack.indexOf(t);if(i==-1)throw new Error("Cannot find existingFn");this._stack.splice(i,0,r)},e.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);t!=-1&&this._stack.splice(t,1)},e.Pipeline.prototype.run=function(e){for(var t=this._stack.length,r=0;r1&&(se&&(r=n),s!=e);)i=r-t,n=t+Math.floor(i/2),s=this.elements[2*n];return s==e?2*n:s>e?2*n:sa?l+=2:o==a&&(t+=r[u+1]*i[l+1],u+=2,l+=2);return t},e.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},e.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),t=1,r=0;t0){var o,a=s.str.charAt(0);a in s.node.edges?o=s.node.edges[a]:(o=new e.TokenSet,s.node.edges[a]=o),1==s.str.length&&(o["final"]=!0),n.push({node:o,editsRemaining:s.editsRemaining,str:s.str.slice(1)})}if(0!=s.editsRemaining){if("*"in s.node.edges)var u=s.node.edges["*"];else{var u=new e.TokenSet;s.node.edges["*"]=u}if(0==s.str.length&&(u["final"]=!0),n.push({node:u,editsRemaining:s.editsRemaining-1,str:s.str}),s.str.length>1&&n.push({node:s.node,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)}),1==s.str.length&&(s.node["final"]=!0),s.str.length>=1){if("*"in s.node.edges)var l=s.node.edges["*"];else{var l=new e.TokenSet;s.node.edges["*"]=l}1==s.str.length&&(l["final"]=!0),n.push({node:l,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)})}if(s.str.length>1){var c,h=s.str.charAt(0),d=s.str.charAt(1);d in s.node.edges?c=s.node.edges[d]:(c=new e.TokenSet,s.node.edges[d]=c),1==s.str.length&&(c["final"]=!0),n.push({node:c,editsRemaining:s.editsRemaining-1,str:h+s.str.slice(2)})}}}return i},e.TokenSet.fromString=function(t){for(var r=new e.TokenSet,i=r,n=0,s=t.length;n=e;t--){var r=this.uncheckedNodes[t],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r["char"]]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}},e.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},e.Index.prototype.search=function(t){return this.query(function(r){var i=new e.QueryParser(t,r);i.parse()})},e.Index.prototype.query=function(t){for(var r=new e.Query(this.fields),i=Object.create(null),n=Object.create(null),s=Object.create(null),o=Object.create(null),a=Object.create(null),u=0;u1?this._b=1:this._b=e},e.Builder.prototype.k1=function(e){this._k1=e},e.Builder.prototype.add=function(t,r){var i=t[this._ref],n=Object.keys(this._fields);this._documents[i]=r||{},this.documentCount+=1;for(var s=0;s=this.length)return e.QueryLexer.EOS;var t=this.str.charAt(this.pos);return this.pos+=1,t},e.QueryLexer.prototype.width=function(){return this.pos-this.start},e.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},e.QueryLexer.prototype.backup=function(){this.pos-=1},e.QueryLexer.prototype.acceptDigitRun=function(){var t,r;do t=this.next(),r=t.charCodeAt(0);while(r>47&&r<58);t!=e.QueryLexer.EOS&&this.backup()},e.QueryLexer.prototype.more=function(){return this.pos1&&(t.backup(),t.emit(e.QueryLexer.TERM)),t.ignore(),t.more())return e.QueryLexer.lexText},e.QueryLexer.lexEditDistance=function(t){return t.ignore(),t.acceptDigitRun(),t.emit(e.QueryLexer.EDIT_DISTANCE),e.QueryLexer.lexText},e.QueryLexer.lexBoost=function(t){return t.ignore(),t.acceptDigitRun(),t.emit(e.QueryLexer.BOOST),e.QueryLexer.lexText},e.QueryLexer.lexEOS=function(t){t.width()>0&&t.emit(e.QueryLexer.TERM)},e.QueryLexer.termSeparator=e.tokenizer.separator,e.QueryLexer.lexText=function(t){for(;;){var r=t.next();if(r==e.QueryLexer.EOS)return e.QueryLexer.lexEOS;if(92!=r.charCodeAt(0)){if(":"==r)return e.QueryLexer.lexField;if("~"==r)return t.backup(),t.width()>0&&t.emit(e.QueryLexer.TERM),e.QueryLexer.lexEditDistance;if("^"==r)return t.backup(),t.width()>0&&t.emit(e.QueryLexer.TERM),e.QueryLexer.lexBoost;if("+"==r&&1===t.width())return t.emit(e.QueryLexer.PRESENCE),e.QueryLexer.lexText;if("-"==r&&1===t.width())return t.emit(e.QueryLexer.PRESENCE),e.QueryLexer.lexText;if(r.match(e.QueryLexer.termSeparator))return e.QueryLexer.lexTerm}else t.escapeCharacter()}},e.QueryParser=function(t,r){this.lexer=new e.QueryLexer(t),this.query=r,this.currentClause={},this.lexemeIdx=0},e.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var t=e.QueryParser.parseClause;t;)t=t(this);return this.query},e.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},e.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},e.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},e.QueryParser.parseClause=function(t){var r=t.peekLexeme();if(void 0!=r)switch(r.type){case e.QueryLexer.PRESENCE:return e.QueryParser.parsePresence;case e.QueryLexer.FIELD:return e.QueryParser.parseField;case e.QueryLexer.TERM:return e.QueryParser.parseTerm;default:var i="expected either a field or a term, found "+r.type;throw r.str.length>=1&&(i+=" with value '"+r.str+"'"),new e.QueryParseError(i,r.start,r.end)}},e.QueryParser.parsePresence=function(t){var r=t.consumeLexeme();if(void 0!=r){switch(r.str){case"-":t.currentClause.presence=e.Query.presence.PROHIBITED;break;case"+":t.currentClause.presence=e.Query.presence.REQUIRED;break;default:var i="unrecognised presence operator'"+r.str+"'";throw new e.QueryParseError(i,r.start,r.end)}var n=t.peekLexeme();if(void 0==n){var i="expecting term or field, found nothing";throw new e.QueryParseError(i,r.start,r.end)}switch(n.type){case e.QueryLexer.FIELD:return e.QueryParser.parseField;case e.QueryLexer.TERM:return e.QueryParser.parseTerm;default:var i="expecting term or field, found '"+n.type+"'";throw new e.QueryParseError(i,n.start,n.end)}}},e.QueryParser.parseField=function(t){var r=t.consumeLexeme();if(void 0!=r){if(t.query.allFields.indexOf(r.str)==-1){var i=t.query.allFields.map(function(e){return"'"+e+"'"}).join(", "),n="unrecognised field '"+r.str+"', possible fields: "+i;throw new e.QueryParseError(n,r.start,r.end)}t.currentClause.fields=[r.str];var s=t.peekLexeme();if(void 0==s){var n="expecting term, found nothing";throw new e.QueryParseError(n,r.start,r.end)}switch(s.type){case e.QueryLexer.TERM:return e.QueryParser.parseTerm;default:var n="expecting term, found '"+s.type+"'";throw new e.QueryParseError(n,s.start,s.end)}}},e.QueryParser.parseTerm=function(t){var r=t.consumeLexeme();if(void 0!=r){t.currentClause.term=r.str.toLowerCase(),r.str.indexOf("*")!=-1&&(t.currentClause.usePipeline=!1);var i=t.peekLexeme();if(void 0==i)return void t.nextClause();switch(i.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+i.type+"'";throw new e.QueryParseError(n,i.start,i.end)}}},e.QueryParser.parseEditDistance=function(t){var r=t.consumeLexeme();if(void 0!=r){var i=parseInt(r.str,10);if(isNaN(i)){var n="edit distance must be numeric";throw new e.QueryParseError(n,r.start,r.end)}t.currentClause.editDistance=i;var s=t.peekLexeme();if(void 0==s)return void t.nextClause();switch(s.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+s.type+"'";throw new e.QueryParseError(n,s.start,s.end)}}},e.QueryParser.parseBoost=function(t){var r=t.consumeLexeme();if(void 0!=r){var i=parseInt(r.str,10);if(isNaN(i)){var n="boost must be numeric";throw new e.QueryParseError(n,r.start,r.end)}t.currentClause.boost=i;var s=t.peekLexeme();if(void 0==s)return void t.nextClause();switch(s.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+s.type+"'";throw new e.QueryParseError(n,s.start,s.end)}}},function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.lunr=t()}(this,function(){return e})}(); diff --git a/plugins/blurbbox/public/search.css b/plugins/blurbbox/public/search.css deleted file mode 100644 index 4979af4..0000000 --- a/plugins/blurbbox/public/search.css +++ /dev/null @@ -1,64 +0,0 @@ -.searchContainer{ - overflow: hidden; - width: 100%; - vertical-align: middle; - white-space: nowrap; -} -.searchContainer input{ - width: 100%; - height: 50px; - border: 1px solid #ddd; - font-size: 1rem; - float: left; - padding-left: 15px; - border-radius: 2px; - box-sizing:border-box; -} -.searchContainer button{ - border-top-right-radius: 2px; - border-bottom-right-radius: 2px; - border: none; - background: #232833; - height: 50px; - width: 50px; - color: #fff; - font-size: 10pt; - margin-left: -50px; -} -.searchContainer button:hover,.searchContainer button:focus, .searchContainer button:active{ - cursor: pointer; -} - -#searchresult{ -} -.resultwrapper{ -} -button#closeSearchResult{ - position: absolute; - right: 0px; - top: 0px; - margin: 10px; - border: none; - border-radius: 2px; - font-size: 1rem; - color: #fff; - background: #000; - padding: 15px; -} -button#closeSearchResult:hover,#closeSearchResult:focus{ - cursor: pointer; -} -.resultlist{ - margin: 0px; - padding: 0px; - list-style:none; -} -.resultitem{ - -} -.resultheader{ - -} -.resultsnippet{ - -} \ No newline at end of file diff --git a/plugins/blurbbox/public/search.js b/plugins/blurbbox/public/search.js deleted file mode 100644 index 639ab18..0000000 --- a/plugins/blurbbox/public/search.js +++ /dev/null @@ -1,115 +0,0 @@ -var searchField = document.getElementById("searchField"); -var searchButton = document.getElementById("searchButton"); - -if(searchField && searchButton) -{ - var searchIndex = false; - var documents = false; - var holdcontent = false; - var contentwrapper = false; - - searchField.addEventListener("focus", function(event){ - - if(!searchIndex) - { - myaxios.get('/indexrs51gfe2o2') - .then(function (response) { - - documents = JSON.parse(response.data); - - searchIndex = lunr(function() { - this.ref("id"); - this.field("title", { boost: 10 }); - this.field("content"); - for (var key in documents){ - this.add({ - "id": documents[key].url, - "title": documents[key].title, - "content": documents[key].content - }); - } - }); - - }) - .catch(function (error) {}); - } - }); - - searchButton.addEventListener("click", function(event){ - event.preventDefault(); - - var term = document.getElementById('searchField').value; - var results = searchIndex.search(term); - - var resultPages = results.map(function (match) { - return documents[match.ref]; - }); - - resultsString = "

Result for " + term + "

"; - resultsString += ""; - resultsString += "
    "; - resultPages.forEach(function (r) { - resultsString += "
  • "; - resultsString += "

    " + r.title + "

    "; - resultsString += "
    " + r.content.substring(0, 200) + " ...
    "; - resultsString += "
  • " - }); - resultsString += "
"; - - if(!holdcontent) - { - contentwrapper = document.getElementById("searchresult").parentNode; - holdcontent = contentwrapper.innerHTML; - } - - contentwrapper.innerHTML = resultsString; - - document.getElementById("closeSearchResult").addEventListener("click", function(event){ - contentwrapper.innerHTML = holdcontent; - }); - - }, false); -} - -/* -var searchIndex = lunr(function() { - this.ref("id"); - this.field("title", { boost: 10 }); - this.field("content"); - for (var key in window.pages) { - this.add({ - "id": key, - "title": pages[key].title, - "content": pages[key].content - }); - } -}); - -function getQueryVariable(variable) { - var query = window.location.search.substring(1); - var vars = query.split("&"); - for (var i = 0; i < vars.length; i++) { - var pair = vars[i].split("="); - if (pair[0] === variable) { - return decodeURIComponent(pair[1].replace(/\+/g, "%20")); - } - } -} - -var searchTerm = getQueryVariable("q"); -// creation of searchIndex from earlier example -var results = searchIndex.search(searchTerm); -var resultPages = results.map(function (match) { - return pages[match.ref]; -}); - -// resultPages from previous example -resultsString = ""; -resultPages.forEach(function (r) { - resultsString += "
  • "; - resultsString += "

    " + r.title + "

    "; - resultsString += "
    " + r.content.substring(0, 200) + "
    "; - resultsString += "
  • " -}); -document.querySelector("#search-results").innerHTML = resultsString; -*/ \ No newline at end of file diff --git a/plugins/blurbbox/search.zip b/plugins/blurbbox/search.zip deleted file mode 100644 index af82cbd..0000000 Binary files a/plugins/blurbbox/search.zip and /dev/null differ diff --git a/plugins/search/index.php b/plugins/search/index.php deleted file mode 100644 index 74ff7ec..0000000 --- a/plugins/search/index.php +++ /dev/null @@ -1,87 +0,0 @@ -getFile('cache', 'index.json'); - if(!$index) - { - $this->createIndex(); - $index = $write->getFile('cache', 'index.json'); - } - - return $this->returnJson($index); - } - - private function createIndex() - { - $write = new WriteCache(); - - # get content structure - $structure = $write->getCache('cache', 'structure.txt'); - - # get data for search-index - $index = $this->getAllContent($structure, $write); - - # store the index file here - $write->writeFile('cache', 'index.json', json_encode($index, JSON_UNESCAPED_SLASHES)); - } - - private function getAllContent($structure, $write, $index = NULL) - { - foreach($structure as $item) - { - if($item->elementType == "folder") - { - if($item->fileType == 'md') - { - $page = $write->getFileWithPath('content' . $item->path . DIRECTORY_SEPARATOR . 'index.md'); - $pageArray = $this->getPageContentArray($page, $item->urlAbs); - $index[$pageArray['url']] = $pageArray; - } - - $index = $this->getAllContent($item->folderContent, $write, $index); - } - else - { - $page = $write->getFileWithPath('content' . $item->path); - $pageArray = $this->getPageContentArray($page, $item->urlAbs); - $index[$pageArray['url']] = $pageArray; - } - } - return $index; - } - - private function getPageContentArray($page, $url) - { - $parts = explode("\n", $page, 2); - - # get the title / headline - $title = trim($parts[0], '# '); - $title = str_replace(["\r\n", "\n", "\r"],' ', $title); - - # get and cleanup the content - $content = $parts[1]; - $content = strip_tags($content); - $content = str_replace(["\r\n", "\n", "\r"],' ', $content); - - $pageContent = [ - 'title' => $title, - 'content' => $content, - 'url' => $url - ]; - - return $pageContent; - } -} \ No newline at end of file diff --git a/plugins/search/public/lunr-licence.md b/plugins/search/public/lunr-licence.md deleted file mode 100644 index 93bece9..0000000 --- a/plugins/search/public/lunr-licence.md +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) 2013 by Oliver Nightingale - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file diff --git a/plugins/search/public/lunr.min.js b/plugins/search/public/lunr.min.js deleted file mode 100644 index 34b279d..0000000 --- a/plugins/search/public/lunr.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.6 - * Copyright (C) 2019 Oliver Nightingale - * @license MIT - */ -!function(){var e=function(t){var r=new e.Builder;return r.pipeline.add(e.trimmer,e.stopWordFilter,e.stemmer),r.searchPipeline.add(e.stemmer),t.call(r,r),r.build()};e.version="2.3.6",e.utils={},e.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),e.utils.asString=function(e){return void 0===e||null===e?"":e.toString()},e.utils.clone=function(e){if(null===e||void 0===e)return e;for(var t=Object.create(null),r=Object.keys(e),i=0;i0){var c=e.utils.clone(r)||{};c.position=[a,l],c.index=s.length,s.push(new e.Token(i.slice(a,o),c))}a=o+1}}return s},e.tokenizer.separator=/[\s\-]+/,e.Pipeline=function(){this._stack=[]},e.Pipeline.registeredFunctions=Object.create(null),e.Pipeline.registerFunction=function(t,r){r in this.registeredFunctions&&e.utils.warn("Overwriting existing registered function: "+r),t.label=r,e.Pipeline.registeredFunctions[t.label]=t},e.Pipeline.warnIfFunctionNotRegistered=function(t){var r=t.label&&t.label in this.registeredFunctions;r||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 r=new e.Pipeline;return t.forEach(function(t){var i=e.Pipeline.registeredFunctions[t];if(!i)throw new Error("Cannot load unregistered function: "+t);r.add(i)}),r},e.Pipeline.prototype.add=function(){var t=Array.prototype.slice.call(arguments);t.forEach(function(t){e.Pipeline.warnIfFunctionNotRegistered(t),this._stack.push(t)},this)},e.Pipeline.prototype.after=function(t,r){e.Pipeline.warnIfFunctionNotRegistered(r);var i=this._stack.indexOf(t);if(i==-1)throw new Error("Cannot find existingFn");i+=1,this._stack.splice(i,0,r)},e.Pipeline.prototype.before=function(t,r){e.Pipeline.warnIfFunctionNotRegistered(r);var i=this._stack.indexOf(t);if(i==-1)throw new Error("Cannot find existingFn");this._stack.splice(i,0,r)},e.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);t!=-1&&this._stack.splice(t,1)},e.Pipeline.prototype.run=function(e){for(var t=this._stack.length,r=0;r1&&(se&&(r=n),s!=e);)i=r-t,n=t+Math.floor(i/2),s=this.elements[2*n];return s==e?2*n:s>e?2*n:sa?l+=2:o==a&&(t+=r[u+1]*i[l+1],u+=2,l+=2);return t},e.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},e.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),t=1,r=0;t0){var o,a=s.str.charAt(0);a in s.node.edges?o=s.node.edges[a]:(o=new e.TokenSet,s.node.edges[a]=o),1==s.str.length&&(o["final"]=!0),n.push({node:o,editsRemaining:s.editsRemaining,str:s.str.slice(1)})}if(0!=s.editsRemaining){if("*"in s.node.edges)var u=s.node.edges["*"];else{var u=new e.TokenSet;s.node.edges["*"]=u}if(0==s.str.length&&(u["final"]=!0),n.push({node:u,editsRemaining:s.editsRemaining-1,str:s.str}),s.str.length>1&&n.push({node:s.node,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)}),1==s.str.length&&(s.node["final"]=!0),s.str.length>=1){if("*"in s.node.edges)var l=s.node.edges["*"];else{var l=new e.TokenSet;s.node.edges["*"]=l}1==s.str.length&&(l["final"]=!0),n.push({node:l,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)})}if(s.str.length>1){var c,h=s.str.charAt(0),d=s.str.charAt(1);d in s.node.edges?c=s.node.edges[d]:(c=new e.TokenSet,s.node.edges[d]=c),1==s.str.length&&(c["final"]=!0),n.push({node:c,editsRemaining:s.editsRemaining-1,str:h+s.str.slice(2)})}}}return i},e.TokenSet.fromString=function(t){for(var r=new e.TokenSet,i=r,n=0,s=t.length;n=e;t--){var r=this.uncheckedNodes[t],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r["char"]]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}},e.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},e.Index.prototype.search=function(t){return this.query(function(r){var i=new e.QueryParser(t,r);i.parse()})},e.Index.prototype.query=function(t){for(var r=new e.Query(this.fields),i=Object.create(null),n=Object.create(null),s=Object.create(null),o=Object.create(null),a=Object.create(null),u=0;u1?this._b=1:this._b=e},e.Builder.prototype.k1=function(e){this._k1=e},e.Builder.prototype.add=function(t,r){var i=t[this._ref],n=Object.keys(this._fields);this._documents[i]=r||{},this.documentCount+=1;for(var s=0;s=this.length)return e.QueryLexer.EOS;var t=this.str.charAt(this.pos);return this.pos+=1,t},e.QueryLexer.prototype.width=function(){return this.pos-this.start},e.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},e.QueryLexer.prototype.backup=function(){this.pos-=1},e.QueryLexer.prototype.acceptDigitRun=function(){var t,r;do t=this.next(),r=t.charCodeAt(0);while(r>47&&r<58);t!=e.QueryLexer.EOS&&this.backup()},e.QueryLexer.prototype.more=function(){return this.pos1&&(t.backup(),t.emit(e.QueryLexer.TERM)),t.ignore(),t.more())return e.QueryLexer.lexText},e.QueryLexer.lexEditDistance=function(t){return t.ignore(),t.acceptDigitRun(),t.emit(e.QueryLexer.EDIT_DISTANCE),e.QueryLexer.lexText},e.QueryLexer.lexBoost=function(t){return t.ignore(),t.acceptDigitRun(),t.emit(e.QueryLexer.BOOST),e.QueryLexer.lexText},e.QueryLexer.lexEOS=function(t){t.width()>0&&t.emit(e.QueryLexer.TERM)},e.QueryLexer.termSeparator=e.tokenizer.separator,e.QueryLexer.lexText=function(t){for(;;){var r=t.next();if(r==e.QueryLexer.EOS)return e.QueryLexer.lexEOS;if(92!=r.charCodeAt(0)){if(":"==r)return e.QueryLexer.lexField;if("~"==r)return t.backup(),t.width()>0&&t.emit(e.QueryLexer.TERM),e.QueryLexer.lexEditDistance;if("^"==r)return t.backup(),t.width()>0&&t.emit(e.QueryLexer.TERM),e.QueryLexer.lexBoost;if("+"==r&&1===t.width())return t.emit(e.QueryLexer.PRESENCE),e.QueryLexer.lexText;if("-"==r&&1===t.width())return t.emit(e.QueryLexer.PRESENCE),e.QueryLexer.lexText;if(r.match(e.QueryLexer.termSeparator))return e.QueryLexer.lexTerm}else t.escapeCharacter()}},e.QueryParser=function(t,r){this.lexer=new e.QueryLexer(t),this.query=r,this.currentClause={},this.lexemeIdx=0},e.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var t=e.QueryParser.parseClause;t;)t=t(this);return this.query},e.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},e.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},e.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},e.QueryParser.parseClause=function(t){var r=t.peekLexeme();if(void 0!=r)switch(r.type){case e.QueryLexer.PRESENCE:return e.QueryParser.parsePresence;case e.QueryLexer.FIELD:return e.QueryParser.parseField;case e.QueryLexer.TERM:return e.QueryParser.parseTerm;default:var i="expected either a field or a term, found "+r.type;throw r.str.length>=1&&(i+=" with value '"+r.str+"'"),new e.QueryParseError(i,r.start,r.end)}},e.QueryParser.parsePresence=function(t){var r=t.consumeLexeme();if(void 0!=r){switch(r.str){case"-":t.currentClause.presence=e.Query.presence.PROHIBITED;break;case"+":t.currentClause.presence=e.Query.presence.REQUIRED;break;default:var i="unrecognised presence operator'"+r.str+"'";throw new e.QueryParseError(i,r.start,r.end)}var n=t.peekLexeme();if(void 0==n){var i="expecting term or field, found nothing";throw new e.QueryParseError(i,r.start,r.end)}switch(n.type){case e.QueryLexer.FIELD:return e.QueryParser.parseField;case e.QueryLexer.TERM:return e.QueryParser.parseTerm;default:var i="expecting term or field, found '"+n.type+"'";throw new e.QueryParseError(i,n.start,n.end)}}},e.QueryParser.parseField=function(t){var r=t.consumeLexeme();if(void 0!=r){if(t.query.allFields.indexOf(r.str)==-1){var i=t.query.allFields.map(function(e){return"'"+e+"'"}).join(", "),n="unrecognised field '"+r.str+"', possible fields: "+i;throw new e.QueryParseError(n,r.start,r.end)}t.currentClause.fields=[r.str];var s=t.peekLexeme();if(void 0==s){var n="expecting term, found nothing";throw new e.QueryParseError(n,r.start,r.end)}switch(s.type){case e.QueryLexer.TERM:return e.QueryParser.parseTerm;default:var n="expecting term, found '"+s.type+"'";throw new e.QueryParseError(n,s.start,s.end)}}},e.QueryParser.parseTerm=function(t){var r=t.consumeLexeme();if(void 0!=r){t.currentClause.term=r.str.toLowerCase(),r.str.indexOf("*")!=-1&&(t.currentClause.usePipeline=!1);var i=t.peekLexeme();if(void 0==i)return void t.nextClause();switch(i.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+i.type+"'";throw new e.QueryParseError(n,i.start,i.end)}}},e.QueryParser.parseEditDistance=function(t){var r=t.consumeLexeme();if(void 0!=r){var i=parseInt(r.str,10);if(isNaN(i)){var n="edit distance must be numeric";throw new e.QueryParseError(n,r.start,r.end)}t.currentClause.editDistance=i;var s=t.peekLexeme();if(void 0==s)return void t.nextClause();switch(s.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+s.type+"'";throw new e.QueryParseError(n,s.start,s.end)}}},e.QueryParser.parseBoost=function(t){var r=t.consumeLexeme();if(void 0!=r){var i=parseInt(r.str,10);if(isNaN(i)){var n="boost must be numeric";throw new e.QueryParseError(n,r.start,r.end)}t.currentClause.boost=i;var s=t.peekLexeme();if(void 0==s)return void t.nextClause();switch(s.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+s.type+"'";throw new e.QueryParseError(n,s.start,s.end)}}},function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.lunr=t()}(this,function(){return e})}(); diff --git a/plugins/search/public/search.css b/plugins/search/public/search.css deleted file mode 100644 index 4979af4..0000000 --- a/plugins/search/public/search.css +++ /dev/null @@ -1,64 +0,0 @@ -.searchContainer{ - overflow: hidden; - width: 100%; - vertical-align: middle; - white-space: nowrap; -} -.searchContainer input{ - width: 100%; - height: 50px; - border: 1px solid #ddd; - font-size: 1rem; - float: left; - padding-left: 15px; - border-radius: 2px; - box-sizing:border-box; -} -.searchContainer button{ - border-top-right-radius: 2px; - border-bottom-right-radius: 2px; - border: none; - background: #232833; - height: 50px; - width: 50px; - color: #fff; - font-size: 10pt; - margin-left: -50px; -} -.searchContainer button:hover,.searchContainer button:focus, .searchContainer button:active{ - cursor: pointer; -} - -#searchresult{ -} -.resultwrapper{ -} -button#closeSearchResult{ - position: absolute; - right: 0px; - top: 0px; - margin: 10px; - border: none; - border-radius: 2px; - font-size: 1rem; - color: #fff; - background: #000; - padding: 15px; -} -button#closeSearchResult:hover,#closeSearchResult:focus{ - cursor: pointer; -} -.resultlist{ - margin: 0px; - padding: 0px; - list-style:none; -} -.resultitem{ - -} -.resultheader{ - -} -.resultsnippet{ - -} \ No newline at end of file diff --git a/plugins/search/public/search.js b/plugins/search/public/search.js deleted file mode 100644 index 639ab18..0000000 --- a/plugins/search/public/search.js +++ /dev/null @@ -1,115 +0,0 @@ -var searchField = document.getElementById("searchField"); -var searchButton = document.getElementById("searchButton"); - -if(searchField && searchButton) -{ - var searchIndex = false; - var documents = false; - var holdcontent = false; - var contentwrapper = false; - - searchField.addEventListener("focus", function(event){ - - if(!searchIndex) - { - myaxios.get('/indexrs51gfe2o2') - .then(function (response) { - - documents = JSON.parse(response.data); - - searchIndex = lunr(function() { - this.ref("id"); - this.field("title", { boost: 10 }); - this.field("content"); - for (var key in documents){ - this.add({ - "id": documents[key].url, - "title": documents[key].title, - "content": documents[key].content - }); - } - }); - - }) - .catch(function (error) {}); - } - }); - - searchButton.addEventListener("click", function(event){ - event.preventDefault(); - - var term = document.getElementById('searchField').value; - var results = searchIndex.search(term); - - var resultPages = results.map(function (match) { - return documents[match.ref]; - }); - - resultsString = "

    Result for " + term + "

    "; - resultsString += ""; - resultsString += "
      "; - resultPages.forEach(function (r) { - resultsString += "
    • "; - resultsString += "

      " + r.title + "

      "; - resultsString += "
      " + r.content.substring(0, 200) + " ...
      "; - resultsString += "
    • " - }); - resultsString += "
    "; - - if(!holdcontent) - { - contentwrapper = document.getElementById("searchresult").parentNode; - holdcontent = contentwrapper.innerHTML; - } - - contentwrapper.innerHTML = resultsString; - - document.getElementById("closeSearchResult").addEventListener("click", function(event){ - contentwrapper.innerHTML = holdcontent; - }); - - }, false); -} - -/* -var searchIndex = lunr(function() { - this.ref("id"); - this.field("title", { boost: 10 }); - this.field("content"); - for (var key in window.pages) { - this.add({ - "id": key, - "title": pages[key].title, - "content": pages[key].content - }); - } -}); - -function getQueryVariable(variable) { - var query = window.location.search.substring(1); - var vars = query.split("&"); - for (var i = 0; i < vars.length; i++) { - var pair = vars[i].split("="); - if (pair[0] === variable) { - return decodeURIComponent(pair[1].replace(/\+/g, "%20")); - } - } -} - -var searchTerm = getQueryVariable("q"); -// creation of searchIndex from earlier example -var results = searchIndex.search(searchTerm); -var resultPages = results.map(function (match) { - return pages[match.ref]; -}); - -// resultPages from previous example -resultsString = ""; -resultPages.forEach(function (r) { - resultsString += "
  • "; - resultsString += "

    " + r.title + "

    "; - resultsString += "
    " + r.content.substring(0, 200) + "
    "; - resultsString += "
  • " -}); -document.querySelector("#search-results").innerHTML = resultsString; -*/ \ No newline at end of file diff --git a/plugins/search/search.php b/plugins/search/search.php deleted file mode 100644 index 8e93719..0000000 --- a/plugins/search/search.php +++ /dev/null @@ -1,128 +0,0 @@ - 'onsettingsLoaded', - 'onContentArrayLoaded' => 'onContentArrayLoaded', - 'onPageReady' => 'onPageReady', - 'onPagePublished' => 'onPagePublished', - 'onPageUnpublished' => 'onPageUnpublished', - 'onPageSorted' => 'onPageSorted', - 'onPageDeleted' => 'onPageDeleted', - ); - } - - # get search.json with route - # update search.json on publish - - public static function addNewRoutes() - { - # the route for the api calls - return array( - array( - 'httpMethod' => 'get', - 'route' => '/indexrs51gfe2o2', - 'class' => 'Plugins\search\index:index' - ), - ); - } - - public function onSettingsLoaded($settings) - { - $this->settings = $settings->getData(); - } - - # at any of theses events, delete the old search index - public function onPagePublished($item) - { - $this->deleteSearchIndex(); - } - public function onPageUnpublished($item) - { - $this->deleteSearchIndex(); - } - public function onPageSorted($inputParams) - { - $this->deleteSearchIndex(); - } - public function onPageDeleted($item) - { - $this->deleteSearchIndex(); - } - - private function deleteSearchIndex() - { - $write = new Write(); - - # store the index file here - $write->deleteFileWithPath('cache' . DIRECTORY_SEPARATOR . 'index.json'); - } - - public function onContentArrayLoaded($contentArray) - { - # get content array - $content = $contentArray->getData(); - $settings = $this->getPluginSettings('search'); - $salt = "asPx9Derf2"; - - # activate axios and vue in frontend - $this->activateAxios(); - $this->activateVue(); - - # add the css and vue application - $this->addCSS('/search/public/search.css'); - $this->addJS('/search/public/lunr.min.js'); - $this->addJS('/search/public/search.js'); - - # simple security for first request - $secret = time(); - $secret = substr($secret,0,-1); - $secret = md5($secret . $salt); - - # simple csrf protection with a session for long following requests - if (session_status() == PHP_SESSION_NONE) { - session_start(); - } - - $length = 32; - $token = substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $length); - $_SESSION['search'] = $token; - $_SESSION['search-expire'] = time() + 1300; # 60 seconds * 30 minutes - - # create div for vue app - $search = '
    '; - - # create content type - $search = Array - ( - 'rawHtml' => $search, - 'allowRawHtmlInSafeMode' => true, - 'autobreak' => 1 - ); - - $content[] = $search; - - $contentArray->setData($content); - } - - public function onPageReady($page) - { - $pageData = $page->getData($page); - - $pageData['widgets']['search'] = '
    '. - ''. - ''. - '
    '; - $page->setData($pageData); - } -} \ No newline at end of file diff --git a/plugins/search/search.yaml b/plugins/search/search.yaml deleted file mode 100644 index d47f64f..0000000 --- a/plugins/search/search.yaml +++ /dev/null @@ -1,8 +0,0 @@ -name: Search -version: 1.0.0 -description: Add a search to your website with lunr.js. -author: Trendschau -homepage: https://typemill.net -licence: MIT -paypal: https://paypal.me/typemill -amount: 10 \ No newline at end of file diff --git a/plugins/search/search.zip b/plugins/search/search.zip deleted file mode 100644 index af82cbd..0000000 Binary files a/plugins/search/search.zip and /dev/null differ