From 0e4703b1b31b3e0f47a5a47e8257e233aeec32f7 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 22 Jul 2016 21:46:23 +0300 Subject: [PATCH] make wikiwords passive... Signed-off-by: Alex A. Naanou --- index.html | 118 ++++++++--------------------------------------------- wiki.js | 39 +++++++++++++----- 2 files changed, 45 insertions(+), 112 deletions(-) diff --git a/index.html b/index.html index b3aa1da..c3efff3 100755 --- a/index.html +++ b/index.html @@ -8,6 +8,7 @@ + diff --git a/wiki.js b/wiki.js index becfe46..c29ef16 100755 --- a/wiki.js +++ b/wiki.js @@ -42,14 +42,25 @@ var setWikiWords = function(text, show_brackets, skip){ .replace( Wiki.__wiki_link__, function(l){ + 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 ? ('' - + (!!show_brackets && l[0] == '[' ? l.slice(1, -1) : l) + + (!!show_brackets ? path : l) +'') : l })} @@ -338,12 +349,12 @@ var macro = { // XXX not sure about these... // XXX add docs... var BaseData = { - // Macro acces to standard page attributes... - 'System/title': function(){ return this.get('..').title }, - 'System/path': function(){ return this.dir }, - 'System/dir': function(){ return this.get('..').dir }, - 'System/location': function(){ return this.dir }, - 'System/resolved': function(){ return this.get('..').acquire() }, + // Macro acces to standard page attributes (paths)... + 'System/title': function(){ return '['+ this.get('..').title +']' }, + 'System/path': function(){ return '['+ this.dir +']' }, + 'System/dir': function(){ return '['+ this.get('..').dir +']' }, + 'System/location': function(){ return '['+ this.dir +']' }, + 'System/resolved': function(){ return '['+ this.get('..').acquire() +']' }, // page data... // @@ -431,7 +442,7 @@ var BaseData = { // XXX add .json support... var data = { 'Templates/EmptyPage': { - text: 'Page [@include(./path)] is empty.' +'

' + text: 'Page @include(./path) is empty.' +'

' +'Links to this page:' +'
' +'@include(./links)' +'

' +'---' +'
' @@ -473,6 +484,7 @@ data.__proto__ = BaseData var Wiki = { __wiki_data: data, + __config_page__: 'System/config', __home_page__: 'WikiHome', __default_page__: 'EmptyPage', // Special sub-paths to look in on each level... @@ -520,6 +532,13 @@ var Wiki = { get data(){ return this.__wiki_data[this.acquire()] }, + /* + // XXX + get config(){ + return this.__wiki_data[this.__config_page__] || {} + }, + //*/ + // XXX clone: function(){