mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-18 17:11:38 +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 = () => {
|
var reload = () => {
|
||||||
|
|
||||||
$('.wiki')
|
$('.wiki')
|
||||||
.html(Wiki.get('./_view').text)
|
.html(Wiki.title[0] == '_' ? Wiki.text : Wiki.get('./_view').text)
|
||||||
|
.ready(update_editor)
|
||||||
|
|
||||||
// XXX save...
|
// XXX save...
|
||||||
localStorage['wiki-data'] = JSON.stringify(Wiki.__wiki_data)
|
localStorage['wiki-data'] = JSON.stringify(Wiki.__wiki_data)
|
||||||
@ -34,28 +35,33 @@ var update_editor = function(){
|
|||||||
// XXX make this update on enter...
|
// XXX make this update on enter...
|
||||||
$('.title')
|
$('.title')
|
||||||
.on('blur', () => {
|
.on('blur', () => {
|
||||||
Wiki.title = $('.title').text()
|
//Wiki.title = $('.title').text()
|
||||||
reload()
|
//reload()
|
||||||
})
|
})
|
||||||
|
|
||||||
// live update text...
|
// live update text...
|
||||||
// XXX is this the right way to go for large documents???
|
// XXX is this the right way to go for large documents???
|
||||||
$('.text')
|
$('.text')
|
||||||
.focus(() => {
|
.focus(function(){
|
||||||
console.log('EDITING...')
|
console.log('EDITING:', Wiki.path)
|
||||||
$('.text').prop('contenteditable', $('.text').prop('contenteditable') != 'true')
|
|
||||||
reload()
|
$(this)
|
||||||
|
.prop('contenteditable', 'true')
|
||||||
|
.html(Wiki.raw)
|
||||||
|
|
||||||
|
//reload()
|
||||||
})
|
})
|
||||||
.on('keyup', () => {
|
.on('keyup', () => {
|
||||||
if($('.text').prop('contenteditable') == 'true'){
|
console.log('SAVING:', Wiki.path)
|
||||||
Wiki.raw = clearWikiWords($('.text').clone()).html()
|
//if($(this).prop('contenteditable') == 'true'){
|
||||||
}
|
// Wiki.raw = clearWikiWords($('.text').clone()).html()
|
||||||
|
//}
|
||||||
})
|
})
|
||||||
// XXX do this live, but on a timeout after user input...
|
// XXX do this live, but on a timeout after user input...
|
||||||
// XXX need to place the cursor in the same position...
|
// XXX need to place the cursor in the same position...
|
||||||
.blur(() => {
|
.blur(() => {
|
||||||
$('.text').prop('contenteditable', false)
|
$(this).removeAttr('contenteditable')
|
||||||
reload()
|
//reload()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,13 +71,14 @@ var go = (path) => {
|
|||||||
path = path.trim()
|
path = path.trim()
|
||||||
path = path[0] == '[' ? path.slice(1, -1) : path
|
path = path[0] == '[' ? path.slice(1, -1) : path
|
||||||
|
|
||||||
|
Wiki.location = path
|
||||||
|
|
||||||
history.pushState({
|
history.pushState({
|
||||||
wikipath: path
|
wikipath: Wiki.location
|
||||||
},
|
},
|
||||||
Wiki.title,
|
Wiki.title,
|
||||||
window.location)
|
window.location)
|
||||||
|
|
||||||
Wiki.location = path
|
|
||||||
reload()
|
reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +102,7 @@ $(() => {
|
|||||||
|
|
||||||
//update_editor()
|
//update_editor()
|
||||||
|
|
||||||
|
// XXX need to resolve relative hashes...
|
||||||
$(window).on('hashchange', function(evt){
|
$(window).on('hashchange', function(evt){
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
|
|
||||||
@ -116,11 +124,6 @@ $(() => {
|
|||||||
|
|
||||||
<div class="wiki"></div>
|
<div class="wiki"></div>
|
||||||
|
|
||||||
<!--div class="path"></div>
|
|
||||||
<hr>
|
|
||||||
<h1 class="title" contenteditable tabindex=0></h1>
|
|
||||||
<div class="text" tabindex=0></div-->
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<!-- vim:set sw=4 ts=4 : -->
|
<!-- 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 path = l[0] == '[' ? l.slice(1, -1) : l
|
||||||
var i = [].slice.call(arguments).slice(-2)[0]
|
var i = [].slice.call(arguments).slice(-2)[0]
|
||||||
|
|
||||||
/*
|
|
||||||
// XXX HACK check if we are inside a tag...
|
// XXX HACK check if we are inside a tag...
|
||||||
var rest = text.slice(i+1)
|
var rest = text.slice(i+1)
|
||||||
if(rest.indexOf('>') < rest.indexOf('<')){
|
if(rest.indexOf('>') < rest.indexOf('<')){
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
//*/
|
|
||||||
|
|
||||||
return skip.indexOf(l) < 0 ?
|
return skip.indexOf(l) < 0 ?
|
||||||
('<a '
|
('<a '
|
||||||
+'class="wikiword" '
|
+'class="wikiword" '
|
||||||
+'href="#'+ path +'" '
|
+'href="#'+ path +'" '
|
||||||
+'bracketed="'+ (show_brackets && l[0] == '[' ? 'yes' : 'no') +'" '
|
+'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)
|
+ (!!show_brackets ? path : l)
|
||||||
+'</a>')
|
+'</a>')
|
||||||
@ -442,34 +440,43 @@ var BaseData = {
|
|||||||
// XXX add .json support...
|
// XXX add .json support...
|
||||||
var data = {
|
var data = {
|
||||||
'Templates/EmptyPage': {
|
'Templates/EmptyPage': {
|
||||||
text: 'Page @include(./path) is empty.' +'<br><br>'
|
text: ''
|
||||||
+'Links to this page:' +'<br>'
|
+'<!-- place filters here so as not to takup page space: ... -->\n'
|
||||||
+'@include(./links)' +'<br><br>'
|
+'\n'
|
||||||
+'---' +'<br>'
|
+'Page @include(./path) is empty.' +'<br><br>\n'
|
||||||
+'WikiHome',
|
+'\n'
|
||||||
|
+'Links to this page:' +'<br>\n'
|
||||||
|
+'@include(./links)' +'<br><br>\n'
|
||||||
|
+'\n',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'Templates/_raw': {
|
||||||
|
text: '@source(..)',
|
||||||
|
},
|
||||||
'Templates/_view': {
|
'Templates/_view': {
|
||||||
text: '\n'
|
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'
|
+'<hr>\n'
|
||||||
+'<h1 class="title" contenteditable tabindex="0">@include(../title)</h1>\n'
|
+'<h1 class="title" contenteditable tabindex="0">@include(../title)</h1>\n'
|
||||||
+'<br>\n'
|
+'<br>\n'
|
||||||
+'<div class="text" tabindex="0">@include(..)</div>\n'
|
+'<div class="text" tabindex="0">@include(..)</div>\n'
|
||||||
+'<script>\n'
|
+'<hr>\n'
|
||||||
+' update_editor()\n'
|
+'<a href="#">home</a>\n'
|
||||||
+'</script>\n'
|
|
||||||
+'\n',
|
+'\n',
|
||||||
},
|
},
|
||||||
'Templates/_edit': {
|
'Templates/_edit': {
|
||||||
text: '\n'
|
text: '\n'
|
||||||
+'<div>/@include(../path) ([../_view])</div>\n'
|
+'<!-- @filter(-wikiword) -->\n'
|
||||||
|
+'\n'
|
||||||
|
+'<div>/@include(../path) (<a href="#..">view</a>)</div>\n'
|
||||||
+'<hr>\n'
|
+'<hr>\n'
|
||||||
+'<h1 contenteditable>@include(../title)</h1>\n'
|
+'<h1 class ="title" contenteditable>@include(../title)</h1>\n'
|
||||||
+'<br>\n'
|
+'<br>\n'
|
||||||
+'<div class="raw" contenteditable>@include(../raw)</div>\n'
|
+'<code><pre class="text" contenteditable>@source(../raw)</pre></code>\n'
|
||||||
+'<script>\n'
|
+'<script>\n'
|
||||||
+'\t$(".raw").text($(".raw").html())\n'
|
+'\t$(".text").text($(".text").html())\n'
|
||||||
+'</script>\n'
|
+'</script>\n'
|
||||||
+'',
|
+'',
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user