diff --git a/NOTES b/NOTES old mode 100644 new mode 100755 diff --git a/pwiki/page.js b/pwiki/page.js index ea4c97b..e1e3adc 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -422,9 +422,7 @@ object.Constructor('BasePage', { // relative proxies to store... exists: relProxy('exists'), - //* XXX MATCH match: relMatchProxy('match'), - /*/ match: async function(path='.', strict=false){ if(path === true || path === false){ strict = path @@ -548,11 +546,6 @@ object.Constructor('BasePage', { : paths instanceof Promise ? await paths : [paths] - /*/ XXX MATCH - paths = paths.length == 0 ? - [await this.find(path)] - : paths - //*/ for(var path of paths){ yield this.get('/'+ path) } }, [Symbol.asyncIterator]: async function*(){ @@ -861,23 +854,23 @@ object.Constructor('Page', BasePage, { // XXX ASYNC make these support async page getters... macros: { __proto__: { // - // @([ ][ local]) - // @(name=[ default=][ local]) + // @([ ][ local]) + // @(name=[ else=][ local]) // - // @arg([ ][ local]) - // @arg(name=[ default=][ local]) + // @arg([ ][ local]) + // @arg(name=[ else=][ local]) // - // [ ][ local]/> - // [ default=][ local]/> + // [ ][ local]/> + // [ else=][ local]/> // // Resolution order: // - local // - .renderer // - .root // - // NOTE: default value is parsed when accessed... + // NOTE: else (default) value is parsed when accessed... arg: Macro( - ['name', 'default', ['local']], + ['name', 'else', ['local']], function(args){ var v = this.args[args.name] || (!args.local @@ -889,10 +882,10 @@ object.Constructor('Page', BasePage, { args.name : v return v - || (args.default - && this.parse(args.default)) }), + || (args['else'] + && this.parse(args['else'])) }), '': Macro( - ['name', 'default', ['local']], + ['name', 'else', ['local']], function(args){ return this.macros.arg.call(this, args) }), args: function(){ diff --git a/pwiki/store/base.js b/pwiki/store/base.js index 385c393..c593441 100755 --- a/pwiki/store/base.js +++ b/pwiki/store/base.js @@ -158,28 +158,6 @@ object.Constructor('JournalDB', { }) -var awaitOrDo = -module.awaitOrDo = -function(data, func){ - if(arguments.length > 2){ - data = [...arguments] - func = data.pop() - var promise = data - .reduce(function(res, e){ - return res - || e instanceof Promise }, false) - return promise ? - Promise.all(data) - .then(function(res){ - return func(...res) }) - : func(...data) - // single data item... - } else { - return data instanceof Promise ? - data.then(func) - : func(data) } } - - //--------------------------------------------------------------------- // Store... @@ -839,7 +817,7 @@ module.BaseStore = { var {path, args} = pwpath.splitArgs( pwpath.sanitize(path, 'string')) - return awaitOrDo( + return Promise.awaitOrRun( this.paths, function(paths){ return paths.includes(path) ? @@ -850,7 +828,7 @@ module.BaseStore = { find: function(path, strict=false){ var {path, args} = pwpath.splitArgs(path) args = pwpath.joinArgs('', args) - return awaitOrDo( + return Promise.awaitOrRun( this.names, function(names){ // build list of existing page candidates... diff --git a/pwiki2.js b/pwiki2.js index 614adda..c572991 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -38,22 +38,6 @@ * * * -* XXX sort: aliases (a-la imagegrid)??? -* XXX sort: revise how we store order... -* .metadata.order = [ .. ] -* .metadata.order_ = [ .. ] -* ... -* or: -* .metadata.order = { -* 'default': [ .. ], -* : [ .. ] -* ... -* } -* ...this would make updating order more complicated (i.e. require a fetch) -* Q: will it be a good idea to use the cache/index api??? -* XXX sort: might be a good idea to pre-sort (index) all the pages and -* simply reference that for sorts... -* ...this needs thought and weighing... * XXX macros: else/default macro args essentially mean the same thing, should we * unify them to use the same name??? * XXX parser: error handling: revise page quoting... @@ -284,6 +268,22 @@ * fixable (more general macro name pattern + ns matching) but I'm not * sure if this is worth it * ...see: .defmacro(..) +* XXX sort: revise how we store order... +* .metadata.order = [ .. ] +* .metadata.order_ = [ .. ] +* ... +* or: +* .metadata.order = { +* 'default': [ .. ], +* : [ .. ] +* ... +* } +* ...this would make updating order more complicated (i.e. require a fetch) +* Q: will it be a good idea to use the cache/index api??? +* XXX sort: aliases (a-la imagegrid)??? +* XXX sort/cache: might be a good idea to pre-sort (index) all the pages and +* simply reference that for sorts... +* ...this needs thought and weighing... * XXX EXPERIMENTAL DOC INHERIT_ARGS added a special-case... * as basename will get appended :$ARGS if no args are given... * ...this only applies to paths referring to the current context