diff --git a/pwiki/page.js b/pwiki/page.js index dac18c4..038822e 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -1167,6 +1167,8 @@ object.Constructor('Page', BasePage, { // handle lists in pages (actions, ... etc.)... if(!page.isPattern){ var raw = await page.raw + if(raw == null){ + return } yield* raw instanceof Array ? raw .map(function(p){ @@ -1425,6 +1427,7 @@ module.System = {
@source(./name) + * ×
@source(./tree) @@ -1494,10 +1497,21 @@ module.System = { var p = this.get('..') return p.title ?? p.name }, - ctime: function(){ - return this.get('..').data.ctime ?? '' }, - mtime: function(){ - return this.get('..').data.mtime ?? '' }, + ctime: async function(){ + return (await this.get('..').data).ctime ?? '' }, + mtime: async function(){ + return (await this.get('..').data).mtime ?? '' }, + + // XXX EXPERIMENTAL... + type: async function(){ + // XXX also check if a page is a store... + return typeof(await this.get('..').data) == 'function' ? + 'action' + : 'page' }, + isAction: async function(){ + return typeof(await this.get('..').data) == 'function' ? + ['action'] + : undefined }, // utils... diff --git a/pwiki/parser.js b/pwiki/parser.js index 89d1fd9..5ecfdd1 100755 --- a/pwiki/parser.js +++ b/pwiki/parser.js @@ -221,6 +221,9 @@ module.BaseParser = { // NOTE: this internally uses page.macros' keys to generate the // lexing pattern. lex: function*(page, str){ + str = typeof(str) != 'string' ? + str+'' + : str // XXX we can't get .raw from the page without going async... //str = str // ?? page.raw @@ -325,7 +328,7 @@ module.BaseParser = { // XXX we can't get .raw from the page without going async... //lex = lex // ?? this.lex(page) - lex = typeof(lex) == 'string' ? + lex = typeof(lex) != 'object' ? this.lex(page, lex) : lex @@ -403,7 +406,7 @@ module.BaseParser = { ast = ast == null ? //this.group(page) this.group(page, await page.raw ?? '') - : typeof(ast) == 'string' ? + : typeof(ast) != 'object' ? this.group(page, ast) : ast instanceof types.Generator ? ast @@ -448,7 +451,7 @@ module.BaseParser = { resolve: async function*(page, ast, state={}){ ast = ast ?? this.expand(page, null, state) - ast = typeof(ast) == 'string' ? + ast = typeof(ast) != 'object' ? this.expand(page, ast, state) : ast