From 5a95f8c8abe5f50edffa2223a18366c8f07c5d25 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 1 Aug 2016 19:49:46 +0300 Subject: [PATCH] internal css support + noscript filter + tweaks... Signed-off-by: Alex A. Naanou --- index.html | 9 +++++++-- wiki.js | 57 +++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index c60a821..b380c07 100755 --- a/index.html +++ b/index.html @@ -53,8 +53,13 @@ var update_editor = function(){ .focus(function(){ $(this).text(Wiki.title) }) - .blur(() => { - Wiki.title = $('.title').text() + .blur(function(){ + var text = $(this).text().trim() + if(text[0] == '/'){ + Wiki.path = text + } else { + Wiki.title = text + } reload() }) diff --git a/wiki.js b/wiki.js index c790ec7..1456e5b 100755 --- a/wiki.js +++ b/wiki.js @@ -110,6 +110,7 @@ var macro = { // NOTE: these are added AFTER the user defined filters... __filters__: [ 'wikiword', + 'noscript', ], // Macros... @@ -326,6 +327,21 @@ var macro = { wikiword: function(context, elem){ return $('') .html(setWikiWords($(elem).html(), true, this.__include_marker__)) }, + noscript: function(context, elem){ + return $(elem) + // remove script tags... + .find('script') + .remove() + .end() + // remove js links... + .find('[href]') + .filter(function(i, e){ return /javascript:/i.test($(e).attr('href')) }) + .attr('href', '#') + .end() + .end() + // remove event handlers... + // XXX .off() will not work here as we need to remove on* handlers... + }, // XXX move this to a plugin... @@ -639,6 +655,24 @@ var BaseData = { // // XXX add .json support... var data = { + // System pages... + 'System/style': { + text: '' + +'.button {\n' + +' text-decoration: none;\n' + +' margin: 5px;\n' + +'}\n' + +'\n' + +'.separator~* {\n' + +' float: right;\n' + +'}\n' + +'', + }, + 'System/settings': { + text: JSON.stringify({}), + }, + + // Templates... 'Templates': { text: '@filter(nl2br)' +'XXX Genereal template description...\n' @@ -650,7 +684,6 @@ var data = { +'\n' +'\n', }, - 'Templates/EmptyPage': { text: '' +'\n' @@ -661,28 +694,35 @@ var data = { +'@include(./links)' +'

\n' +'\n', }, - 'Templates/pages': { text: ' [@source(./path)]
\n' }, 'Templates/tree': { text: ' [@source(./path)]
\n' }, - 'Templates/_raw': { text: '@source(..)', }, - + 'Templates/_css': { + text: '', + }, 'Templates/_view': { text: '\n' + +'@include(style/_css)\n' +'\n' +'
\n' - +' \n' + +' \n' +'[@source(../path)]\n' +'\n' +'\n' +'(edit)\n' +'\n' + +'\n' + +'\n' + +'\n' + +'+\n' +'
\n' +'\n' +'
\n' @@ -797,9 +837,12 @@ var Wiki = { .replace(/^\*|([^.])\*/g, '$1[^\\/]*') +'$') - return Object.keys(this.__wiki_data) + var data = this.__wiki_data + return Object.keys(data) // XXX is this correct??? - .concat(Object.keys(this.__wiki_data.__proto__)) + .concat(Object.keys(data.__proto__) + // do not repeat overloaded stuff... + .filter(function(e){ return !data.hasOwnProperty(e) })) .map(function(p){ return tail != '' ? normalizePath(p +'/'+ tail) : p })