mirror of
https://github.com/flynx/pWiki.git
synced 2026-01-10 12:01:07 +00:00
experimenting with path actions...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
4e00afe9b0
commit
15cc7b1d20
50
wiki.js
50
wiki.js
@ -581,6 +581,10 @@ var macro = {
|
|||||||
|
|
||||||
// XXX not sure about these...
|
// XXX not sure about these...
|
||||||
// XXX add docs...
|
// XXX add docs...
|
||||||
|
// XXX need to handle case:
|
||||||
|
// .data is function + function returns a page
|
||||||
|
// -> "redirect" to that page
|
||||||
|
// ...is changing .path a good idea for redirecting???
|
||||||
var BaseData = {
|
var BaseData = {
|
||||||
// Macro acces to standard page attributes (paths)...
|
// Macro acces to standard page attributes (paths)...
|
||||||
'System/title': function(){ return this.get('..').title },
|
'System/title': function(){ return this.get('..').title },
|
||||||
@ -641,15 +645,15 @@ var BaseData = {
|
|||||||
// XXX these needs redirecting...
|
// XXX these needs redirecting...
|
||||||
//'System/sort': function(){ return this.get('..').sort() },
|
//'System/sort': function(){ return this.get('..').sort() },
|
||||||
//'System/reverse': function(){ return this.get('..').reverse() },
|
//'System/reverse': function(){ return this.get('..').reverse() },
|
||||||
|
/*
|
||||||
'System/delete': function(){
|
'System/delete': function(){
|
||||||
var p = this.dir
|
var p = this.dir
|
||||||
delete this.__wiki_data[p]
|
delete this.__wiki_data[p]
|
||||||
//return this.get('../..').text
|
return this.get('..')
|
||||||
return 'Removed...'
|
|
||||||
},
|
},
|
||||||
|
//*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// data store...
|
// data store...
|
||||||
// Format:
|
// Format:
|
||||||
// {
|
// {
|
||||||
@ -834,6 +838,30 @@ var data = {
|
|||||||
data.__proto__ = BaseData
|
data.__proto__ = BaseData
|
||||||
|
|
||||||
|
|
||||||
|
// XXX experimental...
|
||||||
|
// ...for some reason these are called twice...
|
||||||
|
var PathActions = {
|
||||||
|
/*
|
||||||
|
test: function(){
|
||||||
|
var p = path2lst(this.location)
|
||||||
|
|
||||||
|
console.log('!!! TEST !!!')
|
||||||
|
|
||||||
|
this.location = p.slice(0, -1)
|
||||||
|
},
|
||||||
|
//*/
|
||||||
|
delete: function(){
|
||||||
|
var p = normalizePath(path2lst(this.location).slice(0, -1))
|
||||||
|
|
||||||
|
console.log('!!! DELETE: %s !!!', p)
|
||||||
|
|
||||||
|
delete this.__wiki_data[p]
|
||||||
|
|
||||||
|
this.location = p
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
@ -876,6 +904,15 @@ var Wiki = {
|
|||||||
return path
|
return path
|
||||||
.replace(/\$NOW|\$\{NOW\}/g, ''+Date.now())
|
.replace(/\$NOW|\$\{NOW\}/g, ''+Date.now())
|
||||||
},
|
},
|
||||||
|
resolvePathActions: function(){
|
||||||
|
var p = path2lst(this.path).pop()
|
||||||
|
|
||||||
|
if(p in PathActions){
|
||||||
|
return PathActions[p].call(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
return this
|
||||||
|
},
|
||||||
// Resolve '.' and '..' relative to current page...
|
// Resolve '.' and '..' relative to current page...
|
||||||
//
|
//
|
||||||
// NOTE: '.' is relative to .path and not to .dir
|
// NOTE: '.' is relative to .path and not to .dir
|
||||||
@ -938,6 +975,8 @@ var Wiki = {
|
|||||||
delete this.__order
|
delete this.__order
|
||||||
delete this.__order_by
|
delete this.__order_by
|
||||||
this.__location = this.resolvePathVars(this.resolveDotPath(value))
|
this.__location = this.resolvePathVars(this.resolveDotPath(value))
|
||||||
|
|
||||||
|
this.resolvePathActions()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -1119,13 +1158,14 @@ var Wiki = {
|
|||||||
|
|
||||||
|
|
||||||
// page content...
|
// page content...
|
||||||
|
//
|
||||||
get raw(){
|
get raw(){
|
||||||
var data = this.data
|
var data = this.data
|
||||||
data = data instanceof Function ? data.call(this, this) : data
|
data = data instanceof Function ? data.call(this, this) : data
|
||||||
|
|
||||||
return typeof(data) == typeof('str') ? data
|
return typeof(data) == typeof('str') ? data
|
||||||
: data != null && 'raw' in data ? data.raw
|
: data != null ?
|
||||||
: data != null ? data.text
|
('raw' in data ? data.raw : data.text)
|
||||||
: ''
|
: ''
|
||||||
},
|
},
|
||||||
set raw(value){
|
set raw(value){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user