mirror of
https://github.com/flynx/pWiki.git
synced 2026-01-08 11:01:07 +00:00
bugfix + notes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
b5e3a8891d
commit
7cca3f38f6
52
browser.js
52
browser.js
@ -29,10 +29,34 @@ module.store =
|
|||||||
{ __proto__: basestore.BaseStore }
|
{ __proto__: basestore.BaseStore }
|
||||||
.nest({ __proto__: basestore.MetaStore })
|
.nest({ __proto__: basestore.MetaStore })
|
||||||
|
|
||||||
store.update('System',
|
module.setup =
|
||||||
Object.create(basestore.BaseStore).load(page.System))
|
Promise.all([
|
||||||
store.update('Settings',
|
// static stores...
|
||||||
Object.create(basestore.BaseStore).load(page.Settings))
|
//
|
||||||
|
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 =
|
var pwiki =
|
||||||
module.pwiki =
|
module.pwiki =
|
||||||
@ -41,26 +65,6 @@ module.pwiki =
|
|||||||
page.pWikiPageElement('/', '/', store)
|
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 })
|
* vim:set ts=4 sw=4 : */ return module })
|
||||||
|
|||||||
@ -1060,14 +1060,13 @@ object.Constructor('Page', BasePage, {
|
|||||||
path = pwpath.join(path)
|
path = pwpath.join(path)
|
||||||
|
|
||||||
// get the template relative to the top most pattern...
|
// get the template relative to the top most pattern...
|
||||||
|
// XXX BUG: this sometimes returns undefined on load...
|
||||||
tpl = await this.get(tpl).find(true)
|
tpl = await this.get(tpl).find(true)
|
||||||
if(!tpl){
|
if(!tpl){
|
||||||
throw new Error('UNKNOWN RENDER TEMPLATE: '+ tpl_name) }
|
throw new Error('UNKNOWN RENDER TEMPLATE: '+ tpl_name) }
|
||||||
|
|
||||||
var data = {
|
|
||||||
render_root: this,
|
|
||||||
}
|
|
||||||
// render template in context of page...
|
// render template in context of page...
|
||||||
|
var data = { render_root: this }
|
||||||
return this.get(path, data)
|
return this.get(path, data)
|
||||||
.parse(await this.get(tpl, data).raw) }).call(this) },
|
.parse(await this.get(tpl, data).raw) }).call(this) },
|
||||||
set text(value){
|
set text(value){
|
||||||
|
|||||||
@ -128,9 +128,8 @@ module.BaseStore = {
|
|||||||
|| false },
|
|| false },
|
||||||
// find the closest existing alternative path...
|
// find the closest existing alternative path...
|
||||||
find: async function(path, strict=false){
|
find: async function(path, strict=false){
|
||||||
for(var p of await pwpath.paths(path, !!strict)){
|
for(var p of pwpath.paths(path, !!strict)){
|
||||||
p = await this.exists(p)
|
if(p = await this.exists(p)){
|
||||||
if(p){
|
|
||||||
return p } } },
|
return p } } },
|
||||||
//
|
//
|
||||||
// Resolve page for path
|
// Resolve page for path
|
||||||
|
|||||||
@ -32,6 +32,8 @@ store.next.load(
|
|||||||
return res }, {}))
|
return res }, {}))
|
||||||
//*/
|
//*/
|
||||||
|
|
||||||
|
// XXX these are async...
|
||||||
|
// ...see browser.js for a way to deal with this...
|
||||||
pwiki.store.update('@file-ro', {
|
pwiki.store.update('@file-ro', {
|
||||||
__proto__: filestore.FileStoreRO,
|
__proto__: filestore.FileStoreRO,
|
||||||
__path__: 'bootstrap',
|
__path__: 'bootstrap',
|
||||||
|
|||||||
16
pwiki2.html
16
pwiki2.html
@ -88,9 +88,10 @@ document.pwikiloaded = new Event('pwikiloaded')
|
|||||||
|
|
||||||
|
|
||||||
// start loading pWiki...
|
// start loading pWiki...
|
||||||
require(['./browser'], function(pwiki){
|
require(['./browser'], function(browser){
|
||||||
pwiki = window.pwiki = pwiki.pwiki
|
pwiki = window.pwiki = browser.pwiki
|
||||||
pwiki.dom = document.querySelector('#pWiki')
|
pwiki.dom = document.querySelector('#pWiki')
|
||||||
|
|
||||||
// handle location.hash/history (both directions)
|
// handle location.hash/history (both directions)
|
||||||
window.addEventListener('hashchange', function(evt){
|
window.addEventListener('hashchange', function(evt){
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
@ -126,9 +127,14 @@ require(['./browser'], function(pwiki){
|
|||||||
&& this.dom
|
&& this.dom
|
||||||
.querySelector('#'+ this.hash)
|
.querySelector('#'+ this.hash)
|
||||||
.scrollIntoView() })
|
.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...
|
// XXX make this a 2 stage save -- first cache and then save to store...
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* XXX BUG: source/include problem...
|
* XXX BUG: source/include problem...
|
||||||
* to reproduce:
|
* to reproduce:
|
||||||
* .get('/System/_text_macro/_text').text
|
* .get('/System/_text_macro/_text').text
|
||||||
@ -12,6 +11,10 @@
|
|||||||
* ...there are two ways to dance around this:
|
* ...there are two ways to dance around this:
|
||||||
* - make filters run a bit more globaly -- per block...
|
* - make filters run a bit more globaly -- per block...
|
||||||
* - find a local parser...
|
* - 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 OPTIMIZE: /_tree is really slow...
|
||||||
* XXX might be a good idea to add page caching (state.page_cache) relative
|
* 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
|
* to a path on parsing, to avoid re-matching the same page over and
|
||||||
@ -265,6 +268,8 @@ module.store =
|
|||||||
.nest({ __proto__: basestore.MetaStore })
|
.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
|
// XXX note sure how to organize the system actions -- there can be two
|
||||||
// options:
|
// options:
|
||||||
// - 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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user