mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 10:00:08 +00:00
making things a bit more intuitive -- location/argstr actions now inherit parent arguments by default...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c4b77f231f
commit
1e32383c26
@ -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.:
|
||||
// <a href="#@source(./location)">@source(./path)</a>
|
||||
// i.e. do:
|
||||
// @source(./location)
|
||||
// instead of (current):
|
||||
// <a href="#@source(./location:$ARGS)">@source(./path)</a>
|
||||
// @source(./location:$ARGS)
|
||||
text: object.doc`
|
||||
<slot name="header">
|
||||
<a href="#/list">☰</a>
|
||||
<a href="#@source(./location)">@source(./path)</a>
|
||||
@source(./location)
|
||||
<a href="#@source(./path)/_edit">✎</a>
|
||||
</slot>
|
||||
<hr>
|
||||
|
||||
27
pwiki2.js
27
pwiki2.js
@ -1,11 +1,28 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
*
|
||||
* XXX can we avoid explicitly passing args to ./location ????
|
||||
* i.e.:
|
||||
* <a href="#@source(./location)">@source(./path)</a>
|
||||
* instead of (current):
|
||||
* <a href="#@source(./location:$ARGS)">@source(./path)</a>
|
||||
* 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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user