more fixes and normalization....

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-09-18 20:12:18 +03:00
parent b5ea4bfcb1
commit a6670280cd
2 changed files with 27 additions and 14 deletions

View File

@ -1470,6 +1470,10 @@ object.Constructor('Page', BasePage, {
// NOTE: this uses .PAGE_TEMPLATE to render the page. // NOTE: this uses .PAGE_TEMPLATE to render the page.
// NOTE: writing to .raw is the same as writing to .text... // 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... // XXX revise how we handle strict mode...
get text(){ return (async function(){ get text(){ return (async function(){
// strict mode -- break on non-existing pages... // strict mode -- break on non-existing pages...
@ -1482,6 +1486,7 @@ object.Constructor('Page', BasePage, {
|| path.push(this.PAGE_TEMPLATE) || path.push(this.PAGE_TEMPLATE)
var tpl = pwpath.join(path) var tpl = pwpath.join(path)
var tpl_name = path.pop() var tpl_name = path.pop()
//var tpl_name = path.at(-1)
// get the template relative to the top most pattern... // get the template relative to the top most pattern...
tpl = await this.get(tpl).find(true) tpl = await this.get(tpl).find(true)
@ -1493,11 +1498,17 @@ object.Constructor('Page', BasePage, {
// do the parse... // do the parse...
// NOTE: we render the template in context of page... // NOTE: we render the template in context of page...
return this 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( .parse(
this.get( this.get(
'/'+tpl, '/'+tpl,
{args: this.args}).raw, {args: this.args}).raw,
{depends}) }).call(this) }, {
depends,
renderer: this,
}) }).call(this) },
set text(value){ set text(value){
this.__update__({text: value}) }, this.__update__({text: value}) },
//this.onTextUpdate(value) }, //this.onTextUpdate(value) },
@ -2010,6 +2021,12 @@ module.System = {
//console.log(' :', this, this.renderer) //console.log(' :', this, this.renderer)
return this.location }, return this.location },
{energetic: true}), {energetic: true}),
_testPage: {
text: object.doc`
@source(./path)
`},
_testAction: function(){
return this.path },
// actions... // actions...
@ -2024,12 +2041,10 @@ module.System = {
// redirect... // redirect...
this.renderer this.renderer
&& (this.renderer.location = this.referrer) && (this.renderer.location = this.referrer)
// XXX this should not be needed...
&& this.renderer.refresh() && this.renderer.refresh()
// show info about the delete operation... // XXX returning undefined will stop the redirect...
//return target.get('DeletingPage/_text').text return '' },
return ''
},
// XXX copy/move/... // XXX copy/move/...
// XXX do we need this as a page action??? // XXX do we need this as a page action???
move: function(){ move: function(){
@ -2047,6 +2062,8 @@ module.System = {
// redirect... // redirect...
this.renderer this.renderer
&& (this.renderer.location = this.referrer) && (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, // XXX if we return undefined here this will not fully redirect,
// keeping the move page open but setting the url to the // keeping the move page open but setting the url to the
// redirected page... // redirected page...

View File

@ -4,14 +4,6 @@
* XXX ASAP start writing docs in pwiki * XXX ASAP start writing docs in pwiki
* - WYSIWYG markdown editor/viewer (ASAP) * - WYSIWYG markdown editor/viewer (ASAP)
* - fs store/export in browser or a simple way to export/import... * - 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 * XXX might also be a good idea to investigate a .tree directory index
* as a supplement to .paths() * as a supplement to .paths()
* XXX Q: can we access fs from a pwa??? * XXX Q: can we access fs from a pwa???
@ -207,6 +199,10 @@
* ...not sure how we track these... * ...not sure how we track these...
* XXX revise how we handle .strict mode in page's .raw and .text... * 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 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... * XXX EXPERIMENTAL DOC INHERIT_ARGS added a special-case...
* as basename will get appended :$ARGS if no args are given... * as basename will get appended :$ARGS if no args are given...
* ...this only applies to paths referring to the current context * ...this only applies to paths referring to the current context