From a6670280cd5e186d915c47c9e2c2674352484d7d Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 18 Sep 2022 20:12:18 +0300 Subject: [PATCH] more fixes and normalization.... Signed-off-by: Alex A. Naanou --- pwiki/page.js | 29 +++++++++++++++++++++++------ pwiki2.js | 12 ++++-------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/pwiki/page.js b/pwiki/page.js index 6b1f297..4554b27 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -1470,6 +1470,10 @@ object.Constructor('Page', BasePage, { // NOTE: this uses .PAGE_TEMPLATE to render the page. // NOTE: writing to .raw is the same as writing to .text... // + // XXX should render templates (_view and the like) be a special case + // or render as any other page??? + // ...currently they are rendered in the context of the page and + // not in their own context... // XXX revise how we handle strict mode... get text(){ return (async function(){ // strict mode -- break on non-existing pages... @@ -1482,6 +1486,7 @@ object.Constructor('Page', BasePage, { || path.push(this.PAGE_TEMPLATE) var tpl = pwpath.join(path) var tpl_name = path.pop() + //var tpl_name = path.at(-1) // get the template relative to the top most pattern... tpl = await this.get(tpl).find(true) @@ -1493,11 +1498,17 @@ object.Constructor('Page', BasePage, { // do the parse... // NOTE: we render the template in context of page... return this + // NOTE: this.path can both contain a template and not, this + // normalizes it to the path up to the template path... + .get(path, {args: this.args}) .parse( this.get( '/'+tpl, {args: this.args}).raw, - {depends}) }).call(this) }, + { + depends, + renderer: this, + }) }).call(this) }, set text(value){ this.__update__({text: value}) }, //this.onTextUpdate(value) }, @@ -2010,6 +2021,12 @@ module.System = { //console.log(' :', this, this.renderer) return this.location }, {energetic: true}), + _testPage: { + text: object.doc` + @source(./path) + `}, + _testAction: function(){ + return this.path }, // actions... @@ -2024,12 +2041,10 @@ module.System = { // redirect... this.renderer && (this.renderer.location = this.referrer) + // XXX this should not be needed... && this.renderer.refresh() - // show info about the delete operation... - //return target.get('DeletingPage/_text').text - return '' - }, - + // XXX returning undefined will stop the redirect... + return '' }, // XXX copy/move/... // XXX do we need this as a page action??? move: function(){ @@ -2047,6 +2062,8 @@ module.System = { // redirect... this.renderer && (this.renderer.location = this.referrer) + // XXX this should not be needed... + && this.renderer.refresh() // XXX if we return undefined here this will not fully redirect, // keeping the move page open but setting the url to the // redirected page... diff --git a/pwiki2.js b/pwiki2.js index a00a417..102cf11 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -4,14 +4,6 @@ * XXX ASAP start writing docs in pwiki * - WYSIWYG markdown editor/viewer (ASAP) * - fs store/export in browser or a simple way to export/import... -* XXX currently actions get the parent path (not including the action), -* is this correct??? -* XXX BUG: -* /System/info -* and: -* /System/info/_view -* are not the same... -* ...bug likely in .text * XXX might also be a good idea to investigate a .tree directory index * as a supplement to .paths() * XXX Q: can we access fs from a pwa??? @@ -207,6 +199,10 @@ * ...not sure how we track these... * XXX revise how we handle .strict mode in page's .raw and .text... * XXX might be a good idea to export HTML from a specific path/pattern... +* XXX should render templates (_view and the like) be a special case +* or render as any other page??? +* ...currently they are rendered in the context of the page and +* not in their own context... * XXX EXPERIMENTAL DOC INHERIT_ARGS added a special-case... * as basename will get appended :$ARGS if no args are given... * ...this only applies to paths referring to the current context