mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-20 01:51:39 +00:00
refactoring and bugfixing...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
9a0b8d1ad2
commit
2cba0b91f0
@ -1551,36 +1551,37 @@ object.Constructor('Page', BasePage, {
|
|||||||
'no'
|
'no'
|
||||||
: value }
|
: value }
|
||||||
|
|
||||||
// XXX COUNT
|
|
||||||
// handle count...
|
// handle count...
|
||||||
// NOTE: this duplicates <store>.match(..)'s functionality
|
// NOTE: this duplicates <store>.match(..)'s functionality
|
||||||
// because we need to account for arbitrary macro
|
// because we need to account for arbitrary macro
|
||||||
// nesting that .match(..) does not know about...
|
// nesting that .match(..) does not know about...
|
||||||
// XXX we still end up with NaN in some cases...
|
// XXX revise var naming...
|
||||||
var count = pwpath.splitArgs(src).args.count
|
// XXX these can be overriden in nested macros...
|
||||||
if(count == 'inherit'
|
var count = match.args.count
|
||||||
&& !('macro:count' in vars)){
|
if(count){
|
||||||
|
var c =
|
||||||
|
count == 'inherit' ?
|
||||||
|
(!('macro:count' in vars) ?
|
||||||
|
this.args.count
|
||||||
|
: undefined)
|
||||||
|
: count
|
||||||
|
if(c !== undefined){
|
||||||
vars['macro:count'] =
|
vars['macro:count'] =
|
||||||
vars['macro:count']
|
isNaN(parseInt(c)) ?
|
||||||
?? parseInt(this.args.count) }
|
c
|
||||||
if(count
|
: parseInt(c)
|
||||||
&& count != 'inherit'){
|
vars['macro:index'] = 0 } }
|
||||||
vars['macro:count'] = parseInt(count) }
|
|
||||||
//*/
|
|
||||||
|
|
||||||
// expand matches...
|
// expand matches...
|
||||||
var first = true
|
var first = true
|
||||||
for await(var page of match.asPages(strict)){
|
for await(var page of match.asPages(strict)){
|
||||||
// XXX COUNT
|
|
||||||
// handle count...
|
// handle count...
|
||||||
if(vars['macro:count'] <= 0){
|
|
||||||
break }
|
|
||||||
if('macro:count' in vars){
|
if('macro:count' in vars){
|
||||||
var v = vars
|
if(vars['macro:count'] <= vars['macro:index']){
|
||||||
while(!v.hasOwnProperty('macro:count')){
|
break }
|
||||||
v = v.__proto__ }
|
object.sources(vars, 'macro:index')
|
||||||
v['macro:count']-- }
|
.shift()['macro:index']++ }
|
||||||
//*/
|
// output join between elements....
|
||||||
if(join && !first){
|
if(join && !first){
|
||||||
yield join }
|
yield join }
|
||||||
first = false
|
first = false
|
||||||
@ -1602,9 +1603,9 @@ object.Constructor('Page', BasePage, {
|
|||||||
text, _state), _state)
|
text, _state), _state)
|
||||||
} else {
|
} else {
|
||||||
yield this.__parser__.expand(page, text, state) } }
|
yield this.__parser__.expand(page, text, state) } }
|
||||||
// XXX COUNT
|
|
||||||
// cleanup...
|
// cleanup...
|
||||||
delete vars['macro:count']
|
delete vars['macro:count']
|
||||||
|
delete vars['macro:index']
|
||||||
// else...
|
// else...
|
||||||
if(first
|
if(first
|
||||||
&& (text || args['else'])){
|
&& (text || args['else'])){
|
||||||
@ -2311,8 +2312,7 @@ module.System = {
|
|||||||
<slot title/>
|
<slot title/>
|
||||||
<!--@var(count "@(count)")-->
|
<!--@var(count "@(count)")-->
|
||||||
|
|
||||||
<!--macro tree src="../*:$ARGS"-->
|
<macro tree src="../*:$ARGS">
|
||||||
<macro tree src="../*:$ARGS:count=inherit">
|
|
||||||
@var(path "@source(s ./path)")
|
@var(path "@source(s ./path)")
|
||||||
<div>
|
<div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
|
|||||||
14
pwiki2.js
14
pwiki2.js
@ -25,18 +25,12 @@
|
|||||||
* -
|
* -
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* XXX not yet sure why /tree's root macro needs to have count=inherit...
|
* XXX macro: macro:count / macro:index vars can be overridden by count/index
|
||||||
* for an example see:
|
* attributes....
|
||||||
* /Tests/MacroPageCountInheritTest:count=3
|
* ...this needs testing...
|
||||||
* ...adding :count=inherit after $ARGS fixes the issue...
|
|
||||||
* not sure why this works in this context:
|
|
||||||
* /Tests/MacroCountTest
|
|
||||||
* XXX should @macro(..) handle offset in the same manner as count???
|
* XXX should @macro(..) handle offset in the same manner as count???
|
||||||
* XXX BUG: @var(macro:count) can still be NaN in some cases...
|
|
||||||
* XXX BUG: count does not appear to affext /Test/list/generator and /Test/list/static...
|
* XXX BUG: count does not appear to affext /Test/list/generator and /Test/list/static...
|
||||||
* XXX macros: should vars and url args be unified???
|
* ...do we need to support this???
|
||||||
* ...likely no but need tho think about it some more...
|
|
||||||
* XXX should @quote(..)'s expandactions be on by default???
|
|
||||||
* XXX FEATURE store: mirror (slave) -- a way to hold data in one store
|
* XXX FEATURE store: mirror (slave) -- a way to hold data in one store
|
||||||
* and to mirror everything (async) to a separate store...
|
* and to mirror everything (async) to a separate store...
|
||||||
* example:
|
* example:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user