Merge branch 'master' of github.com:flynx/pWiki

This commit is contained in:
Alex A. Naanou 2022-09-14 12:59:53 +03:00
commit 869cb08cba
4 changed files with 41 additions and 59 deletions

View File

@ -1911,20 +1911,19 @@ module.System = {
// page actions... // page actions...
// //
/* XXX broken... // XXX broken...
// XXX this does not work as energetic... // XXX this does not work as energetic...
// XXX for some reason this is called twice...
time: async function(){ time: async function(){
var t = Date.now() var t = Date.now()
var text = await this.get('../_text').text var text = await this.get('../_text').text
var time = Date.now() - t var time = Date.now() - t
console.log('RENDER TIME:', time) console.log('RENDER TIME:', time)
return object.doc` return object.doc`
Time to render: ${time}ms <br> Time to render: ${time}ms <br>
<ht> <ht>
${text}`}, ${text}`},
//*/ //*/
// XXX EXPERIMENTAL -- page types... // XXX EXPERIMENTAL -- page types...
@ -2011,8 +2010,6 @@ module.Test = {
// XXX do we support this??? // XXX do we support this???
//'list/action': function(){ //'list/action': function(){
// return [...'abcdef'] }, // return [...'abcdef'] },
// XXX BUG CHROME: this hangs under chrome...
// (see: pwiki2.js)
'list/generator': function*(){ 'list/generator': function*(){
yield* [...'abcdef'] }, yield* [...'abcdef'] },
'list/static': { 'list/static': {

View File

@ -334,16 +334,17 @@ module.BaseStore = {
args = pwpath.joinArgs('', args) args = pwpath.joinArgs('', args)
// NOTE: we are matching full paths only here so leading and // NOTE: we are matching full paths only here so leading and
// trainling '/' are optional... // trainling '/' are optional...
// NOTE: we ensure that we match full names and always split var pattern = new RegExp(`^\\/?`
// at '/' only... +RegExp.quoteRegExp(
var pattern = new RegExp(`^\\/?${ // remove leading/trailing '/'
path path.replace(/^\/|\/$/g, ''))
.replace(/^\/|\/$/g, '') // pattern: **
.replace(/\//g, '\\/') .replace(/\\\*\\\*/g, '(.*)')
//.replace(/\*\*/g, '.*') // pattern: *
.replace(/([\\\/]?)\*\*/g, '($1.*)') // NOTE: we are prepping the leading '.' of a pattern
.replace(/(?<=^|[\\\/]+|[^.])\*/g, '[^\\/]*') // dir for hidden tests...
}(?=[\\\\\/]|$)`) .replace(/(^|\\\/+)(\\\.|)([^\/]*)\\\*/g, '$1$2($3[^\\/]*)')
+'(?=[\\/]|$)', 'g')
/*/ XXX CACHED.... /*/ XXX CACHED....
var name = pwpath.basename(path) var name = pwpath.basename(path)
return [...(name.includes('*') ? return [...(name.includes('*') ?
@ -359,14 +360,17 @@ module.BaseStore = {
// skip metadata paths... // skip metadata paths...
if(p.includes('*')){ if(p.includes('*')){
return res } return res }
/*/ XXX HIDE this is wrong -- need to check for var m = [...p.matchAll(pattern)]
// hidden paths within the match... m.length > 0
if(pwpath.basename(p)[0] == '.' && (!all ?
&& !all){ // test if we need to hide things....
return res } m.reduce(function(res, m){
//*/ return res === false ?
var m = p.match(pattern) res
m : !/(^\.|[\\\/]\.)/.test(m[1])
}, true)
: true)
&& (m = m[0])
&& (!strict && (!strict
|| m[0] == p) || m[0] == p)
&& res.add( && res.add(
@ -464,9 +468,6 @@ module.BaseStore = {
// this can be the result of matching a/* in a a/b/c // this can be the result of matching a/* in a a/b/c
// and returning a a/b which can be undefined... // and returning a a/b which can be undefined...
return that.get(p, strict) }) 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) : (await this.__get__(path)
?? ((this.next || {}).__get__ ?? ((this.next || {}).__get__
&& this.next.get(path, strict))) }, && this.next.get(path, strict))) },

View File

@ -166,6 +166,7 @@ require.config({
document.pwikiloaded = new Event('pwikiloaded') document.pwikiloaded = new Event('pwikiloaded')
REFRESH_DELAY = 20
// start loading pWiki... // start loading pWiki...
require(['./browser'], function(browser){ require(['./browser'], function(browser){
@ -186,8 +187,9 @@ require(['./browser'], function(browser){
: '/'+path : '/'+path
startSpinner() startSpinner()
// NOTE: setTimeout(..) to allow the spinner to start... // NOTE: setTimeout(..) to allow the spinner to start...
// NOTE: this seems not to work if the REFRESH_DELAY is too small...
setTimeout(function(){ setTimeout(function(){
pwiki.location = [path, hash] }, 0) }) pwiki.location = [path, hash] }, REFRESH_DELAY) })
pwiki pwiki
.onBeforeNavigate(function(){ .onBeforeNavigate(function(){
saveNow() }) saveNow() })
@ -226,7 +228,7 @@ require(['./browser'], function(browser){
lnk.addEventListener('click', function(evt){ lnk.addEventListener('click', function(evt){
startSpinner() startSpinner()
setTimeout(function(){ setTimeout(function(){
that.refresh() }, 0) }) } }) that.refresh() }, REFRESH_DELAY) }) } })
// wait for stuff to finish... // wait for stuff to finish...
browser.setup.then(function(){ browser.setup.then(function(){

View File

@ -1,18 +1,14 @@
/********************************************************************** /**********************************************************************
* *
* *
* XXX BUG: .hide_paths: * XXX BUG:
* - hidden dir should hide all the children -- BROKEN * /System/info
* (see /.hidden/suppage) * and:
* - listing a hidden subtree should work regardless of :all -- BROKEN * /System/info/_view
* (see: /.hidden/tree) * are not the same...
* ...bug likely in .text
* XXX might also be a good idea to investigate a .tree directory index * XXX might also be a good idea to investigate a .tree directory index
* as a supplement to .paths() * 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 Q: can we access fs from a pwa???
* XXX start writing docs in pwiki * XXX start writing docs in pwiki
* - WYSIWYG markdown editor/viewer (ASAP) * - WYSIWYG markdown editor/viewer (ASAP)
@ -62,20 +58,6 @@
* i.e. a way to pass tags through path... * i.e. a way to pass tags through path...
* /some/path:tags=a,b,c * /some/path:tags=a,b,c
* XXX FEATURE images... * 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?? * XXX rename??
* System -> .system * System -> .system
* Config -> .pwiki * Config -> .pwiki