tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-07-10 04:30:52 +03:00
parent 82be9f8709
commit e10bdf83b0
2 changed files with 36 additions and 11 deletions

View File

@ -38,6 +38,12 @@ var reload = () => {
//console.log('>>>>>', macro, args) //console.log('>>>>>', macro, args)
if(macro == 'filter' && args.length == 1){
console.log('FILTER:', args[0])
// XXX
return ''
}
if(macro == 'include' && args.length == 1){ if(macro == 'include' && args.length == 1){
w = Object.create(Wiki) w = Object.create(Wiki)
w.location = args[0] w.location = args[0]
@ -66,6 +72,12 @@ var reload = () => {
//console.log('>>>>>', macro, args) //console.log('>>>>>', macro, args)
if(macro == 'filter' && args.name != null){
console.log('FILTER:', args.name)
// XXX
return ''
}
if(macro == 'include' && args.src != null){ if(macro == 'include' && args.src != null){
w = Object.create(Wiki) w = Object.create(Wiki)
w.location = args.src w.location = args.src

35
wiki.js
View File

@ -11,6 +11,23 @@
// XXX not sure about these... // XXX not sure about these...
var BaseData = { var BaseData = {
'Templates/title': function(){
var o = Object.create(this)
o.location = o.dir
return o.title
},
'Templates/path': function(){
return this.dir },
'Templates/dir': function(){
return normalizePath(path2lst(this.dir).slice(0, -1)) },
'Templates/location': function(){
return this.dir },
'Templates/resolved': function(){
var o = Object.create(this)
o.location = o.dir
return o.acquire(o.dir, o.title)
},
'Templates/list': function(){ 'Templates/list': function(){
var p = this.dir var p = this.dir
@ -44,14 +61,13 @@ var BaseData = {
'Templates/links': function(){ 'Templates/links': function(){
var that = this var that = this
var p = this.dir var p = this.dir
var rp = this.acquire(path2lst(p).slice(0, -1), path2lst(p).pop())
var res = [] var res = []
var wiki = this.__wiki_data var wiki = this.__wiki_data
Object.keys(wiki).forEach(function(k){ Object.keys(wiki).forEach(function(k){
(wiki[k].links || []).forEach(function(l){ (wiki[k].links || []).forEach(function(l){
that.acquire(path2lst(l).slice(0, -1), path2lst(l).pop()) == rp (l == p || that.acquire(path2lst(l).slice(0, -1), path2lst(l).pop()) == p)
&& res.push([l, k]) && res.push([l, k])
}) })
}) })
@ -129,22 +145,19 @@ var Wiki = {
// Resolve '.' and '..' relative to current page... // Resolve '.' and '..' relative to current page...
// //
// With the .path set to A/B/C, this will resolve the folowing to: // NOTE: '.' is relative to .path and not to .dir
// '.' -> 'A/B'
// '..' -> 'A'
// './X' -> 'A/B/X'
// '../X' -> 'A/X'
//
// NOTE: this is here as it needs the context to resolve... // NOTE: this is here as it needs the context to resolve...
resolveDotPath: function(path){ resolveDotPath: function(path){
path = normalizePath(path) path = normalizePath(path)
// '.' or './*' // '.' or './*'
return path == '.' || /^\.\//.test(path) ? return path == '.' || /^\.\//.test(path) ?
path.replace(/^\./, this.dir) //path.replace(/^\./, this.dir)
path.replace(/^\./, this.path)
// '..' or '../*' // '..' or '../*'
: path == '..' || /^\.\.\//.test(path) ? : path == '..' || /^\.\.\//.test(path) ?
path.replace(/^\.\./, //path.replace(/^\.\./,
normalizePath(path2lst(this.dir).slice(0, -1))) // normalizePath(path2lst(this.dir).slice(0, -1)))
path.replace(/^\.\./, this.dir)
: path : path
}, },