mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 18:10:09 +00:00
fix...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
4c93757b4a
commit
d50c2b675d
84
pwiki2.js
84
pwiki2.js
@ -837,6 +837,7 @@ object.Constructor('BasePage', {
|
|||||||
// store interface...
|
// store interface...
|
||||||
//
|
//
|
||||||
// XXX we are only doing modifiers here...
|
// XXX we are only doing modifiers here...
|
||||||
|
// ...these ar mainly used to disable writing in .ro(..)
|
||||||
__update__: function(data){
|
__update__: function(data){
|
||||||
this.store.update(this.location, data)
|
this.store.update(this.location, data)
|
||||||
return this },
|
return this },
|
||||||
@ -911,6 +912,8 @@ object.Constructor('BasePage', {
|
|||||||
// XXX should this be an iterator???
|
// XXX should this be an iterator???
|
||||||
each: function(path){
|
each: function(path){
|
||||||
var that = this
|
var that = this
|
||||||
|
// NOTE: we are trying to avoid resolving non-pattern paths unless
|
||||||
|
// we really have to...
|
||||||
path = path ?
|
path = path ?
|
||||||
module.path.relative(this.path, path)
|
module.path.relative(this.path, path)
|
||||||
: this.path
|
: this.path
|
||||||
@ -1007,6 +1010,47 @@ object.Constructor('BasePage', {
|
|||||||
//*/
|
//*/
|
||||||
data) },
|
data) },
|
||||||
|
|
||||||
|
// XXX EXPERIMENTAL...
|
||||||
|
ro: function(data={}){
|
||||||
|
return Object.assign({
|
||||||
|
__proto__: this,
|
||||||
|
__update__: function(){ return this },
|
||||||
|
__delete__: function(){ return this },
|
||||||
|
},
|
||||||
|
data) },
|
||||||
|
// XXX should we be able to change path/location here???
|
||||||
|
// XXX EXPERIMENTAL...
|
||||||
|
virtual: function(data={}){
|
||||||
|
var that = this
|
||||||
|
return {
|
||||||
|
__proto__: this,
|
||||||
|
// make the location read-only...
|
||||||
|
get location(){
|
||||||
|
// NOTE: since we are not providing this as a basis for
|
||||||
|
// inheritance we do not need to properly access
|
||||||
|
// the parent prop...
|
||||||
|
// ...otherwise use:
|
||||||
|
// object.parentProperty(..)
|
||||||
|
return this.__proto__.location },
|
||||||
|
__update__: function(data){
|
||||||
|
Object.assign(this.data, data)
|
||||||
|
return this },
|
||||||
|
__delete__: function(){ return this },
|
||||||
|
// NOTE: we need to proxy .clone(..) back to parent so as to
|
||||||
|
// avoid overloading .data in the children too...
|
||||||
|
clone: function(...args){
|
||||||
|
var res = that.clone(...args)
|
||||||
|
return res.path == this.path ?
|
||||||
|
that.virtual(data)
|
||||||
|
: res },
|
||||||
|
data: Object.assign(
|
||||||
|
{
|
||||||
|
ctime: Date.now(),
|
||||||
|
mtime: Date.now(),
|
||||||
|
},
|
||||||
|
data),
|
||||||
|
} },
|
||||||
|
|
||||||
// XXX should this be update or assign???
|
// XXX should this be update or assign???
|
||||||
// XXX how should this work on multiple pages...
|
// XXX how should this work on multiple pages...
|
||||||
update: function(...data){
|
update: function(...data){
|
||||||
@ -1962,7 +2006,7 @@ object.Constructor('Page', BasePage, {
|
|||||||
// XXX should we wrap this in pages...
|
// XXX should we wrap this in pages...
|
||||||
pages.raw
|
pages.raw
|
||||||
.map(function(data){
|
.map(function(data){
|
||||||
return that.virtual(data) })
|
return that.virtual({text: data}) })
|
||||||
: pages.each()
|
: pages.each()
|
||||||
//*/
|
//*/
|
||||||
// no matching pages -> get the else block...
|
// no matching pages -> get the else block...
|
||||||
@ -1983,7 +2027,6 @@ object.Constructor('Page', BasePage, {
|
|||||||
// apply macro text...
|
// apply macro text...
|
||||||
return pages
|
return pages
|
||||||
.map(function(page, i){
|
.map(function(page, i){
|
||||||
console.log('---', page.path)
|
|
||||||
return [
|
return [
|
||||||
...that.__parser__.expand(page, text, state),
|
...that.__parser__.expand(page, text, state),
|
||||||
...((join_block && i < pages.length-1) ?
|
...((join_block && i < pages.length-1) ?
|
||||||
@ -2074,43 +2117,6 @@ object.Constructor('Page', BasePage, {
|
|||||||
set text(value){
|
set text(value){
|
||||||
//this.store.update(this.location, {text: value}) },
|
//this.store.update(this.location, {text: value}) },
|
||||||
this.__update__({text: value}) },
|
this.__update__({text: value}) },
|
||||||
|
|
||||||
// XXX EXPERIMENTAL...
|
|
||||||
ro: function(data={}){
|
|
||||||
return Object.assign({
|
|
||||||
__proto__: this,
|
|
||||||
__update__: function(){ return this },
|
|
||||||
__delete__: function(){ return this },
|
|
||||||
},
|
|
||||||
data) },
|
|
||||||
// XXX should we be able to change path/location here???
|
|
||||||
// XXX EXPERIMENTAL...
|
|
||||||
virtual: function(text){
|
|
||||||
var that = this
|
|
||||||
return {
|
|
||||||
__proto__: this,
|
|
||||||
// make the location read-only...
|
|
||||||
get location(){
|
|
||||||
// NOTE: since we are not providing this as a basis for
|
|
||||||
// inheritance we do not need to properly access
|
|
||||||
// the parent prop...
|
|
||||||
// ...otherwise use:
|
|
||||||
// object.parentProperty(..)
|
|
||||||
return this.__proto__.location },
|
|
||||||
__update__: function(data){
|
|
||||||
Object.assign(this.data, data)
|
|
||||||
return this },
|
|
||||||
__delete__: function(){ return this },
|
|
||||||
// NOTE: we need to proxy .clone(..) back to parent so as to
|
|
||||||
// avoid overloading .data in the children too...
|
|
||||||
clone: function(...args){
|
|
||||||
return that.clone(...args) },
|
|
||||||
data: {
|
|
||||||
ctime: Date.now(),
|
|
||||||
mtime: Date.now(),
|
|
||||||
text,
|
|
||||||
},
|
|
||||||
} },
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user