notes, cleanup and tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-08-28 16:34:46 +03:00
parent aecc0b6cac
commit 18141b0751
4 changed files with 58 additions and 44 deletions

View File

@ -41,8 +41,8 @@ module.setup =
Promise.all([ Promise.all([
// static stores... // static stores...
// //
//store.next.update('System', store.next.update('System',
store.update('System', //store.update('System',
Object.create(basestore.BaseStore).load(page.System)), Object.create(basestore.BaseStore).load(page.System)),
store.update('Settings', store.update('Settings',
Object.create(basestore.BaseStore).load(page.Settings)), Object.create(basestore.BaseStore).load(page.Settings)),
@ -63,7 +63,7 @@ Promise.all([
__proto__: pouchdbstore.PouchDBStore, __proto__: pouchdbstore.PouchDBStore,
}), }),
// next testing... /*/ XXX next testing...
store.next.update('NextPage', { store.next.update('NextPage', {
text: 'next page...', text: 'next page...',
}), }),
@ -79,6 +79,7 @@ Promise.all([
store.next.update('System/NextTest', { store.next.update('System/NextTest', {
text: 'next test..' text: 'next test..'
}), }),
//*/
]) ])
// XXX // XXX
//typeof(Bootstrap) != 'undefined' //typeof(Bootstrap) != 'undefined'

View File

