bugfix + notes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-08-16 11:00:23 +03:00
parent b5e3a8891d
commit 7cca3f38f6
6 changed files with 51 additions and 36 deletions

View File

@ -29,10 +29,34 @@ module.store =
{ __proto__: basestore.BaseStore }
.nest({ __proto__: basestore.MetaStore })
store.update('System',
Object.create(basestore.BaseStore).load(page.System))
store.update('Settings',
Object.create(basestore.BaseStore).load(page.Settings))
module.setup =
Promise.all([
// static stores...
//
store.update('System',
Object.create(basestore.BaseStore).load(page.System)),
store.update('Settings',
Object.create(basestore.BaseStore).load(page.Settings)),
// persistent stores...
//
store.update('@local', {
__proto__: localstoragestore.localStorageStore,
data: localStorage,
}),
store.update('@session', {
__proto__: localstoragestore.localStorageStore,
data: sessionStorage,
}),
store.update('@pouch', {
__proto__: pouchdbstore.PouchDBStore,
}),
])
// XXX
//typeof(Bootstrap) != 'undefined'
// && pwiki.store.load(Bootstrap)
var pwiki =
module.pwiki =
@ -41,26 +65,6 @@ module.pwiki =
page.pWikiPageElement('/', '/', store)
pwiki.store.update('@local', {
__proto__: localstoragestore.localStorageStore,
data: localStorage,
})
pwiki.store.update('@session', {
__proto__: localstoragestore.localStorageStore,
data: sessionStorage,
})
pwiki.store.update('@pouch', {
__proto__: pouchdbstore.PouchDBStore,
})
// XXX
//typeof(Bootstrap) != 'undefined'
// && pwiki.store.load(Bootstrap)
/**********************************************************************
* vim:set ts=4 sw=4 : */ return module })

View File

@ -1060,14 +1060,13 @@ object.Constructor('Page', BasePage, {
path = pwpath.join(path)
// get the template relative to the top most pattern...
// XXX BUG: this sometimes returns undefined on load...
tpl = await this.get(tpl).find(true)
if(!tpl){
throw new Error('UNKNOWN RENDER TEMPLATE: '+ tpl_name) }
var data = {
render_root: this,
}
// render template in context of page...
var data = { render_root: this }
return this.get(path, data)
.parse(await this.get(tpl, data).raw) }).call(this) },
set text(value){

View File

@ -128,9 +128,8 @@ module.BaseStore = {
|| false },
// find the closest existing alternative path...
find: async function(path, strict=false){
for(var p of await pwpath.paths(path, !!strict)){
p = await this.exists(p)
if(p){
for(var p of pwpath.paths(path, !!strict)){
if(p = await this.exists(p)){
return p } } },
//
// Resolve page for path

View File

@ -32,6 +32,8 @@ store.next.load(
return res }, {}))
//*/
// XXX these are async...
// ...see browser.js for a way to deal with this...
pwiki.store.update('@file-ro', {
__proto__: filestore.FileStoreRO,
__path__: 'bootstrap',

View File

@ -88,9 +88,10 @@ document.pwikiloaded = new Event('pwikiloaded')
// start loading pWiki...
require(['./browser'], function(pwiki){
pwiki = window.pwiki = pwiki.pwiki
require(['./browser'], function(browser){
pwiki = window.pwiki = browser.pwiki
pwiki.dom = document.querySelector('#pWiki')
// handle location.hash/history (both directions)
window.addEventListener('hashchange', function(evt){
evt.preventDefault()
@ -126,9 +127,14 @@ require(['./browser'], function(pwiki){
&& this.dom
.querySelector('#'+ this.hash)
.scrollIntoView() })
// show current page...
pwiki.path = location.hash.slice(1)
})
// wait for stuff to finish...
browser.setup.then(function(){
// show current page...
pwiki.path = location.hash.slice(1)
}) })
// XXX make this a 2 stage save -- first cache and then save to store...

View File

@ -1,7 +1,6 @@
/**********************************************************************
*
*
*
* XXX BUG: source/include problem...
* to reproduce:
* .get('/System/_text_macro/_text').text
@ -12,6 +11,10 @@
* ...there are two ways to dance around this:
* - make filters run a bit more globaly -- per block...
* - find a local parser...
* XXX BUG?: empty stores do not appear to show up in listings...
* ...this is expected but not intuitive...
* might be a good idea to add a special path like /Stores to list
* sub-stores...
* XXX OPTIMIZE: /_tree is really slow...
* XXX might be a good idea to add page caching (state.page_cache) relative
* to a path on parsing, to avoid re-matching the same page over and
@ -265,6 +268,8 @@ module.store =
.nest({ __proto__: basestore.MetaStore })
// XXX these are async...
// ...see browser.js for a way to deal with this...
// XXX note sure how to organize the system actions -- there can be two
// options:
// - a root ram store with all the static stuff and nest the rest