experimenting with folder names + action aliases...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-09-17 17:13:23 +03:00
parent 1e32383c26
commit 271a0fe1a4
5 changed files with 79 additions and 63 deletions

View File

@ -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)),

View File

@ -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:
// {
// <name>: true,
// <name>: <alias>,
// }
//
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:

View File

@ -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()

View File

@ -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 .__<name>__(..) use it internally... (XXX check this)
__data: undefined,

View File

@ -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)),