diff --git a/pwiki/page.js b/pwiki/page.js index b7d4df5..576f365 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -1059,7 +1059,7 @@ object.Constructor('Page', BasePage, { source: Macro( // XXX should this have the same args as include??? ['src', 'recursive', 'join', - ['s', 'strict', 'nonstrict', 'isolated']], + ['s', 'strict', 'nonstrict']], //['src'], async function*(args, body, state){ var that = this @@ -1069,6 +1069,21 @@ object.Constructor('Page', BasePage, { async function(src, state){ //return that.parse(that.get(src).raw, state) }) }), return that.parse(this.raw, state) }) }), + + // Load macro and slot definitions but ignore the page text... + // + // NOTE: this is essentially the same as @source(..) but returns ''. + // XXX revise name... + load: Macro( + ['src', ['strict', 'nonstrict']], + async function*(args, body, state){ + var that = this + yield* this.macros.include.call(this, + 'load', + args, body, state, 'sources', + async function(src, state){ + await that.parse(this.raw, state) + return '' }) }), // // @quote() // @@ -1248,6 +1263,7 @@ object.Constructor('Page', BasePage, { && stack.push(slots[name]) delete slots[name] var slot = await this.__parser__.expand(this, text, state) + var original = slot slots[name] && stack.unshift(slot) slot = slots[name] = @@ -1272,7 +1288,7 @@ object.Constructor('Page', BasePage, { '' : Object.assign( function(state){ - return state.slots[name] }, + return (state.slots || {})[name] ?? original }, {slot: name}) }), 'content': ['slot'], @@ -1304,7 +1320,8 @@ object.Constructor('Page', BasePage, { // XXX SORT sorting not implemented yet.... macro: Macro( ['name', 'src', 'sort', 'text', 'join', 'else', - ['strict', 'nonstrict']], + ['strict', 'nonstrict', 'isolated']], + //['strict', 'nonstrict', 'unisolated']], async function*(args, body, state){ var that = this var name = args.name //?? args[0] @@ -1323,6 +1340,8 @@ object.Constructor('Page', BasePage, { : text var strict = args.strict && !args.nonstrict + var isolated = args.isolated + //var isolated = !args.unisolated var join var depends = state.depends = @@ -1392,7 +1411,18 @@ object.Constructor('Page', BasePage, { if(join && !first){ yield join } first = false - yield this.__parser__.expand(page, text, state) } + if(isolated){ + var _state = { + seen: state.seen, + depends, + renderer: state.renderer, + } + // XXX this is ugly, can we avoid this??? + yield this.__parser__.resolve(page, + this.__parser__.expand(page, + text, _state), _state) + } else { + yield this.__parser__.expand(page, text, state) } } // else... if(first && (text || args['else'])){ @@ -2008,6 +2038,32 @@ module.System = { `}, + // XXX remove when bug (quote getting trash) fixed... + edit_isolated: { + // XXX not sure if we should use .title or .name here... + text: object.doc` + + @source(../title) (edit) + + + ../.. + @source(../location/!) + + + +

+ @source(./title) +

+
+
+
`}, + // XXX debug... _path: {text: '@source(./path/! join=" ")'}, _location: {text: '@source(./location/! join=" ")'}, diff --git a/pwiki2.html b/pwiki2.html index 0763783..b411a3c 100755 --- a/pwiki2.html +++ b/pwiki2.html @@ -244,7 +244,7 @@ require.config({ var STYLE_UPDATED = false var updateStyle = async function(){ document.querySelector('#style').innerHTML = - await pwiki.get('/.config/Style/_raw').text } + await pwiki.get('/.config/Style/_text').text } //*/ // XXX might be a good idea to make this a method of pwiki??? @@ -253,7 +253,7 @@ var updateConfig = async function(){ // XXX need to set this to something... // XXX // XXX need to use a parser that supports comments and stuff... - return JSON.parse(await pwiki.get('/.config/Config/_raw').text) } + return JSON.parse(await pwiki.get('/.config/Config/_text').text) } // XXX versioning?? diff --git a/pwiki2.js b/pwiki2.js index ab22b3c..152af47 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -18,7 +18,23 @@ * - CLI - * * -* XXX parser: might be a good idea to make slots local to macro by default... +* XXX BUG: in .system/edit if macro is isolated then @quote(..) will +* for some reason get odd stuff like '[object Object]'... +* these break: +* /QuoteTest/edit_isolated +* /MacroSlotTest/edit_isolated +* these work: +* /QuoteTest/edit +* /MacroSlotTest/edit +* ...can't produce a minimal example (/QuoteTest) other than +* editing .system/edit... +* ...seems that in isolated mode some macros get expanded before/in @quote(..) +* XXX remove .system/edit_isolated when done... +* XXX MACRO: should 's isolated be on by default??? +* ...do we need to isolate named macros too??? +* ...should this isolation be one-directional??? +* ...i.e. iterations see/overload things defined above but +* can not affect the above context... * XXX STYLE: should style loading be done via the event mechanics * (see: pwiki2.html) or via the base templates (see: pwiki/page.js:_view * template)??? @@ -396,6 +412,7 @@ * * * XXX DOC: +* - macro isolation in relation to slots... * - paths in pWiki behave a bit differently than traditional * file-system paths, this is due to one key distinction: * in pWiki there is no distinction between a file and a