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???
|
// XXX should this be an iterator???
|
||||||
each: async function*(path){
|
each: async function*(path){
|
||||||
var that = this
|
|
||||||
// NOTE: we are trying to avoid resolving non-pattern paths unless
|
// NOTE: we are trying to avoid resolving non-pattern paths unless
|
||||||
// we really have to...
|
// we really have to...
|
||||||
path = path ?
|
path = path ?
|
||||||
@ -345,7 +344,7 @@ object.Constructor('BasePage', {
|
|||||||
: [paths]
|
: [paths]
|
||||||
|
|
||||||
for(var path of paths){
|
for(var path of paths){
|
||||||
yield that.get('/'+ path) } },
|
yield this.get('/'+ path) } },
|
||||||
|
|
||||||
map: async function(func){
|
map: async function(func){
|
||||||
return this.each().map(func) },
|
return this.each().map(func) },
|
||||||
@ -1132,17 +1131,41 @@ object.Constructor('pWikiPageElement', Page, {
|
|||||||
|
|
||||||
dom: undefined,
|
dom: undefined,
|
||||||
|
|
||||||
|
|
||||||
domFilters: {
|
domFilters: {
|
||||||
// XXX see Page.filters.wikiword for notes...
|
// XXX see Page.filters.wikiword for notes...
|
||||||
wikiword: wikiword.wikiWordText,
|
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(){
|
get title(){
|
||||||
return this.dom.getAttribute('title')
|
return this.dom.getAttribute('title')
|
||||||
|| (this.dom.querySelector('h1') || {}).innerText
|
|| (this.dom.querySelector('h1') || {}).innerText
|
||||||
|| this.path },
|
|| this.path },
|
||||||
// XXX this is not persistent, is this what we want???
|
|
||||||
set title(value){
|
set title(value){
|
||||||
this.dom.setAttribute('title', value) },
|
this.dom.setAttribute('title', value) },
|
||||||
|
|
||||||
@ -1172,6 +1195,7 @@ object.Constructor('pWikiPageElement', Page, {
|
|||||||
&& (page.__proto__ = this.__page_constructor__.prototype)
|
&& (page.__proto__ = this.__page_constructor__.prototype)
|
||||||
return page },
|
return page },
|
||||||
|
|
||||||
|
// handle dom as first argument...
|
||||||
__init__: function(dom, ...args){
|
__init__: function(dom, ...args){
|
||||||
if(dom instanceof Element){
|
if(dom instanceof Element){
|
||||||
this.dom = dom
|
this.dom = dom
|
||||||
|
|||||||
@ -343,19 +343,26 @@ module.BaseStore = {
|
|||||||
for(var [path, value] of Object.entries(input)){
|
for(var [path, value] of Object.entries(input)){
|
||||||
this.update(path, value) } }
|
this.update(path, value) } }
|
||||||
return this },
|
return this },
|
||||||
|
// NOTE: this will not serialize functions...
|
||||||
//__batch_json__: function(){
|
//__batch_json__: function(){
|
||||||
// // ...
|
// // ...
|
||||||
// return json},
|
// return json},
|
||||||
json: async function(asstring=false){
|
json: async function(options={}){
|
||||||
|
if(options === true){
|
||||||
|
options = {stringify: true} }
|
||||||
|
var {stringify, keep_funcs} = options
|
||||||
// batch...
|
// batch...
|
||||||
if(this.__batch_json__){
|
if(this.__batch_json__){
|
||||||
var res = this.__batch_json__(asstring)
|
var res = this.__batch_json__(stringify)
|
||||||
// generic...
|
// generic...
|
||||||
} else {
|
} else {
|
||||||
var res = {}
|
var res = {}
|
||||||
for(var path of await this.paths()){
|
for(var path of await this.paths()){
|
||||||
res[path] = await this.get(path) } }
|
var page = await this.get(path)
|
||||||
return (asstring
|
if(keep_funcs
|
||||||
|
|| typeof(page) != 'function'){
|
||||||
|
res[path] = page } } }
|
||||||
|
return (stringify
|
||||||
&& typeof(res) != 'string') ?
|
&& typeof(res) != 'string') ?
|
||||||
JSON.stringify(res)
|
JSON.stringify(res)
|
||||||
: res },
|
: res },
|
||||||
|
|||||||
10
pwiki2.html
10
pwiki2.html
@ -101,14 +101,11 @@ require(['./browser'], function(pwiki){
|
|||||||
pwiki.path
|
pwiki.path
|
||||||
//'/'
|
//'/'
|
||||||
: path
|
: path
|
||||||
// XXX treat links as absolute unless explicitly relative...
|
// treat links as absolute unless explicitly relative...
|
||||||
path = /^\.\.?([\\\/].*)?$/.test(path) ?
|
path = /^\.\.?([\\\/].*)?$/.test(path) ?
|
||||||
path
|
path
|
||||||
: '/'+path
|
: '/'+path
|
||||||
// NOTE: .hash needs to be set before .path, otherwise the path
|
pwiki.path = [path, hash] })
|
||||||
// handlers will not see it..
|
|
||||||
pwiki.hash = hash
|
|
||||||
pwiki.path = path })
|
|
||||||
pwiki
|
pwiki
|
||||||
.onNavigate(function(){
|
.onNavigate(function(){
|
||||||
// NOTE: we do not need to directly update location.hash here as
|
// NOTE: we do not need to directly update location.hash here as
|
||||||
@ -140,7 +137,8 @@ require(['./browser'], function(pwiki){
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="pWiki" />
|
<!-- XXX need to add something passive but animated here... -->
|
||||||
|
<div id="pWiki">Loading...</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</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 BUG: .get('/*').raw hangs...
|
||||||
* XXX add action to reset overloaded (bootstrap) pages...
|
* XXX add action to reset overloaded (bootstrap) pages...
|
||||||
* - per page
|
* - per page
|
||||||
@ -20,7 +26,7 @@
|
|||||||
* - editor and interactivity
|
* - editor and interactivity
|
||||||
* - migrate bootstrap
|
* - migrate bootstrap
|
||||||
* - store topology
|
* - store topology
|
||||||
* - markdown -- DONE??
|
* - markdown -- DONE
|
||||||
* - WikiWord -- DONE
|
* - WikiWord -- DONE
|
||||||
* - dom filter mechanics -- DONE
|
* - dom filter mechanics -- DONE
|
||||||
* - filters / dom filters:
|
* - filters / dom filters:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user