@ -1138,14 +1138,19 @@ object.Constructor('Page', BasePage, {
// //
// NOTE: writing to .raw is the same as writing to .text... // NOTE: writing to .raw is the same as writing to .text...
// NOTE: when matching multiple pages this will return a list... // NOTE: when matching multiple pages this will return a list...
//
// XXX revise how we handle .strict mode...
get raw(){ return (async function(){ get raw(){ return (async function(){
var data = await this.data var data = await this.data
// no data... // no data...
// NOTE: if we hit this it means that nothing was resolved, // NOTE: if we hit this it means that nothing was resolved,
// not even the System/NotFound page, i.e. something // not even the System/NotFound page, i.e. something
// went really wrong... // went really wrong...
// NOTE: in .strict mode this will explicitly fail and not try
// to recover...
if(data == null){ if(data == null){
if(this.NOT_FOUND_ERROR){ if(!this.strict
&& this.NOT_FOUND_ERROR){
var msg = this.get(this.NOT_FOUND_ERROR) var msg = this.get(this.NOT_FOUND_ERROR)
if(await msg.match()){ if(await msg.match()){
return msg.raw } } return msg.raw } }
@ -1221,10 +1226,16 @@ object.Constructor('Page', BasePage, {
// NOTE: this uses .PAGE_TEMPLATE to render the page. // NOTE: this uses .PAGE_TEMPLATE to render the page.
// NOTE: writing to .raw is the same as writing to .text... // NOTE: writing to .raw is the same as writing to .text...
// //
// XXX revise how we handle strict mode...
//
// NOTE: .__debug_last_render_state is mainly exposed for introspection // NOTE: .__debug_last_render_state is mainly exposed for introspection
// and debugging, set comment it out to disable... // and debugging, set comment it out to disable...
//__debug_last_render_state: undefined, //__debug_last_render_state: undefined,
get text(){ return (async function(){ get text(){ return (async function(){
// strict mode -- break on non-existing pages...
if(this.strict
&& !await this.resolve(true)){
throw new Error('NOT FOUND ERROR: '+ this.path) }
var path = pwpath.split(this.path) var path = pwpath.split(this.path)
path.at(-1)[0] == '_' path.at(-1)[0] == '_'
|| path.push(this.PAGE_TEMPLATE) || path.push(this.PAGE_TEMPLATE)
@ -1509,12 +1520,13 @@ module.System = {
// XXX all of these should support pattern pages... // XXX all of these should support pattern pages...
_text: { _text: {
text: '@include(. isolated join="@source(file-separator)")' }, text: '@include(. isolated join="@source(file-separator)")' },
// XXX /rootpath here is not relative -- makes reuse harder...
_view: { _view: {
text: object.doc` text: object.doc`
<slot name="header"> <slot name="header">
<a href="#/list">&#9776;</a> <a href="#/list">&#9776;</a>
@source(./path) @source(/rootpath)
<a href="#@source(./path)/_edit">(edit)</a> <a href="#@source(/rootpath)/_edit">(edit)</a>
</slot> </slot>
<hr> <hr>
<slot name="content"></slot> <slot name="content"></slot>
@ -1690,10 +1702,12 @@ module.System = {
return (this.render_root || {}).path }, return (this.render_root || {}).path },
referrer: function(){ referrer: function(){
return this.referrer || this.path }, return this.referrer || this.path },
location: function(){
return this.get('..').location },
path: function(){ path: function(){
return this.get('..').path }, return this.get('..').path },
location: function(){ rootpath: function(){
return this.get('..').path }, return this.root.path },
resolved: async function(){ resolved: async function(){
return this.get('..').resolve() }, return this.get('..').resolve() },
dir: function(){ dir: function(){

View File

@ -649,7 +649,9 @@ module.MetaStore = {
pwpath.join(s, res) pwpath.join(s, res)
: res }), : res }),
get: async function(path, strict=false){ get: async function(path, strict=false){
path = await this.resolve(path) path = await this.resolve(path, strict)
if(path == undefined){
return }
var res var res
var p = this.substore(path) var p = this.substore(path)
if(p){ if(p){

View File

@ -9,9 +9,9 @@
* .get(..) -- DONE * .get(..) -- DONE
* .metadata(..) -- * .metadata(..) --
* .delete(..) * .delete(..)
* XXX deleting something in .next will break stuff...
* ... * ...
* XXX this broke "strict"... * XXX OPTIMIZE page search: make things invariant via .names
* XXX page search: make things invariant via .names
* - if a page is in a system path and there are no alternatives * - if a page is in a system path and there are no alternatives
* just return it and do not search. * just return it and do not search.
* - if there are alternatives rank them * - if there are alternatives rank them
@ -19,21 +19,20 @@
* - return the first system * - return the first system
* XXX sort paths in .names * XXX sort paths in .names
* XXX remove/mark shadowed paths??? * XXX remove/mark shadowed paths???
* XXX NORMCACHE .normalize(..) cache normalized strings... * XXX OPTIMIZE MATCH limit candidates to actual page name matches -- this will
* ...seems to have little impact...
* XXX MATCH limit candidates to actual page name matches -- this will
* limit the number of requests to actual number of pages with that * limit the number of requests to actual number of pages with that
* name... * name...
* e.g. when searching for xxx/tree the only "tree" available is * e.g. when searching for xxx/tree the only "tree" available is
* System/tree, and if it is overloaded it's now a question of * System/tree, and if it is overloaded it's now a question of
* picking one out of two and not out of tens generated by .paths() * picking one out of two and not out of tens generated by .paths()
* XXX CACHE match pattern paths -- to catch page creation... * XXX OPTIMIZE CACHE match pattern paths -- to catch page creation...
* 1) explicit subpath matching -- same as .match(..) * 1) explicit subpath matching -- same as .match(..)
* 2) identify recursive patterns -- same as ** * 2) identify recursive patterns -- same as **
* XXX CACHE track store changes... * XXX OPTIMIZE CACHE track store changes...
* XXX CACHE/DEPENDS might be a good idea to add a dependencyUpdated event... * XXX OPTIMIZE CACHE/DEPENDS might be a good idea to add a dependencyUpdated event...
* ...and use it for cache invalidation... * ...and use it for cache invalidation...
* XXX CACHE creating a new page does not invalidate /tree cache... * XXX OPTIMIZE NORMCACHE .normalize(..) cache normalized strings...
* ...seems to have little impact...
* XXX OPTIMIZE: the actions that depend on lots of tiny requests (/tree) * XXX OPTIMIZE: the actions that depend on lots of tiny requests (/tree)
* can get really slow... * can get really slow...
* ...it feels like one reason is the async/await ping-pong... * ...it feels like one reason is the async/await ping-pong...
@ -45,7 +44,10 @@
* mark the normalized string and return it as-is on * mark the normalized string and return it as-is on
* renormalization... * renormalization...
* ...initial experiment made things slower... * ...initial experiment made things slower...
* XXX FEATURE eed a uniform way to track some state in links in pwiki * XXX FEATURE self-doc:
* - some thing lile Action(<name>, <doc>, <func>|<str>)
* - System/doc -- show <doc> for action...
* XXX FEATURE add a uniform way to track some state in links in pwiki
* for things like paging and the like with simple user/macro * for things like paging and the like with simple user/macro
* access (???)... * access (???)...
* ...the simplest that comes to mind is to store in in path * ...the simplest that comes to mind is to store in in path
@ -134,6 +136,7 @@
* XXX CHECK: @macro(..) and @slot(..) must overload in the same way... * XXX CHECK: @macro(..) and @slot(..) must overload in the same way...
* XXX DEPENDS/CACHE @macro(..) introduces a dependency on count (pattern) * XXX DEPENDS/CACHE @macro(..) introduces a dependency on count (pattern)
* ...not sure how we track these... * ...not sure how we track these...
* XXX revise how we handle .strict mode in page's .raw and .text...
* *
* *
* *
@ -155,7 +158,7 @@
* - copy/move -- DONE * - copy/move -- DONE
* - resolved (async) -- * - resolved (async) --
* - migrate/rewrite bootstrap -- * - migrate/rewrite bootstrap --
* - store topology -- * - store topology -- DONE
* - sync and sync conf -- * - sync and sync conf --
* - images * - images
* - get -- * - get --
@ -342,11 +345,7 @@ module.path =
var page = require('./pwiki/page') var page = require('./pwiki/page')
var basestore = require('./pwiki/store/base') var basestore = require('./pwiki/store/base')
var pouchdbstore = require('./pwiki/store/pouchdb')
//var localstoragestore = require('./store/localstorage')
// XXX for some reason this does not run quietly in browser
//var pouchdbstore = require('./store/pouchdb')
//var filestore = require('./store/file')
@ -355,24 +354,19 @@ var basestore = require('./pwiki/store/base')
// //
// //
// Store topology: // Store topology:
// // XXX
// root (BaseStore) ---next--- main (MetaStore)
// |
// +-- System/... (BaseStore)
//
// Alternative store topology:
//
// root (BaseStore) ---next--- main (MetaStore)
// System/... (static)
//
// //
var store = var store =
module.store = module.store = {
//BaseStore.nest() // XXX base localstorage...
// XXX clone... __proto__: pouchdbstore.PouchDBStore,
{ __proto__: basestore.BaseStore } /*/
.nest({ __proto__: basestore.MetaStore }) __proto__: basestore.MetaStore,
//*/
next: { __proto__: basestore.MetaStore },
}
// XXX these are async... // XXX these are async...
@ -382,10 +376,13 @@ module.store =
// - a root ram store with all the static stuff and nest the rest // - a root ram store with all the static stuff and nest the rest
// - a nested store (as is the case here) // - a nested store (as is the case here)
// XXX nested system store... // XXX nested system store...
store.update('System', module.setup =
Object.create(basestore.BaseStore).load(page.System)) Promise.all([
store.update('Settings', store.next.update('System',
Object.create(basestore.BaseStore).load(page.Settings)) Object.create(basestore.BaseStore).load(page.System)),
store.update('Settings',
Object.create(basestore.BaseStore).load(page.Settings)),
])