mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-17 00:21:40 +00:00
tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
0e4703b1b3
commit
82d9cb4d8a
41
index.html
41
index.html
@ -21,7 +21,8 @@ var clear = () => {
|
||||
var reload = () => {
|
||||
|
||||
$('.wiki')
|
||||
.html(Wiki.get('./_view').text)
|
||||
.html(Wiki.title[0] == '_' ? Wiki.text : Wiki.get('./_view').text)
|
||||
.ready(update_editor)
|
||||
|
||||
// XXX save...
|
||||
localStorage['wiki-data'] = JSON.stringify(Wiki.__wiki_data)
|
||||
@ -34,28 +35,33 @@ var update_editor = function(){
|
||||
// XXX make this update on enter...
|
||||
$('.title')
|
||||
.on('blur', () => {
|
||||
Wiki.title = $('.title').text()
|
||||
reload()
|
||||
//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()
|
||||
.focus(function(){
|
||||
console.log('EDITING:', Wiki.path)
|
||||
|
||||
$(this)
|
||||
.prop('contenteditable', 'true')
|
||||
.html(Wiki.raw)
|
||||
|
||||
//reload()
|
||||
})
|
||||
.on('keyup', () => {
|
||||
if($('.text').prop('contenteditable') == 'true'){
|
||||
Wiki.raw = clearWikiWords($('.text').clone()).html()
|
||||
}
|
||||
console.log('SAVING:', Wiki.path)
|
||||
//if($(this).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()
|
||||
$(this).removeAttr('contenteditable')
|
||||
//reload()
|
||||
})
|
||||
}
|
||||
|
||||
@ -65,13 +71,14 @@ var go = (path) => {
|
||||
path = path.trim()
|
||||
path = path[0] == '[' ? path.slice(1, -1) : path
|
||||
|
||||
Wiki.location = path
|
||||
|
||||
history.pushState({
|
||||
wikipath: path
|
||||
wikipath: Wiki.location
|
||||
},
|
||||
Wiki.title,
|
||||
window.location)
|
||||
|
||||
Wiki.location = path
|
||||
reload()
|
||||
}
|
||||
|
||||
@ -95,6 +102,7 @@ $(() => {
|
||||
|
||||
//update_editor()
|
||||
|
||||
// XXX need to resolve relative hashes...
|
||||
$(window).on('hashchange', function(evt){
|
||||
evt.preventDefault()
|
||||
|
||||
@ -116,11 +124,6 @@ $(() => {
|
||||
|
||||
<div class="wiki"></div>
|
||||
|
||||
<!--div class="path"></div>
|
||||
<hr>
|
||||
<h1 class="title" contenteditable tabindex=0></h1>
|
||||
<div class="text" tabindex=0></div-->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<!-- vim:set sw=4 ts=4 : -->
|
||||
|
||||
39
wiki.js
39
wiki.js
@ -45,20 +45,18 @@ var setWikiWords = function(text, show_brackets, skip){
|
||||
var path = l[0] == '[' ? l.slice(1, -1) : l
|
||||
var i = [].slice.call(arguments).slice(-2)[0]
|
||||
|
||||
/*
|
||||
// XXX HACK check if we are inside a tag...
|
||||
var rest = text.slice(i+1)
|
||||
if(rest.indexOf('>') < rest.indexOf('<')){
|
||||
return l
|
||||
}
|
||||
//*/
|
||||
|
||||
return skip.indexOf(l) < 0 ?
|
||||
('<a '
|
||||
+'class="wikiword" '
|
||||
+'href="#'+ path +'" '
|
||||
+'bracketed="'+ (show_brackets && l[0] == '[' ? 'yes' : 'no') +'" '
|
||||
+'onclick="go($(this).attr(\'href\').slice(1))" '
|
||||
//+'onclick="event.preventDefault(); go($(this).attr(\'href\').slice(1))" '
|
||||
+'>'
|
||||
+ (!!show_brackets ? path : l)
|
||||
+'</a>')
|
||||
@ -442,34 +440,43 @@ var BaseData = {
|
||||
// XXX add .json support...
|
||||
var data = {
|
||||
'Templates/EmptyPage': {
|
||||
text: 'Page @include(./path) is empty.' +'<br><br>'
|
||||
+'Links to this page:' +'<br>'
|
||||
+'@include(./links)' +'<br><br>'
|
||||
+'---' +'<br>'
|
||||
+'WikiHome',
|
||||
text: ''
|
||||
+'<!-- place filters here so as not to takup page space: ... -->\n'
|
||||
+'\n'
|
||||
+'Page @include(./path) is empty.' +'<br><br>\n'
|
||||
+'\n'
|
||||
+'Links to this page:' +'<br>\n'
|
||||
+'@include(./links)' +'<br><br>\n'
|
||||
+'\n',
|
||||
},
|
||||
|
||||
'Templates/_raw': {
|
||||
text: '@source(..)',
|
||||
},
|
||||
'Templates/_view': {
|
||||
text: '\n'
|
||||
+'<div class="path">@include(../path) ([../_edit])</div>\n'
|
||||
+'<!-- place filters here so as not to takup page space: ... -->\n'
|
||||
+'\n'
|
||||
+'<div>/@include(../path) (<a href="#./_edit">edit</a>)</div>\n'
|
||||
+'<hr>\n'
|
||||
+'<h1 class="title" contenteditable tabindex="0">@include(../title)</h1>\n'
|
||||
+'<br>\n'
|
||||
+'<div class="text" tabindex="0">@include(..)</div>\n'
|
||||
+'<script>\n'
|
||||
+' update_editor()\n'
|
||||
+'</script>\n'
|
||||
+'<hr>\n'
|
||||
+'<a href="#">home</a>\n'
|
||||
+'\n',
|
||||
},
|
||||
'Templates/_edit': {
|
||||
text: '\n'
|
||||
+'<div>/@include(../path) ([../_view])</div>\n'
|
||||
+'<!-- @filter(-wikiword) -->\n'
|
||||
+'\n'
|
||||
+'<div>/@include(../path) (<a href="#..">view</a>)</div>\n'
|
||||
+'<hr>\n'
|
||||
+'<h1 contenteditable>@include(../title)</h1>\n'
|
||||
+'<h1 class ="title" contenteditable>@include(../title)</h1>\n'
|
||||
+'<br>\n'
|
||||
+'<div class="raw" contenteditable>@include(../raw)</div>\n'
|
||||
+'<code><pre class="text" contenteditable>@source(../raw)</pre></code>\n'
|
||||
+'<script>\n'
|
||||
+'\t$(".raw").text($(".raw").html())\n'
|
||||
+'\t$(".text").text($(".text").html())\n'
|
||||
+'</script>\n'
|
||||
+'',
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user