mirror of
https://github.com/flynx/pWiki.git
synced 2026-01-04 17:11:09 +00:00
tweaking and cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
541c573e53
commit
406d386f64
@ -86,7 +86,7 @@ var macro = {
|
|||||||
|
|
||||||
|
|
||||||
var reload = () => {
|
var reload = () => {
|
||||||
$('.dir').text('/' + Wiki.dir)
|
$('.path').text('/' + Wiki.path)
|
||||||
|
|
||||||
$('.title').text(Wiki.title)
|
$('.title').text(Wiki.title)
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ $(() => {
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="dir"></div>
|
<div class="path"></div>
|
||||||
<hr>
|
<hr>
|
||||||
<h1 class="title" contenteditable tabindex=0></h1>
|
<h1 class="title" contenteditable tabindex=0></h1>
|
||||||
<div class="text" tabindex=0></div>
|
<div class="text" tabindex=0></div>
|
||||||
|
|||||||
36
wiki.js
36
wiki.js
@ -25,7 +25,7 @@ var BaseData = {
|
|||||||
'System/resolved': function(){
|
'System/resolved': function(){
|
||||||
var o = Object.create(this)
|
var o = Object.create(this)
|
||||||
o.location = o.dir
|
o.location = o.dir
|
||||||
return o.get(o.dir).acquire(o.title)
|
return o.get(o.dir).acquire('./'+o.title)
|
||||||
},
|
},
|
||||||
|
|
||||||
'System/list': function(){
|
'System/list': function(){
|
||||||
@ -67,7 +67,7 @@ var BaseData = {
|
|||||||
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){
|
||||||
(l == p || that.get(path2lst(l).slice(0, -1)).acquire(path2lst(l).pop()) == p)
|
(l == p || that.get(path2lst(l).slice(0, -1)).acquire('./'+path2lst(l).pop()) == p)
|
||||||
&& res.push([l, k])
|
&& res.push([l, k])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -175,6 +175,11 @@ var Wiki = {
|
|||||||
set location(value){
|
set location(value){
|
||||||
this.__location = this.resolveDotPath(value) },
|
this.__location = this.resolveDotPath(value) },
|
||||||
|
|
||||||
|
|
||||||
|
get data(){
|
||||||
|
return this.__wiki_data[this.acquire()] },
|
||||||
|
|
||||||
|
|
||||||
// page path...
|
// page path...
|
||||||
//
|
//
|
||||||
// Format:
|
// Format:
|
||||||
@ -225,7 +230,7 @@ var Wiki = {
|
|||||||
var t = p.pop()
|
var t = p.pop()
|
||||||
p = normalizePath(p)
|
p = normalizePath(p)
|
||||||
|
|
||||||
var target = page.get(p).acquire(t)
|
var target = page.get(p).acquire('./'+t)
|
||||||
// page target changed...
|
// page target changed...
|
||||||
// NOTE: this can happen either when a link was an orphan
|
// NOTE: this can happen either when a link was an orphan
|
||||||
// or if the new page path shadowed the original
|
// or if the new page path shadowed the original
|
||||||
@ -236,7 +241,7 @@ var Wiki = {
|
|||||||
return lnk
|
return lnk
|
||||||
|
|
||||||
// skip links that do not resolve to target...
|
// skip links that do not resolve to target...
|
||||||
} else if(page.get(p).acquire(t) != l){
|
} else if(page.get(p).acquire('./'+t) != l){
|
||||||
return lnk
|
return lnk
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,9 +258,9 @@ var Wiki = {
|
|||||||
} else if(ndir == odir){
|
} else if(ndir == odir){
|
||||||
// conflict: the new link will not resolve to the
|
// conflict: the new link will not resolve to the
|
||||||
// target page...
|
// target page...
|
||||||
if(page.get(p).acquire(ntitle) != value){
|
if(page.get(p).acquire('./'+ntitle) != value){
|
||||||
console.log('ERR:', lnk, '->', to,
|
console.log('ERR:', lnk, '->', to,
|
||||||
'is shadowed by:', page.get(p).acquire(ntitle))
|
'is shadowed by:', page.get(p).acquire('./'+ntitle))
|
||||||
// XXX should we add a note to the link???
|
// XXX should we add a note to the link???
|
||||||
redirect = true
|
redirect = true
|
||||||
|
|
||||||
@ -379,17 +384,18 @@ var Wiki = {
|
|||||||
exists: function(path){
|
exists: function(path){
|
||||||
return normalizePath(path) in this.__wiki_data },
|
return normalizePath(path) in this.__wiki_data },
|
||||||
// get title from dir and then go up the tree...
|
// get title from dir and then go up the tree...
|
||||||
acquire: function(title, no_default){
|
acquire: function(path, no_default){
|
||||||
title = title || this.title
|
|
||||||
|
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
|
// handle paths and relative paths...
|
||||||
|
var p = this.get(path)
|
||||||
|
var title = p.title
|
||||||
|
path = path2lst(p.dir)
|
||||||
|
|
||||||
var acquire_from = this.__acquesition_order__ || []
|
var acquire_from = this.__acquesition_order__ || []
|
||||||
var post_acquire_from = this.__post_acquesition_order__ || []
|
var post_acquire_from = this.__post_acquesition_order__ || []
|
||||||
var data = this.__wiki_data
|
var data = this.__wiki_data
|
||||||
|
|
||||||
// XXX should this be .dir or .path???
|
|
||||||
var path = path2lst(this.dir)
|
|
||||||
|
|
||||||
var _get = function(path, title, lst){
|
var _get = function(path, title, lst){
|
||||||
lst = (lst == null || lst.length == 0) ? [''] : lst
|
lst = (lst == null || lst.length == 0) ? [''] : lst
|
||||||
for(var i=0; i < lst.length; i++){
|
for(var i=0; i < lst.length; i++){
|
||||||
@ -426,11 +432,7 @@ var Wiki = {
|
|||||||
|
|
||||||
// NOTE: this may be null...
|
// NOTE: this may be null...
|
||||||
return p
|
return p
|
||||||
|| (!no_default ? this.acquire(this.__default_page__) : null)
|
|| (!no_default ? this.acquire('./'+this.__default_page__) : null)
|
||||||
},
|
|
||||||
|
|
||||||
get data(){
|
|
||||||
return this.__wiki_data[this.acquire()]
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user