mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-17 08:31:38 +00:00
added basic full-text search support (flexsearch), still needs some work...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
8d0fcb5baa
commit
28fa71ff00
@ -5,6 +5,7 @@
|
|||||||
"license": "BSD",
|
"license": "BSD",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@toast-ui/editor": "^3.2.0",
|
"@toast-ui/editor": "^3.2.0",
|
||||||
|
"flexsearch": "^0.7.31",
|
||||||
"glob": "*",
|
"glob": "*",
|
||||||
"idb-keyval": "^6.2.0",
|
"idb-keyval": "^6.2.0",
|
||||||
"ig-actions": "*",
|
"ig-actions": "*",
|
||||||
|
|||||||
@ -2325,7 +2325,22 @@ module.System = {
|
|||||||
RecursionError: {
|
RecursionError: {
|
||||||
text: 'RECURSION ERROR: @source(../path)' },
|
text: 'RECURSION ERROR: @source(../path)' },
|
||||||
NotFoundError: {
|
NotFoundError: {
|
||||||
text: 'NOT FOUND ERROR: @source(./path)' },
|
//text: 'NOT FOUND ERROR: @source(./path)' },
|
||||||
|
text: object.doc`
|
||||||
|
<slot title/>
|
||||||
|
|
||||||
|
<p>NOT FOUND ERROR: @source(./path)</p>
|
||||||
|
|
||||||
|
<slot nested>
|
||||||
|
<div>
|
||||||
|
<b>Nested pages:</b><br>
|
||||||
|
<div style="padding-left: 30px">
|
||||||
|
<macro src="./*" join="<br>" else="@slot(nested)">
|
||||||
|
<a href="#@source(s ./path)">@source(./title)</a>
|
||||||
|
</macro>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</slot>` },
|
||||||
NotFoundTemplateError: {
|
NotFoundTemplateError: {
|
||||||
text: 'NOT FOUND TEMPLATE ERROR: @source(../path)' },
|
text: 'NOT FOUND TEMPLATE ERROR: @source(../path)' },
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,8 @@
|
|||||||
(function(require){ var module={} // make module AMD/node compatible...
|
(function(require){ var module={} // make module AMD/node compatible...
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
|
var flexsearch = require('flexsearch')
|
||||||
|
|
||||||
var object = require('ig-object')
|
var object = require('ig-object')
|
||||||
var types = require('ig-types')
|
var types = require('ig-types')
|
||||||
|
|
||||||
@ -296,6 +298,26 @@ module.BaseStore = {
|
|||||||
|
|
||||||
|
|
||||||
// XXX text search index (???)
|
// XXX text search index (???)
|
||||||
|
// XXX do we index .data.text or .raw or .text
|
||||||
|
__search: index.makeIndex('search',
|
||||||
|
async function(){
|
||||||
|
var index = new flexsearch.Index()
|
||||||
|
for(var path of (await this.paths)){
|
||||||
|
var text = (await this.get(path)).text
|
||||||
|
text
|
||||||
|
&& typeof(text) != 'function'
|
||||||
|
&& index.add(path, text) }
|
||||||
|
return index }, {
|
||||||
|
update: async function(data, path, update){
|
||||||
|
update.text
|
||||||
|
&& typeof(update.text) != 'function'
|
||||||
|
&& (await data).add(path, update.text)
|
||||||
|
return data },
|
||||||
|
remove: async function(data, path){
|
||||||
|
;(await data).remove(path)
|
||||||
|
return data }, }),
|
||||||
|
search: function(){
|
||||||
|
return this.__search().search(...arguments) },
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@ -234,6 +234,7 @@ require.config({
|
|||||||
'pouchdb': 'node_modules/pouchdb/dist/pouchdb',
|
'pouchdb': 'node_modules/pouchdb/dist/pouchdb',
|
||||||
'showdown': 'node_modules/showdown/dist/showdown',
|
'showdown': 'node_modules/showdown/dist/showdown',
|
||||||
'idb-keyval': 'node_modules/idb-keyval/dist/umd',
|
'idb-keyval': 'node_modules/idb-keyval/dist/umd',
|
||||||
|
'flexsearch': 'node_modules/flexsearch/dist/flexsearch.bundle',
|
||||||
}, ['ext-lib']),
|
}, ['ext-lib']),
|
||||||
},
|
},
|
||||||
packages: [
|
packages: [
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
* XXX ASAP start writing docs in pwiki
|
* XXX ASAP start writing docs in pwiki
|
||||||
* - minimal/functional editor - DONE
|
* - minimal/functional editor - DONE
|
||||||
* - WYSIWYG markdown editor/viewer (ASAP) -
|
* - WYSIWYG markdown editor/viewer (ASAP) -
|
||||||
* - transparent sync
|
* - transparent sync/backup
|
||||||
* - fs store/export in browser or a simple way to export/import...
|
* - fs store/export in browser or a simple way to export/import...
|
||||||
* ...can't seem to get it to work without asking for permission
|
* ...can't seem to get it to work without asking for permission
|
||||||
* on every startup (one more thing left to try, keeping the
|
* on every startup (one more thing left to try, keeping the
|
||||||
@ -17,6 +17,13 @@
|
|||||||
* - GUI -
|
* - GUI -
|
||||||
* - CLI -
|
* - CLI -
|
||||||
*
|
*
|
||||||
|
* XXX things that will help:
|
||||||
|
* - async render (infinite scroll + search + large pages)
|
||||||
|
* unresolved -> dom placeholder
|
||||||
|
* iterator prepends to placeholder
|
||||||
|
* when resolved/done remove placeholder
|
||||||
|
* -
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* XXX macro-vars: should the vars be defined as macro:<name> (current) or
|
* XXX macro-vars: should the vars be defined as macro:<name> (current) or
|
||||||
* simply as <name>???
|
* simply as <name>???
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user