diff --git a/pwiki/page.js b/pwiki/page.js index 6538b53..a2cbe5c 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -427,20 +427,22 @@ object.Constructor('BasePage', { //*/ resolve: relMatchProxy('resolve'), - - delete: async function(path='.', base=true){ - if(path === true || path === false){ - base = path - path = '.' } - var page = this.get(path) - if(page.isPattern){ - base - && this.__delete__(this.path.split('*')[0]) - for(var p of await this.get('path').raw){ - this.__delete__(p) } - } else { - this.__delete__(path) } - return this }, + delete: types.event.Event('delete', + async function(handle, path='.', base=true){ + handle(false) + if(path === true || path === false){ + base = path + path = '.' } + var page = this.get(path) + if(page.isPattern){ + base + && this.__delete__(this.path.split('*')[0]) + for(var p of await this.get('path').raw){ + this.__delete__(p) } + } else { + this.__delete__(path) } + handle() + return this }), // XXX should these be implemented here or proxy to .store??? // XXX do we sanity check to no not contain '*'??? copy: async function(to, base=true){ @@ -687,8 +689,9 @@ object.Constructor('BasePage', { // ...right now this will write what-ever is given, even if it // will never be explicitly be accessible... // XXX sync/async??? - update: function(...data){ - return Object.assign(this, ...data) }, + update: types.event.Event('update', + function(_, ...data){ + return Object.assign(this, ...data) }), // XXX should this take an options/dict argument???? __init__: function(path, referrer, store){ @@ -1359,7 +1362,7 @@ object.Constructor('Page', BasePage, { text = typeof(text) == 'string' ? [...this.__parser__.group(this, text+'', 'macro')] : text - var join + var join, itext var iargs = {} // stored macros... @@ -1383,7 +1386,7 @@ object.Constructor('Page', BasePage, { // XXX is there a point in overloading text??? text = text.length > 0 ? text - : itext + : itext ?? text var sort = (args.sort ?? iargs.sort ?? '') @@ -1441,7 +1444,7 @@ object.Constructor('Page', BasePage, { seen: state.seen, depends, renderer: state.renderer, - macros: args.inheritmacros ? + macros: inheritmacros ? {__proto__: macros} : {}, } @@ -2102,7 +2105,9 @@ module.System = {
@source(./title) 🛈 - × + ×
@include("./tree:$ARGS") diff --git a/pwiki/parser.js b/pwiki/parser.js index b1a2a9c..f401025 100755 --- a/pwiki/parser.js +++ b/pwiki/parser.js @@ -35,7 +35,7 @@ module.BaseParser = { // MACRO_ARGS: ['(\\s*(',[ // arg='val' | arg="val" | arg=val - '(?[a-z-]+)\\s*=\\s*(?'+([ + '(?[a-z:-]+)\\s*=\\s*(?'+([ // XXX CHROME/NODE BUG: this does not work yet... //'\\s+(?[\'"])[^\\k]*\\k', '"(?(\\"|[^"])*?)"', diff --git a/pwiki/store/base.js b/pwiki/store/base.js index 5028caf..0588236 100755 --- a/pwiki/store/base.js +++ b/pwiki/store/base.js @@ -276,7 +276,7 @@ module.BaseStore = { return data }, remove: async function(data, path){ var {tags, paths} = await data - for(var tag of paths[path]){ + for(var tag of paths[path] ?? []){ tags[tag].delete(path) } return data }, }), get tags(){ @@ -609,8 +609,11 @@ module.BaseStore = { // ...this could be a sign of problems with index -- needs more // tought... update: types.event.Event('update', - function(handler, path, data, mode='update'){ - return this.__update(...[...arguments].slice(1)) }), + async function(handler, path, data, mode='update'){ + handler(false) + var res = await this.__update(...[...arguments].slice(1)) + handler() + return res }), __delete__: async function(path){ delete this.data[path] }, @@ -625,8 +628,11 @@ module.BaseStore = { this.index('remove', path) } return this }, delete: types.event.Event('delete', - function(handler, path){ - return this.__delete(path) }), + async function(handler, path){ + handler(false) + var res = await this.__delete(path) + handler() + return res }), // XXX NEXT might be a good idea to have an API to move pages from // current store up the chain... diff --git a/pwiki2.html b/pwiki2.html index b411a3c..54a2741 100755 --- a/pwiki2.html +++ b/pwiki2.html @@ -97,7 +97,7 @@ a:hover { /* Spinner... */ .spinner { - position: absolute; + position: fixed; display: flex; text-align: center; left: 50%; @@ -411,6 +411,7 @@ require(['./browser'], function(browser){ // when the hash is actually changed... for(var lnk of this.dom.querySelectorAll(`a[href="${location.hash}"]`)){ lnk.addEventListener('click', refresh) } }) + .delete(refresh) // handle special file updates... // NOTE: the actual updates are done .navigate(..) diff --git a/pwiki2.js b/pwiki2.js index b4c732b..d742c6d 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -18,6 +18,8 @@ * - CLI - * * +* XXX macros: add @defmacro( ..) to be exactly as @macro( ..) +* but defines a @(..) macro... * XXX BUG: parser: * This will break: * await pwiki.parse('@source(.)')