From 7af3f9d742ae1230dfdf1650c9fe1abbd36587b8 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 10 Oct 2016 04:30:47 +0300 Subject: [PATCH] moving to gen2, not done yet... Signed-off-by: Alex A. Naanou --- index2.html | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++ macro.js | 50 ++++++++++++++++++++--- pwiki.js | 38 ++++++++++++++---- 3 files changed, 188 insertions(+), 12 deletions(-) create mode 100755 index2.html diff --git a/index2.html b/index2.html new file mode 100755 index 0000000..68a945f --- /dev/null +++ b/index2.html @@ -0,0 +1,112 @@ + + + +pWiki + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + diff --git a/macro.js b/macro.js index f12f71c..a64ef54 100755 --- a/macro.js +++ b/macro.js @@ -8,6 +8,41 @@ /*********************************************************************/ +var setWikiWords = function(text, show_brackets, skip){ + skip = skip || [] + skip = skip instanceof Array ? skip : [skip] + return text + // set new... + .replace( + macro.__wiki_link__, + function(l){ + // check if wikiword is escaped... + if(l[0] == '\\'){ + return l.slice(1) + } + + 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 ? path : l) + +'') + : l + })} + + /*********************************************************************/ @@ -58,6 +93,14 @@ module = { 'editor', ], + // XXX should this be here??? + __wiki_link__: RegExp('('+[ + '\\\\?(\\./|\\.\\./|[A-Z][a-z0-9]+[A-Z/])[a-zA-Z0-9/]*', + '\\\\?\\[[^\\]]+\\]', + ].join('|') +')', 'g'), + + + // Macros... // // XXX add support for sort and reverse attrs in all relavant macros @@ -379,6 +422,8 @@ module = { // 1) set it H1 if it is the first tag in .text // 2) set it to .location // + // NOTE: we do not set the title tag here because this will be + // done for every included page... title: function(context, elem){ elem = $(elem) var title = elem.find('.text h1').first() @@ -387,11 +432,6 @@ module = { if(elem.find('.text').text().trim().indexOf(title.text().trim()) == 0){ title.detach() elem.find('.title').html(title.html()) - $('title').html(title.text()) - - // show location... - } else { - $('title').text(context.location) } return elem diff --git a/pwiki.js b/pwiki.js index 09ebfb7..cc0004e 100755 --- a/pwiki.js +++ b/pwiki.js @@ -121,9 +121,11 @@ module.BaseData = { 'System/text': function(){ return { text: this.get('..').text() } }, // XXX update these to the new format -- must return an object... - /* // XXX move this to Wiki.children + rename... + // XXX 'System/list': function(){ + return 'NoImplemented' + var p = this.dir return Object.keys(this.__wiki_data) @@ -139,7 +141,10 @@ module.BaseData = { .join('
') }, // list links to this page... + // XXX 'System/links': function(){ + return 'NoImplemented' + var that = this var p = this.dir @@ -159,7 +164,6 @@ module.BaseData = { .sort() .join('
') }, - //*/ // Page modifiers/actions... // XXX these needs redirecting... @@ -1310,6 +1314,7 @@ var pWikiUIActions = actions.Actions({ '.title': function(elems){ var client = this var wiki = this.page + elems .focus(function(){ var to = $(this).attr('saveto') || '.' @@ -1332,11 +1337,16 @@ var pWikiUIActions = actions.Actions({ client.reload() }) + + /* XXX this messes up history for some reason... + $('title').text(elems.first().text()) + //*/ }, // raw text editor... '.raw': function(elems){ var client = this var wiki = this.page + elems .focus(function(){ var to = $(this).attr('saveto') || '.' @@ -1358,6 +1368,7 @@ var pWikiUIActions = actions.Actions({ 'input[type="checkbox"].state': function(elems){ var client = this var wiki = this.page + elems // initial state... .each(function(){ @@ -1384,7 +1395,7 @@ var pWikiUIActions = actions.Actions({ //client.save() }) }, - } + }, location: ['', function(path){ @@ -1404,6 +1415,8 @@ var pWikiUIActions = actions.Actions({ page.location(path) + this.dom.attr('wiki-active', 'no') + this.reload() }], reload: ['', @@ -1412,9 +1425,10 @@ var pWikiUIActions = actions.Actions({ var page = this.page this.dom + .empty() // update path and render page... // XXX revise the default view approach... - .html(page.title()[0] == '_' ? + .append(page.title()[0] == '_' ? page.text() : page.get('./_view').text()) // activate page controls... @@ -1438,9 +1452,10 @@ var pWikiUIActions = actions.Actions({ || pWikiUIActions.__dom_filters__ // apply dom filters... - Object.keys(filters).forEach(function(pattern){ - filters[pattern].call(that, dom.find(pattern)) - }) + Object.keys(filters) + .forEach(function(pattern){ + // XXX for some reason this works but has no effect... + filters[pattern].call(that, dom.find(pattern)) }) }], /* @@ -1472,6 +1487,15 @@ var pWikiUI = pWikiFeatures.Feature({ }) +// XXX STUB: not sure if this is the right way... +var pWikiClient = +module.pWikiClient = object.makeConstructor('pWikiClient', + actions.mix( + // XXX not sure if we need this here... + //actions.MetaActions, + pWikiUIActions)) + + /*********************************************************************/