From 271a0fe1a4ff61ce7f4f3530c2a8cab24371c6c1 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 17 Sep 2022 17:13:23 +0300 Subject: [PATCH] experimenting with folder names + action aliases... Signed-off-by: Alex A. Naanou --- browser.js | 5 ++-- pwiki/page.js | 71 +++++++++++++++++++++++++++------------------ pwiki/path.js | 5 ++-- pwiki/store/base.js | 5 ---- pwiki2.js | 56 ++++++++++++++++++----------------- 5 files changed, 79 insertions(+), 63 deletions(-) diff --git a/browser.js b/browser.js index fec3932..53174d5 100755 --- a/browser.js +++ b/browser.js @@ -47,8 +47,9 @@ module.setup = Promise.all([ // static stores... // - store.next.update('System', - //store.update('System', + //store.next.update('System', + store.next.update( + pwpath.sanitize(pwpath.SYSTEM_PATH), Object.create(basestore.BaseStore).load(page.System)), store.update('Settings', Object.create(basestore.BaseStore).load(page.Settings)), diff --git a/pwiki/page.js b/pwiki/page.js index ed94553..108964a 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -57,27 +57,35 @@ object.Constructor('BasePage', { // different "class"... //__clone_proto__: undefined, - actions: new Set([ - 'location', - 'referrer', - 'path', - 'name', - 'dir', - 'argstr', - 'title', - 'resolved', - 'rootpath', - 'length', - 'type', - 'ctime', - 'mtime', - ]), + // + // Format: + // { + // : true, + // : , + // } + // + actions: { + location: true, + referrer: true, + path: true, + name: true, + dir: true, + // alias... + args: 'argstr', + title: true, + resolved: true, + rootpath: true, + length: true, + type: true, + ctime: true, + mtime: true, + }, // These actions will be default get :$ARGS appended if no args are // explicitly given... // XXX INHERIT_ARGS actions_inherit_args: new Set([ 'location', - 'argstr', + 'args', ]), @@ -249,8 +257,11 @@ object.Constructor('BasePage', { get energetic(){ return async function(){ return this.__energetic === true || ((this.actions - && this.actions.has(this.name) - && !!this[this.name].energetic) + && this.actions[this.name] + && !!this[ + this.actions[this.name] === true ? + this.name + : this.actions[this.name] ].energetic) || !!await this.store.isEnergetic(this.path)) }.call(this) }, set energetic(value){ this.__energetic = value }, @@ -261,8 +272,11 @@ object.Constructor('BasePage', { get data(){ return (async function(){ // direct actions... if(this.actions - && this.actions.has(this.name)){ - var name = this.name + && this.actions[this.name]){ + var name = + this.actions[this.name] === true ? + this.name + : this.actions[this.name] var page = this.get('..', {args: this.args}) var res = (this.isPattern && !this.__energetic @@ -863,6 +877,7 @@ object.Constructor('Page', BasePage, { if(!src){ return } // XXX INHERIT_ARGS special-case: inherit args by default... + // XXX should this be done when isolated??? if(this.actions_inherit_args && this.actions_inherit_args.has(pwpath.basename(src)) && this.get(pwpath.dirname(src)).path == this.path){ @@ -1293,15 +1308,15 @@ object.Constructor('Page', BasePage, { // NOTE: these can not be overloaded. // (XXX should this be so?) // XXX should this be an object??? - actions: new Set([ + actions: { ...module.BasePage.prototype.actions, - '!', + '!': true, // XXX DEBUG -- remove these... - 'testDirect', - 'testDirect!', - ]), + testDirect: true, + 'testDirect!': true, + }, '!': Object.assign( function(){ @@ -1658,11 +1673,11 @@ object.Constructor('pWikiPageElement', Page, { set __clone_proto__(value){ this.__clone_proto = value }, - actions: new Set([ + actions: { ...CachedPage.prototype.actions, - 'hash' - ]), + hash: true, + }, // NOTE: setting location will reset .hash set it directly via either // one of: diff --git a/pwiki/path.js b/pwiki/path.js index 23f42bc..e58f7ce 100755 --- a/pwiki/path.js +++ b/pwiki/path.js @@ -31,6 +31,8 @@ module = { 'NotFoundError', ], + //SYSTEM_PATH: '/System', + SYSTEM_PATH: '/.system', // Default alternate search locations... // // NOTE: if a path here is relative it is also searched relative to @@ -38,7 +40,6 @@ module = { SEARCH_PATHS: [ //'./Theme/CLI', './Templates', - '/System', ], /*/ XXX NORMCACHE... @@ -252,7 +253,7 @@ module = { && path.push(this.INDEX_PAGE) } // search for page... var page = path.pop() - for(var tpl of ['.', ...this.SEARCH_PATHS]){ + for(var tpl of ['.', ...this.SEARCH_PATHS, this.SYSTEM_PATH]){ // search for page up the path... var pg = page var base = path.slice() diff --git a/pwiki/store/base.js b/pwiki/store/base.js index e937d7d..f9dd1a3 100755 --- a/pwiki/store/base.js +++ b/pwiki/store/base.js @@ -140,11 +140,6 @@ module.BaseStore = { // XXX revise naming... next: undefined, - // XXX HIDE name?? - hide_paths: [ - 'System', - ], - // NOTE: .data is not part of the spec and can be implementation-specific, // only .____(..) use it internally... (XXX check this) __data: undefined, diff --git a/pwiki2.js b/pwiki2.js index d47be7f..acffe04 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -1,28 +1,9 @@ /********************************************************************** * * -* 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 ASAP start writing docs in pwiki +* - WYSIWYG markdown editor/viewer (ASAP) +* - fs store/export in browser or a simple way to export/import... * XXX BUG: * /System/info * and: @@ -32,9 +13,6 @@ * XXX might also be a good idea to investigate a .tree directory index * as a supplement to .paths() * XXX Q: can we access fs from a pwa??? -* XXX start writing docs in pwiki -* - WYSIWYG markdown editor/viewer (ASAP) -* - fs store/export in browser * XXX CACHE need to explicitly prevent caching of some actions/pages... * XXX the parser should handle all action return values, including: * - lists -- XXX @@ -227,6 +205,30 @@ * ...not sure how we track these... * XXX revise how we handle .strict mode in page's .raw and .text... * XXX might be a good idea to export HTML from a specific path/pattern... +* 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 should this be done when isolated??? +* ...yes (current) * * * @@ -484,7 +486,9 @@ module.store = { // XXX nested system store... module.setup = Promise.all([ - store.next.update('System', + //store.next.update('System', + store.next.update( + pwpath.sanitize(pwpath.SYSTEM_PATH), Object.create(basestore.BaseStore).load(page.System)), store.update('Settings', Object.create(basestore.BaseStore).load(page.Settings)),