From 7255be8c3509b7eee077ec2737abbba64904e66f Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 20 Feb 2023 02:21:22 +0300 Subject: [PATCH] some tweaking and cleanup... Signed-off-by: Alex A. Naanou --- pwiki/page.js | 94 +++++---------------------------------------------- pwiki2.html | 6 ++++ 2 files changed, 15 insertions(+), 85 deletions(-) diff --git a/pwiki/page.js b/pwiki/page.js index 2e43271..0378e30 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -577,15 +577,8 @@ object.Constructor('BasePage', { }) }, // XXX should this be an iterator??? - // XXX EXPERIMENTAL... - // to be sync this needs: - // .energetic - // .store.isEnergetic(..) - // .resolve(..) -> .store.resolve(..) - // XXX should this support strict mode??? each: function(path, strict){ var that = this - // XXX STRICT... if(path === true || path === false){ strict = path path = null } @@ -615,7 +608,6 @@ object.Constructor('BasePage', { return Promise.iter( paths, function(path){ - // XXX STRICT... return strict ? Promise.awaitOrRun( that.exists('/'+path), @@ -624,32 +616,7 @@ object.Constructor('BasePage', { that.get('/'+ path) : [] }) : that.get('/'+ path) }) - /*/ // XXX STRICT... - return that.get('/'+ path) }) - //*/ .sync() }, - /*/ // XXX ASYNC... - each: async function*(path){ - // NOTE: we are trying to avoid resolving non-pattern paths unless - // we really have to... - path = path ? - pwpath.relative(this.path, path) - : this.location - var paths = path.includes('*') - // XXX ENERGETIC... - && !(await this.energetic - // XXX test if energetic action... - || await this.store.isEnergetic(path)) ? - this.resolve(path) - : path - paths = paths instanceof Array ? - paths - : paths instanceof Promise ? - await paths - : [paths] - for(var path of paths){ - yield this.get('/'+ path) } }, - //*/ // XXX is this correct here??? [Symbol.asyncIterator]: async function*(){ yield* this.each() }, @@ -1979,52 +1946,6 @@ object.Constructor('Page', BasePage, { // actions... // // XXX revise name... - /*/ XXX EXPERIMENTAL - asPages: function(path='.:$ARGS', strict=false){ - // options... - var args = [...arguments] - var opts = typeof(args.at(-1)) == 'object' ? - args.pop() - : {} - var {path, strict} = { - ...opts, - path: typeof(args[0]) == 'string' ? - args.shift() - : '.:$ARGS', - strict: args.shift() - ?? false, - } - - var page = this.get(path, strict) - // each... - if(page.isPattern){ - return page.each() - // handle lists in pages (actions, ... etc.)... - } else { - return Promise.awaitOrRun( - page.data, - function(data){ - data = - data instanceof types.Generator ? - // XXX - //await data() - data() - : typeof(data) == 'function' ? - data - : data && 'text' in data ? - data.text - : null - if(data instanceof Array - || data instanceof types.Generator){ - return data - .map(function(p){ - return page.virtual({text: p}) }) } - // do not iterate pages/actions that are undefined... - if(data == null){ - return } - - return page }) } }, - /*/ // XXX ASYNC... // XXX BUG: this does not respect strict of single pages if they do // not exist... // ...see: @macro(..) bug + .each(..) @@ -2050,7 +1971,7 @@ object.Constructor('Page', BasePage, { yield* page // handle lists in pages (actions, ... etc.)... } else { - // page does not exist... + // strict + page does not exist... if(strict && !(await page.exists())){ return } @@ -2074,7 +1995,6 @@ object.Constructor('Page', BasePage, { return } yield page } }, - //*/ // expanded page text... // @@ -2521,9 +2441,9 @@ module.System = { oninput="saveContent(\'@source(s ./path)/title\', this.innerText)"> @source(./title/quote) - @macro(src="." strict - text="" - else="*") + @macro(src="." + strict + else='new') @@ -2705,7 +2625,9 @@ module.System = { Path: [@source(../path/quote)] (edit)
- Resolved path: [/@source(../resolved/quote)]
+ + Resolved path: [/@source(../resolved/quote)]
+
Referrer: [@source(../referrer/quote)]
Args:
@@ -2721,6 +2643,8 @@ module.System = { ctime: @source(../ctime)
mtime: @source(../mtime)
+
+ Resolved text:
` }, diff --git a/pwiki2.html b/pwiki2.html index 2ae6ef0..0772052 100755 --- a/pwiki2.html +++ b/pwiki2.html @@ -167,6 +167,12 @@ body.loading .page.spinner span { opacity: 0.4; } +.new-page-indicator { + position: absolute; + font-size: small; + font-style: italic; + opacity: 0.5; +} /* TOC */ toc {