mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-16 16:11:39 +00:00
better hash handling + tweaking and notes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
152fd92e0f
commit
45beb4bbde
@ -329,7 +329,6 @@ object.Constructor('BasePage', {
|
||||
|
||||
// XXX should this be an iterator???
|
||||
each: async function*(path){
|
||||
var that = this
|
||||
// NOTE: we are trying to avoid resolving non-pattern paths unless
|
||||
// we really have to...
|
||||
path = path ?
|
||||
@ -345,7 +344,7 @@ object.Constructor('BasePage', {
|
||||
: [paths]
|
||||
|
||||
for(var path of paths){
|
||||
yield that.get('/'+ path) } },
|
||||
yield this.get('/'+ path) } },
|
||||
|
||||
map: async function(func){
|
||||
return this.each().map(func) },
|
||||
@ -1132,17 +1131,41 @@ object.Constructor('pWikiPageElement', Page, {
|
||||
|
||||
dom: undefined,
|
||||
|
||||
|
||||
domFilters: {
|
||||
// XXX see Page.filters.wikiword for notes...
|
||||
wikiword: wikiword.wikiWordText,
|
||||
},
|
||||
|
||||
// NOTE: setting location will reset .hash set it directly via either
|
||||
// one of:
|
||||
// .location = [path, hash]
|
||||
// .location = 'path#hash'
|
||||
hash: undefined,
|
||||
// NOTE: getting .location will not return the hash, so as not to force
|
||||
// the user to parse it out each time.
|
||||
get location(){
|
||||
return object.parentProperty(pWikiPageElement.prototype, 'location')
|
||||
.get.call(this) },
|
||||
set location(value){
|
||||
var [value, hash] =
|
||||
// .location = [path, hash]
|
||||
value instanceof Array ?
|
||||
value
|
||||
// .location = '<path>#<hash>'
|
||||
: value.includes('#') ?
|
||||
value.split('#')
|
||||
// no hash is given...
|
||||
: [value, undefined]
|
||||
this.hash = hash
|
||||
object.parentProperty(pWikiPageElement.prototype, 'location')
|
||||
.set.call(this, value) },
|
||||
|
||||
// XXX this is not persistent, is this what we want???
|
||||
get title(){
|
||||
return this.dom.getAttribute('title')
|
||||
|| (this.dom.querySelector('h1') || {}).innerText
|
||||
|| this.path },
|
||||
// XXX this is not persistent, is this what we want???
|
||||
set title(value){
|
||||
this.dom.setAttribute('title', value) },
|
||||
|
||||
@ -1172,6 +1195,7 @@ object.Constructor('pWikiPageElement', Page, {
|
||||
&& (page.__proto__ = this.__page_constructor__.prototype)
|
||||
return page },
|
||||
|
||||
// handle dom as first argument...
|
||||
__init__: function(dom, ...args){
|
||||
if(dom instanceof Element){
|
||||
this.dom = dom
|
||||
|
||||
@ -343,19 +343,26 @@ module.BaseStore = {
|
||||
for(var [path, value] of Object.entries(input)){
|
||||
this.update(path, value) } }
|
||||
return this },
|
||||
// NOTE: this will not serialize functions...
|
||||
//__batch_json__: function(){
|
||||
// // ...
|
||||
// return json},
|
||||
json: async function(asstring=false){
|
||||
json: async function(options={}){
|
||||
if(options === true){
|
||||
options = {stringify: true} }
|
||||
var {stringify, keep_funcs} = options
|
||||
// batch...
|
||||
if(this.__batch_json__){
|
||||
var res = this.__batch_json__(asstring)
|
||||
var res = this.__batch_json__(stringify)
|
||||
// generic...
|
||||
} else {
|
||||
var res = {}
|
||||
for(var path of await this.paths()){
|
||||
res[path] = await this.get(path) } }
|
||||
return (asstring
|
||||
var page = await this.get(path)
|
||||
if(keep_funcs
|
||||
|| typeof(page) != 'function'){
|
||||
res[path] = page } } }
|
||||
return (stringify
|
||||
&& typeof(res) != 'string') ?
|
||||
JSON.stringify(res)
|
||||
: res },
|
||||
|
||||
10
pwiki2.html
10
pwiki2.html
@ -101,14 +101,11 @@ require(['./browser'], function(pwiki){
|
||||
pwiki.path
|
||||
//'/'
|
||||
: path
|
||||
// XXX treat links as absolute unless explicitly relative...
|
||||
// treat links as absolute unless explicitly relative...
|
||||
path = /^\.\.?([\\\/].*)?$/.test(path) ?
|
||||
path
|
||||
: '/'+path
|
||||
// NOTE: .hash needs to be set before .path, otherwise the path
|
||||
// handlers will not see it..
|
||||
pwiki.hash = hash
|
||||
pwiki.path = path })
|
||||
pwiki.path = [path, hash] })
|
||||
pwiki
|
||||
.onNavigate(function(){
|
||||
// NOTE: we do not need to directly update location.hash here as
|
||||
@ -140,7 +137,8 @@ require(['./browser'], function(pwiki){
|
||||
|
||||
<body>
|
||||
|
||||
<div id="pWiki" />
|
||||
<!-- XXX need to add something passive but animated here... -->
|
||||
<div id="pWiki">Loading...</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,6 +1,12 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
*
|
||||
* XXX BUG:
|
||||
* pwiki.get(..) -> Page object
|
||||
* pwiki.get(..).get(..) -> pWikiPageElement object
|
||||
* pwiki.get(..).get(..).get(..) -> Page object
|
||||
* ...
|
||||
*
|
||||
* XXX BUG: .get('/*').raw hangs...
|
||||
* XXX add action to reset overloaded (bootstrap) pages...
|
||||
* - per page
|
||||
@ -20,7 +26,7 @@
|
||||
* - editor and interactivity
|
||||
* - migrate bootstrap
|
||||
* - store topology
|
||||
* - markdown -- DONE??
|
||||
* - markdown -- DONE
|
||||
* - WikiWord -- DONE
|
||||
* - dom filter mechanics -- DONE
|
||||
* - filters / dom filters:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user