mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-19 01:21:38 +00:00
started move to hosted editor/viewer...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
cf32b82ef2
commit
77234a7c58
74
index.html
74
index.html
@ -20,6 +20,16 @@ var clear = () => {
|
|||||||
|
|
||||||
|
|
||||||
var reload = () => {
|
var reload = () => {
|
||||||
|
|
||||||
|
//*
|
||||||
|
//$('.wiki').html(Wiki.text)
|
||||||
|
//var editing = $('.text').prop('contenteditable') != 'false'
|
||||||
|
|
||||||
|
$('.wiki')
|
||||||
|
.html(Wiki.get('./_view').text)
|
||||||
|
//*/
|
||||||
|
|
||||||
|
/*
|
||||||
$('.path').text('/' + Wiki.path)
|
$('.path').text('/' + Wiki.path)
|
||||||
|
|
||||||
$('.title').text(Wiki.title)
|
$('.title').text(Wiki.title)
|
||||||
@ -112,6 +122,7 @@ var reload = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$('.text').html(setWikiWords(text, filters.indexOf('show_link_brackets') < 0 && editing))
|
$('.text').html(setWikiWords(text, filters.indexOf('show_link_brackets') < 0 && editing))
|
||||||
|
//*/
|
||||||
|
|
||||||
// XXX save...
|
// XXX save...
|
||||||
localStorage['wiki-data'] = JSON.stringify(Wiki.__wiki_data)
|
localStorage['wiki-data'] = JSON.stringify(Wiki.__wiki_data)
|
||||||
@ -120,7 +131,38 @@ var reload = () => {
|
|||||||
$('title').text(Wiki.location)
|
$('title').text(Wiki.location)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var update_editor = function(){
|
||||||
|
// XXX make this update on enter...
|
||||||
|
$('.title')
|
||||||
|
.on('blur', () => {
|
||||||
|
Wiki.title = $('.title').text()
|
||||||
|
reload()
|
||||||
|
})
|
||||||
|
|
||||||
|
// live update text...
|
||||||
|
// XXX is this the right way to go for large documents???
|
||||||
|
$('.text')
|
||||||
|
.focus(() => {
|
||||||
|
console.log('EDITING...')
|
||||||
|
$('.text').prop('contenteditable', $('.text').prop('contenteditable') != 'true')
|
||||||
|
reload()
|
||||||
|
})
|
||||||
|
.on('keyup', () => {
|
||||||
|
if($('.text').prop('contenteditable') == 'true'){
|
||||||
|
Wiki.raw = clearWikiWords($('.text').clone()).html()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// XXX do this live, but on a timeout after user input...
|
||||||
|
// XXX need to place the cursor in the same position...
|
||||||
|
.blur(() => {
|
||||||
|
$('.text').prop('contenteditable', false)
|
||||||
|
reload()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
var go = (path) => {
|
var go = (path) => {
|
||||||
|
console.log('GO:', path)
|
||||||
|
|
||||||
path = path.trim()
|
path = path.trim()
|
||||||
path = path[0] == '[' ? path.slice(1, -1) : path
|
path = path[0] == '[' ? path.slice(1, -1) : path
|
||||||
|
|
||||||
@ -152,40 +194,18 @@ $(() => {
|
|||||||
|
|
||||||
reload()
|
reload()
|
||||||
|
|
||||||
// XXX make this update on enter...
|
//update_editor()
|
||||||
$('.title')
|
|
||||||
.on('blur', () => {
|
|
||||||
Wiki.title = $('.title').text()
|
|
||||||
reload()
|
|
||||||
})
|
|
||||||
|
|
||||||
// live update text...
|
|
||||||
// XXX is this the right way to go for large documents???
|
|
||||||
$('.text')
|
|
||||||
.focus(() => {
|
|
||||||
$('.text').prop('contenteditable', $('.text').prop('contenteditable') != 'true')
|
|
||||||
reload()
|
|
||||||
})
|
|
||||||
.on('keyup', () => {
|
|
||||||
if($('.text').prop('contenteditable') == 'true'){
|
|
||||||
Wiki.raw = clearWikiWords($('.text').clone()).html()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// XXX do this live, but on a timeout after user input...
|
|
||||||
// XXX need to place the cursor in the same position...
|
|
||||||
.blur(() => {
|
|
||||||
$('.text').prop('contenteditable', false)
|
|
||||||
reload()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="path"></div>
|
<div class="wiki"></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-->
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
51
wiki.js
51
wiki.js
@ -118,16 +118,23 @@ var macro = {
|
|||||||
// ...if required this can be done via global and local
|
// ...if required this can be done via global and local
|
||||||
// filters... (now filters are only local)
|
// filters... (now filters are only local)
|
||||||
// XXX do we need to render just one slot??? (slot arg)
|
// XXX do we need to render just one slot??? (slot arg)
|
||||||
|
// XXX might be a good idea to wrap the result in a tag to enable
|
||||||
|
// in-place editing...
|
||||||
include_args: ['src'],
|
include_args: ['src'],
|
||||||
include: function(context, args, _, state){
|
include: function(context, args, _, state){
|
||||||
var path = args.src
|
var path = args.src
|
||||||
|
|
||||||
// XXX not sure if we need to render the source page relative
|
// get and prepare the included page...
|
||||||
// to this or as-is...
|
|
||||||
state.include
|
state.include
|
||||||
//.push(this.parse(context, context.get(path).raw))
|
.push(context.get(path))
|
||||||
.push(context.get(path).text)
|
/*
|
||||||
|
// XXX do we need to quote the path here??? ...might get wikiword-ed ;)
|
||||||
|
.push('<span class="include" src="'+path+'">'
|
||||||
|
+context.get(path).text
|
||||||
|
+'</span>')
|
||||||
|
//*/
|
||||||
|
|
||||||
|
// return the marker...
|
||||||
return this.__include_marker__
|
return this.__include_marker__
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -189,7 +196,7 @@ var macro = {
|
|||||||
text: function(context, text){ return $('<div>').text(text).html() },
|
text: function(context, text){ return $('<div>').text(text).html() },
|
||||||
|
|
||||||
wikiword: function(context, text){
|
wikiword: function(context, text){
|
||||||
return setWikiWords(text, null, this.__include_marker__) },
|
return setWikiWords(text, true, this.__include_marker__) },
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -255,11 +262,6 @@ var macro = {
|
|||||||
// macro stage 2...
|
// macro stage 2...
|
||||||
text = _parse(context, text, this.post_macro)
|
text = _parse(context, text, this.post_macro)
|
||||||
|
|
||||||
// XXX for some reason the next line parses WikiHome twice, once
|
|
||||||
// with -wikiword and oce without...
|
|
||||||
// $('body').html(Wiki.get('WikiHome/_view').text)
|
|
||||||
console.log('filters:', state.filters, text.slice(0, 60))
|
|
||||||
|
|
||||||
// filter stage....
|
// filter stage....
|
||||||
state.filters
|
state.filters
|
||||||
.concat(this.__filters__)
|
.concat(this.__filters__)
|
||||||
@ -294,7 +296,16 @@ var macro = {
|
|||||||
// merge includes...
|
// merge includes...
|
||||||
// XXX need to check for errors (includes too short/long)...
|
// XXX need to check for errors (includes too short/long)...
|
||||||
text = text.replace(RegExp(this.__include_marker__, 'g'), function(){
|
text = text.replace(RegExp(this.__include_marker__, 'g'), function(){
|
||||||
return state.include.shift()
|
var page = state.include.shift()
|
||||||
|
// NOTE: we are quoting html here, this is done to prevent
|
||||||
|
// included html from messing up the outer structure with
|
||||||
|
// things like unclosed tags and stuff...
|
||||||
|
// XXX can this be anything other than html?
|
||||||
|
return $('<span>')
|
||||||
|
.addClass('include')
|
||||||
|
.attr('src', page.path)
|
||||||
|
.html(page.text)[0]
|
||||||
|
.outerHTML
|
||||||
})
|
})
|
||||||
|
|
||||||
return text
|
return text
|
||||||
@ -404,11 +415,14 @@ var data = {
|
|||||||
|
|
||||||
'Templates/_view': {
|
'Templates/_view': {
|
||||||
text: '\n'
|
text: '\n'
|
||||||
+'<div>/@include(../path) ([../_edit])</div>\n'
|
+'<div class="path">@include(../path) ([../_edit])</div>\n'
|
||||||
+'<hr>\n'
|
+'<hr>\n'
|
||||||
+'<h1>@include(../title)</h1>\n'
|
+'<h1 class="title" contenteditable tabindex="0">@include(../title)</h1>\n'
|
||||||
+'<br>\n'
|
+'<br>\n'
|
||||||
+'<div>@include(../text)</div>\n'
|
+'<div class="text" tabindex="0">@include(..)</div>\n'
|
||||||
|
+'<script>\n'
|
||||||
|
+' update_editor()\n'
|
||||||
|
+'</script>\n'
|
||||||
+'\n',
|
+'\n',
|
||||||
},
|
},
|
||||||
'Templates/_edit': {
|
'Templates/_edit': {
|
||||||
@ -417,7 +431,7 @@ var data = {
|
|||||||
+'<hr>\n'
|
+'<hr>\n'
|
||||||
+'<h1 contenteditable>@include(../title)</h1>\n'
|
+'<h1 contenteditable>@include(../title)</h1>\n'
|
||||||
+'<br>\n'
|
+'<br>\n'
|
||||||
+'<div class="raw" contenteditable>@include(../text)</div>\n'
|
+'<div class="raw" contenteditable>@include(../raw)</div>\n'
|
||||||
+'<script>\n'
|
+'<script>\n'
|
||||||
+'\t$(".raw").text($(".raw").html())\n'
|
+'\t$(".raw").text($(".raw").html())\n'
|
||||||
+'</script>\n'
|
+'</script>\n'
|
||||||
@ -657,7 +671,12 @@ var Wiki = {
|
|||||||
this.__wiki_data[l].links = this.links
|
this.__wiki_data[l].links = this.links
|
||||||
},
|
},
|
||||||
|
|
||||||
get text(){ return macro.parse(this, this.raw) },
|
// XXX not sure if this should return special function result as-is...
|
||||||
|
// ...might be better to just special-case the 'raw' in path...
|
||||||
|
get text(){
|
||||||
|
// special case: if we are getting ./raw then do not parse text...
|
||||||
|
return this.title == 'raw' ? this.raw
|
||||||
|
: macro.parse(this, this.raw) },
|
||||||
|
|
||||||
|
|
||||||
// NOTE: this is set by setting .text
|
// NOTE: this is set by setting .text
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user