From 027033b548a6e4e144e617dea6b0c8a44a52d5c6 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 17 Feb 2023 05:12:30 +0300 Subject: [PATCH] added templates to page editor + tweaking @quote(..) Signed-off-by: Alex A. Naanou --- pwiki/page.js | 34 ++++++++++++++++++++++++---------- pwiki2.html | 4 ++++ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/pwiki/page.js b/pwiki/page.js index 41ce4ca..267a99b 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -1235,15 +1235,17 @@ object.Constructor('Page', BasePage, { // NOTE: the filter argument uses the same filters as @filter(..) // // XXX need a way to escape macros -- i.e. include in a quoted text... + // XXX should join/else be sub-tags??? quote: Macro( - ['src', 'filter', 'text', 'join', - ['s', 'expandactions']], + ['src', 'filter', 'text', 'join', 'else', + ['s', 'expandactions', 'strict']], async function*(args, body, state){ var src = args.src //|| args[0] var base = this.get(this.path.split(/\*/).shift()) var text = args.text ?? body ?? [] + var strict = args.strict ?? false // parse arg values... src = src ? await base.parse(src, state) @@ -1269,14 +1271,20 @@ object.Constructor('Page', BasePage, { (!expandactions && await this.get(src).type == 'action' ? base.get(this.QUOTE_ACTION_PAGE) - : this.get(src).asPages()) + : await this.get(src).asPages(strict)) : text instanceof Array ? [text.join('')] : typeof(text) == 'string' ? [text] : text + // else... + pages = ((!pages + || pages.length == 0) + && args['else']) ? + base.parse(args['else'], state) + : pages // empty... - if(!pages){ + if(!pages || pages.length == 0){ return } var join = args.join @@ -1656,6 +1664,7 @@ object.Constructor('Page', BasePage, { ('strict' in args ? args.strict : iargs.strict) + //?? true ?? false var isolated = ('isolated' in args ? @@ -2481,7 +2490,7 @@ module.System = { wikiwords="no" contenteditable oninput="saveLiveContent(\'@source(s ./path)\', this.innerText)" - > + > @macro(titleeditor .) @@ -2495,7 +2504,7 @@ module.System = { @source(../location/quote/!) - + `}, // XXX EXPERIMENTAL... ed: { @@ -2839,20 +2848,25 @@ module.Templates = { // XXX for some reason this does not list files... FlatNotes: { text: object.doc` + @var(template FlatNotes/EmptyPage) + - 🗎 - + 🗎 + @var(path "@source(s ./path)") + + Empty + ` }, // XXX this is not resolved... - 'FlatNotes/.templates/EmptyPage': {text: ' '}, + 'FlatNotes/EmptyPage': {text: ' '}, } var Test = diff --git a/pwiki2.html b/pwiki2.html index f04dd1b..2ae6ef0 100755 --- a/pwiki2.html +++ b/pwiki2.html @@ -163,6 +163,10 @@ body.loading .page.spinner span { } } +.placeholder { + opacity: 0.4; +} + /* TOC */ toc {