diff --git a/pwiki/page.js b/pwiki/page.js index a96c368..ed94553 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -63,6 +63,7 @@ object.Constructor('BasePage', { 'path', 'name', 'dir', + 'argstr', 'title', 'resolved', 'rootpath', @@ -71,6 +72,13 @@ object.Constructor('BasePage', { 'ctime', 'mtime', ]), + // These actions will be default get :$ARGS appended if no args are + // explicitly given... + // XXX INHERIT_ARGS + actions_inherit_args: new Set([ + 'location', + 'argstr', + ]), // NOTE: this can be inherited... @@ -854,6 +862,11 @@ object.Constructor('Page', BasePage, { await base.parse(args.src, state)) if(!src){ return } + // XXX INHERIT_ARGS special-case: inherit args by default... + if(this.actions_inherit_args + && this.actions_inherit_args.has(pwpath.basename(src)) + && this.get(pwpath.dirname(src)).path == this.path){ + src += ':$ARGS' } var recursive = args.recursive ?? body var isolated = args.isolated var strict = args.strict @@ -972,6 +985,11 @@ object.Constructor('Page', BasePage, { src = src ? await base.parse(src, state) : src + // XXX INHERIT_ARGS special-case: inherit args by default... + if(this.actions_inherit_args + && this.actions_inherit_args.has(pwpath.basename(src)) + && this.get(pwpath.dirname(src)).path == this.path){ + src += ':$ARGS' } var expandactions = args.expandactions var depends = state.depends = @@ -1227,12 +1245,20 @@ object.Constructor('Page', BasePage, { [text, join] = state.macros[name] } } if(src){ + src = await base.parse(src, state) + // XXX INHERIT_ARGS special-case: inherit args by default... + if(this.actions_inherit_args + && this.actions_inherit_args.has(pwpath.basename(src)) + && this.get(pwpath.dirname(src)).path == this.path){ + src += ':$ARGS' } + join = _getBlock('join') ?? join join = join && await base.parse(join, state) - var match = this.get(await base.parse(src, state)) + //var match = this.get(await base.parse(src, state)) + var match = this.get(src) // NOTE: thie does not introduce a dependency on each // of the iterated pages, that is handled by the @@ -1744,14 +1770,14 @@ module.System = { // XXX /rootpath here is not relative -- makes reuse harder... _view: { // XXX can we avoid explicitly passing args to ./location ???? - // i.e.: - // @source(./path) + // i.e. do: + // @source(./location) // instead of (current): - // @source(./path) + // @source(./location:$ARGS) text: object.doc` - @source(./path) + @source(./location)
diff --git a/pwiki2.js b/pwiki2.js index 4511e52..d47be7f 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -1,11 +1,28 @@ /********************************************************************** * * -* XXX can we avoid explicitly passing args to ./location ???? -* i.e.: -* @source(./path) -* instead of (current): -* @source(./path) +* 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 +* page, i.e.: +* await pwiki +* .get('/page:x:y:z') +* // this will get the args... +* .parse('@source(./location)') +* +* await pwiki +* .get('/page:x:y:z') +* // this will not get the args -- different page... +* .parse('@source(./x/location)') +* +* await pwiki +* .get('/page:x:y:z') +* // this will get explicitly given empty args... +* .parse('@source(./location:)') +* +* special args that auto-inherit are given in .actions_inherit_args +* XXX this is currently implemented on the level of macro parsing, +* should this be in a more general way??? * XXX BUG: * /System/info * and: