diff --git a/pwiki/page.js b/pwiki/page.js index 1c7d4c2..98c24e8 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -226,16 +226,20 @@ object.Constructor('BasePage', { to : '../'+to) }, - /*/ XXX TITLE... + /*/ XXX TITLE / EXPERIMENTAL... // NOTE: .__title is intentionally not persistent... __title: undefined, get title(){ return this.__title - ?? this.path }, + ?? this.name }, set title(value){ this.__title = value this.__update__({title: value}) }, //*/ + get title(){ + return pwpath.decodeElem(this.name) }, + set title(value){ + this.name = pwpath.encodeElem(value) }, get isPattern(){ return this.path.includes('*') }, @@ -316,10 +320,10 @@ object.Constructor('BasePage', { // single page... // XXX ENERGETIC... var res = await this.store.get(this.path, !!this.strict, !!await this.energetic) - /*/ XXX TITLE... + /*/ XXX TITLE / EXPERIMENTAL... // load the title if set... res.title - ?? (this.__title = res.title) + && (this.__title = res.title) //*/ return typeof(res) == 'function' ? res.bind(this) @@ -979,17 +983,21 @@ object.Constructor('Page', BasePage, { // this renders the src in the context of current page while // include is rendered in the context of its page but with // the same state... + // i.e. for @include(PATH) the paths within the included page + // are resolved relative to PATH while for @source(PATH) + // relative to the page containing the @source(..) statement... source: Macro( // XXX should this have the same args as include??? ['src', 'recursive', 'join', ['strict', 'nonstrict', 'isolated']], //['src'], async function*(args, body, state){ + var that = this yield* this.macros.include.call(this, 'source', args, body, state, 'sources', async function(src, state){ - return this.parse(this.get(src).raw, state) }) }), + return that.parse(that.get(src).raw, state) }) }), // // @quote() // @@ -1485,8 +1493,10 @@ object.Constructor('Page', BasePage, { // handle lists in pages (actions, ... etc.)... } else { var data = await page.data - data = typeof(data) == 'function' ? - data + data = + typeof(data) == 'function' ? + //data + await data() : 'text' in data ? data.text : null @@ -1496,6 +1506,9 @@ object.Constructor('Page', BasePage, { .map(function(p){ return page.virtual({text: p}) }) return } + // do not iterate pages/actions that are undefined... + if(data == null){ + return } yield page } }, @@ -1826,7 +1839,8 @@ module.System = { text: object.doc` - @source(./location/!) + + [@source(./location/!)] @@ -1837,6 +1851,7 @@ module.System = { ` }, // XXX add join... @@ -1885,15 +1900,17 @@ module.System = { +''}, //*/ edit: { + // XXX not sure if we should use .title or .name here... text: object.doc` - @include(_view) - @source(../path) + ../.. + @source(../location/!) +

- @source(./name) + oninput="saveContent(\'@source(./path)/title\', this.innerText)"> + @source(./title)


 			
 				
@@ -1940,7 +1958,7 @@ module.System = { ×
- @source("./tree:@(all)") + @include("./tree:@(all)")
` }, @@ -1997,6 +2015,20 @@ module.System = { QuoteActionPage: { text: '[ native code ]' }, + // XXX should this be in templates??? + // XXX for some reason this does not list files... + FlatNotes: { + text: object.doc` + + 🗎 + + + ` }, + // page actions... // diff --git a/pwiki/path.js b/pwiki/path.js index c757c96..2a65766 100755 --- a/pwiki/path.js +++ b/pwiki/path.js @@ -56,6 +56,11 @@ module = { .replace(/[#:*%]/g, encodeURIComponent) }, decode: function(str){ return decodeURIComponent(str) }, + encodeElem: function(str){ + return str + .replace(/[#:*%\\\/.]/g, encodeURIComponent) }, + decodeElem: function(str){ + return decodeURIComponent(str) }, /*/ XXX NORMCACHE... __normalized_cache_threshold: 100, @@ -106,14 +111,18 @@ module = { if(res.length == 0 && e == '..'){ return [e] } - ;(e == '.' + // multiple leading '..'... + ;(e == '..' + && res.at(-1) == '..' ? + res.push(e) + : e == '.' // keep explicit '/' only at start/end of path... || (e == '' && i != 0 && i != L.length-1)) ? undefined : e == '..' - || res[res.length-1] == '>>' ? + || res.at(-1) == '>>' ? ((res.length > 1 || res[0] != '') && res.pop()) @@ -158,10 +167,12 @@ module = { : 'string') : format path = this.split(path) - ;(path[0] == '' + // leading: '/', '.' and '..'... + while(path[0] == '' || path[0] == '.' - || path[0] == '..') - && path.shift() + || path[0] == '..'){ + path.shift() } + //trailing '/' path.at(-1) == '' && path.pop() return format == 'string' ? diff --git a/pwiki2.js b/pwiki2.js index e8ee6ec..01db776 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -6,11 +6,6 @@ * - fs store/export in browser or a simple way to export/import... * * -* XXX need page names to contain odd characters when created by user, for -* example: note titles... -* ...and need this to work through all the i/o... -* ....this might be an argument towards the .title attr, at least -* for notes... * XXX macros: should we add the pattern path to .depends instead of the * final path... * ...would also need a fast way to pattern match...