From 7505096dda9b9d0add901c5189ec992720c4e674 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 14 Sep 2022 03:16:26 +0300 Subject: [PATCH 1/5] reworked path pattern matching... Signed-off-by: Alex A. Naanou --- pwiki/store/base.js | 43 +++++++++++++++++++++++++++---------------- pwiki2.js | 5 ----- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/pwiki/store/base.js b/pwiki/store/base.js index 8cc427c..e0a406c 100755 --- a/pwiki/store/base.js +++ b/pwiki/store/base.js @@ -334,16 +334,17 @@ module.BaseStore = { args = pwpath.joinArgs('', args) // NOTE: we are matching full paths only here so leading and // trainling '/' are optional... - // NOTE: we ensure that we match full names and always split - // at '/' only... - var pattern = new RegExp(`^\\/?${ - path - .replace(/^\/|\/$/g, '') - .replace(/\//g, '\\/') - //.replace(/\*\*/g, '.*') - .replace(/([\\\/]?)\*\*/g, '($1.*)') - .replace(/(?<=^|[\\\/]+|[^.])\*/g, '[^\\/]*') - }(?=[\\\\\/]|$)`) + var pattern = new RegExp(`^\\/?` + +RegExp.quoteRegExp( + // remove leading/trailing '/' + path.replace(/^\/|\/$/g, '')) + // pattern: ** + .replace(/\\\*\\\*/g, '(.*)') + // pattern: * + // NOTE: we are prepping the leading '.' of a pattern + // dir for hidden tests... + .replace(/(^|\\\/+)(\\\.|)([^\/]*)\\\*/g, '$1$2($3[^\\/]*)') + +'(?=[\\/]|$)', 'g') /*/ XXX CACHED.... var name = pwpath.basename(path) return [...(name.includes('*') ? @@ -359,14 +360,24 @@ module.BaseStore = { // skip metadata paths... if(p.includes('*')){ return res } - /*/ XXX HIDE this is wrong -- need to check for - // hidden paths within the match... - if(pwpath.basename(p)[0] == '.' - && !all){ - return res } - //*/ + // XXX HIDE + var m = [...p.matchAll(pattern)] + m.length > 0 + && (!all ? + // test if we need to hide things.... + m.reduce(function(res, m){ + return res === false ? + res + // XXX if we are using a partial pattern this is wrong... + // i.e. something like 'x*' (TEST) + : !/(^\.|[\\\/]\.)/.test(m[1]) + }, true) + : true) + && (m = m[0]) + /*/ var m = p.match(pattern) m + //*/ && (!strict || m[0] == p) && res.add( diff --git a/pwiki2.js b/pwiki2.js index be89185..6f70e59 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -1,11 +1,6 @@ /********************************************************************** * * -* XXX BUG: .hide_paths: -* - hidden dir should hide all the children -- BROKEN -* (see /.hidden/suppage) -* - listing a hidden subtree should work regardless of :all -- BROKEN -* (see: /.hidden/tree) * XXX might also be a good idea to investigate a .tree directory index * as a supplement to .paths() * XXX BUG: changing the URL does not start the spinner... From d3c2832f8f815dc704ea28df8c31ac4bfd3c22a9 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 14 Sep 2022 03:19:44 +0300 Subject: [PATCH 2/5] cleanup... Signed-off-by: Alex A. Naanou --- pwiki/store/base.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pwiki/store/base.js b/pwiki/store/base.js index e0a406c..0dc7fbd 100755 --- a/pwiki/store/base.js +++ b/pwiki/store/base.js @@ -360,7 +360,6 @@ module.BaseStore = { // skip metadata paths... if(p.includes('*')){ return res } - // XXX HIDE var m = [...p.matchAll(pattern)] m.length > 0 && (!all ? @@ -368,16 +367,10 @@ module.BaseStore = { m.reduce(function(res, m){ return res === false ? res - // XXX if we are using a partial pattern this is wrong... - // i.e. something like 'x*' (TEST) : !/(^\.|[\\\/]\.)/.test(m[1]) }, true) : true) && (m = m[0]) - /*/ - var m = p.match(pattern) - m - //*/ && (!strict || m[0] == p) && res.add( From 0c1fdf4ca686ce922567b88d77ae17514459b410 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 14 Sep 2022 03:33:05 +0300 Subject: [PATCH 3/5] notes... Signed-off-by: Alex A. Naanou --- pwiki/page.js | 19 +++++++++---------- pwiki2.js | 6 ++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/pwiki/page.js b/pwiki/page.js index 068cb6f..2ea8132 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -1911,20 +1911,19 @@ module.System = { // page actions... // - /* XXX broken... + // XXX broken... // XXX this does not work as energetic... - // XXX for some reason this is called twice... time: async function(){ - var t = Date.now() - var text = await this.get('../_text').text - var time = Date.now() - t + var t = Date.now() + var text = await this.get('../_text').text + var time = Date.now() - t - console.log('RENDER TIME:', time) + console.log('RENDER TIME:', time) - return object.doc` - Time to render: ${time}ms
- - ${text}`}, + return object.doc` + Time to render: ${time}ms
+ + ${text}`}, //*/ // XXX EXPERIMENTAL -- page types... diff --git a/pwiki2.js b/pwiki2.js index 6f70e59..6c45fa5 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -1,6 +1,12 @@ /********************************************************************** * * +* XXX BUG: +* /System/info +* and: +* /System/info/_view +* are not the same... +* ...bug likely in .text * XXX might also be a good idea to investigate a .tree directory index * as a supplement to .paths() * XXX BUG: changing the URL does not start the spinner... From 0d8c91386a79bd9fe63d0ed6e85b1a0ad90001ec Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 14 Sep 2022 09:57:32 +0300 Subject: [PATCH 4/5] fixed loading spinner... Signed-off-by: Alex A. Naanou --- pwiki2.html | 6 ++++-- pwiki2.js | 5 ----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pwiki2.html b/pwiki2.html index ba60d99..653ed8c 100755 --- a/pwiki2.html +++ b/pwiki2.html @@ -166,6 +166,7 @@ require.config({ document.pwikiloaded = new Event('pwikiloaded') +REFRESH_DELAY = 20 // start loading pWiki... require(['./browser'], function(browser){ @@ -186,8 +187,9 @@ require(['./browser'], function(browser){ : '/'+path startSpinner() // NOTE: setTimeout(..) to allow the spinner to start... + // NOTE: this seems not to work if the REFRESH_DELAY is too small... setTimeout(function(){ - pwiki.location = [path, hash] }, 0) }) + pwiki.location = [path, hash] }, REFRESH_DELAY) }) pwiki .onBeforeNavigate(function(){ saveNow() }) @@ -226,7 +228,7 @@ require(['./browser'], function(browser){ lnk.addEventListener('click', function(evt){ startSpinner() setTimeout(function(){ - that.refresh() }, 0) }) } }) + that.refresh() }, REFRESH_DELAY) }) } }) // wait for stuff to finish... browser.setup.then(function(){ diff --git a/pwiki2.js b/pwiki2.js index 6c45fa5..0a4fe72 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -9,11 +9,6 @@ * ...bug likely in .text * XXX might also be a good idea to investigate a .tree directory index * as a supplement to .paths() -* XXX BUG: changing the URL does not start the spinner... -* chech: -* - url (hashchange) -* - click link -* - history back/foreward * XXX Q: can we access fs from a pwa??? * XXX start writing docs in pwiki * - WYSIWYG markdown editor/viewer (ASAP) From 3d06fda888df75e132ab4df366b71939fa7cb42f Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 14 Sep 2022 11:24:33 +0300 Subject: [PATCH 5/5] cleanup... Signed-off-by: Alex A. Naanou --- pwiki/page.js | 2 -- pwiki/store/base.js | 3 --- pwiki2.js | 14 -------------- 3 files changed, 19 deletions(-) diff --git a/pwiki/page.js b/pwiki/page.js index 2ea8132..58f4a4e 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -2010,8 +2010,6 @@ module.Test = { // XXX do we support this??? //'list/action': function(){ // return [...'abcdef'] }, - // XXX BUG CHROME: this hangs under chrome... - // (see: pwiki2.js) 'list/generator': function*(){ yield* [...'abcdef'] }, 'list/static': { diff --git a/pwiki/store/base.js b/pwiki/store/base.js index 0dc7fbd..e937d7d 100755 --- a/pwiki/store/base.js +++ b/pwiki/store/base.js @@ -468,9 +468,6 @@ module.BaseStore = { // this can be the result of matching a/* in a a/b/c // and returning a a/b which can be undefined... return that.get(p, strict) }) - // XXX BUG CHROME: this hangs on Chrome when getting a - // generator function... - // ...should not require any editing when bug fixed. : (await this.__get__(path) ?? ((this.next || {}).__get__ && this.next.get(path, strict))) }, diff --git a/pwiki2.js b/pwiki2.js index 0a4fe72..cba46f0 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -55,20 +55,6 @@ * i.e. a way to pass tags through path... * /some/path:tags=a,b,c * XXX FEATURE images... -* XXX BUG CHROME: can't .get(..) a generator... -* affected code: -* BaseStore's .get(..) -* bug report: -* https://bugs.chromium.org/p/chromium/issues/detail?id=1361981 -* when done test: -* .get('/test/list/generator').asPages() -* .get('/test/list/generator').raw -* .get('/test/list/generator').data -* .get('/test/list/generator').text -* potential temporaty fix: -* wrap all .__get__(..) call in an async function testing if -* it's return value is a generator function (return) or anything -* else (await)... * XXX rename?? * System -> .system * Config -> .pwiki