mirror of
https://github.com/flynx/pWiki.git
synced 2026-01-08 19:11:09 +00:00
refactoring (.text() -> .html()) and work on .links(..)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
e29edc403f
commit
354f26acd8
@ -2,7 +2,7 @@
|
|||||||
XXX Genereal template description...
|
XXX Genereal template description...
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<macro src="./*">
|
<macro name="show-source" src="./*">
|
||||||
<hr>
|
<hr>
|
||||||
<h2>
|
<h2>
|
||||||
<a href="#@source(./path)/_edit">@source(./path)</a>
|
<a href="#@source(./path)/_edit">@source(./path)</a>
|
||||||
@ -12,5 +12,7 @@ XXX Genereal template description...
|
|||||||
</p>
|
</p>
|
||||||
</macro>
|
</macro>
|
||||||
|
|
||||||
|
<macro name="show-source" src="System/style"/>
|
||||||
|
|
||||||
<!-- @filter(-wikiword) -->
|
<!-- @filter(-wikiword) -->
|
||||||
<!-- vim:set ts=4 sw=4 : -->
|
<!-- vim:set ts=4 sw=4 : -->
|
||||||
|
|||||||
65
pwiki.js
65
pwiki.js
@ -118,7 +118,7 @@ module.BaseData = {
|
|||||||
// is the same as:
|
// is the same as:
|
||||||
// .get('.').raw
|
// .get('.').raw
|
||||||
'System/raw': function(){ return { text: this.get('..').raw() } },
|
'System/raw': function(){ return { text: this.get('..').raw() } },
|
||||||
'System/text': function(){ return { text: this.get('..').text() } },
|
'System/html': function(){ return { text: this.get('..').html() } },
|
||||||
|
|
||||||
// XXX update these to the new format -- must return an object...
|
// XXX update these to the new format -- must return an object...
|
||||||
// XXX move this to Wiki.children + rename...
|
// XXX move this to Wiki.children + rename...
|
||||||
@ -141,20 +141,24 @@ module.BaseData = {
|
|||||||
.join('<br>')
|
.join('<br>')
|
||||||
},
|
},
|
||||||
// list links to this page...
|
// list links to this page...
|
||||||
// XXX
|
// XXX this is done, though we cant use this until we solve .html(..)
|
||||||
|
// macro recursion issues...
|
||||||
'System/links': function(){
|
'System/links': function(){
|
||||||
return 'NoImplemented'
|
return 'NoImplemented'
|
||||||
|
|
||||||
var that = this
|
var that = this
|
||||||
var p = this.dir
|
var p = this.path()
|
||||||
|
|
||||||
var res = []
|
var res = []
|
||||||
|
|
||||||
var wiki = this.__wiki_data
|
this.wiki.match('**')
|
||||||
Object.keys(wiki).forEach(function(k){
|
.forEach(function(p){
|
||||||
(wiki[k].links || []).forEach(function(l){
|
var pa = that.acquire(p)
|
||||||
(l == p || that.get(path2lst(l).slice(0, -1)).acquire('./'+path2lst(l).pop()) == p)
|
|
||||||
&& res.push([l, k])
|
that.get(p).links().forEach(function(l){
|
||||||
|
var la = that.acquire(l)
|
||||||
|
if(l == p || la == p || la == pa){
|
||||||
|
res.push([l, p])
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -1034,25 +1038,46 @@ module.pWikiMacros = actions.Actions(pWikiBase, {
|
|||||||
config: {
|
config: {
|
||||||
},
|
},
|
||||||
|
|
||||||
text: ['Page/',
|
html: ['Page/',
|
||||||
function(value){
|
function(value){
|
||||||
|
// get...
|
||||||
return arguments.length == 0 ?
|
return arguments.length == 0 ?
|
||||||
(this.title() == 'raw' ?
|
(this.title() == 'raw' ?
|
||||||
|
// special case -- if title is 'raw' then return text as-is...
|
||||||
(this.raw() || '')
|
(this.raw() || '')
|
||||||
|
// parse macros...
|
||||||
: (this.__macro_parser__ || pWikiMacros.__macro_parser__)
|
: (this.__macro_parser__ || pWikiMacros.__macro_parser__)
|
||||||
.parse(this, this.raw()))
|
.parse(this, this.raw()))
|
||||||
: this.raw(value) }],
|
|
||||||
|
// set...
|
||||||
|
: this
|
||||||
|
// clear cached stuff related to text...
|
||||||
|
.attr('links', undefined)
|
||||||
|
// set the value...
|
||||||
|
.raw(value) }],
|
||||||
code: ['Page/',
|
code: ['Page/',
|
||||||
function(value){
|
function(value){
|
||||||
return arguments.length == 0 ?
|
return arguments.length == 0 ?
|
||||||
this.text().text()
|
this.html().text()
|
||||||
// XXX should we un-encode here???
|
// XXX should we un-encode here???
|
||||||
: this.text(value) }],
|
: this.html(value) }],
|
||||||
|
links: ['Page/List links from page',
|
||||||
// XXX
|
function(force){
|
||||||
links: ['Page/',
|
// get and cache links...
|
||||||
function(){
|
if(force || this.attr('links') == null){
|
||||||
// XXX
|
var text = this.html()
|
||||||
|
var links = typeof(text) == typeof('str') ? []
|
||||||
|
: text.find('[href]')
|
||||||
|
.map(function(){
|
||||||
|
var url = $(this).attr('href')
|
||||||
|
return url[0] == '#' ? url.slice(1) : null
|
||||||
|
})
|
||||||
|
.toArray()
|
||||||
|
this.attr('links', links)
|
||||||
|
return links
|
||||||
|
}
|
||||||
|
// get cached links...
|
||||||
|
return this.attr('links')
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
|
||||||
@ -1455,8 +1480,8 @@ var pWikiUIActions = actions.Actions({
|
|||||||
// update path and render page...
|
// update path and render page...
|
||||||
// XXX revise the default view approach...
|
// XXX revise the default view approach...
|
||||||
.append(page.title()[0] == '_' ?
|
.append(page.title()[0] == '_' ?
|
||||||
page.text()
|
page.html()
|
||||||
: page.get('./_view').text())
|
: page.get('./_view').html())
|
||||||
// activate page controls...
|
// activate page controls...
|
||||||
.ready(function(){
|
.ready(function(){
|
||||||
that.updateDom()
|
that.updateDom()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user