added templates to page editor + tweaking @quote(..)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-02-17 05:12:30 +03:00
parent b3f40b54f5
commit 027033b548
2 changed files with 28 additions and 10 deletions

View File

@ -1235,15 +1235,17 @@ object.Constructor('Page', BasePage, {
// NOTE: the filter argument uses the same filters as @filter(..) // NOTE: the filter argument uses the same filters as @filter(..)
// //
// XXX need a way to escape macros -- i.e. include </quote> in a quoted text... // XXX need a way to escape macros -- i.e. include </quote> in a quoted text...
// XXX should join/else be sub-tags???
quote: Macro( quote: Macro(
['src', 'filter', 'text', 'join', ['src', 'filter', 'text', 'join', 'else',
['s', 'expandactions']], ['s', 'expandactions', 'strict']],
async function*(args, body, state){ async function*(args, body, state){
var src = args.src //|| args[0] var src = args.src //|| args[0]
var base = this.get(this.path.split(/\*/).shift()) var base = this.get(this.path.split(/\*/).shift())
var text = args.text var text = args.text
?? body ?? body
?? [] ?? []
var strict = args.strict ?? false
// parse arg values... // parse arg values...
src = src ? src = src ?
await base.parse(src, state) await base.parse(src, state)
@ -1269,14 +1271,20 @@ object.Constructor('Page', BasePage, {
(!expandactions (!expandactions
&& await this.get(src).type == 'action' ? && await this.get(src).type == 'action' ?
base.get(this.QUOTE_ACTION_PAGE) base.get(this.QUOTE_ACTION_PAGE)
: this.get(src).asPages()) : await this.get(src).asPages(strict))
: text instanceof Array ? : text instanceof Array ?
[text.join('')] [text.join('')]
: typeof(text) == 'string' ? : typeof(text) == 'string' ?
[text] [text]
: text : text
// else...
pages = ((!pages
|| pages.length == 0)
&& args['else']) ?
base.parse(args['else'], state)
: pages
// empty... // empty...
if(!pages){ if(!pages || pages.length == 0){
return } return }
var join = args.join var join = args.join
@ -1656,6 +1664,7 @@ object.Constructor('Page', BasePage, {
('strict' in args ? ('strict' in args ?
args.strict args.strict
: iargs.strict) : iargs.strict)
//?? true
?? false ?? false
var isolated = var isolated =
('isolated' in args ? ('isolated' in args ?
@ -2481,7 +2490,7 @@ module.System = {
wikiwords="no" wikiwords="no"
contenteditable contenteditable
oninput="saveLiveContent(\'@source(s ./path)\', this.innerText)" oninput="saveLiveContent(\'@source(s ./path)\', this.innerText)"
><quote filter="quote-tags" src="."/></pre> ><quote filter="quote-tags" src="@arg(template .)"/></pre>
</macro> </macro>
<macro editor join="@source(file-separator)"> <macro editor join="@source(file-separator)">
@macro(titleeditor .) @macro(titleeditor .)
@ -2495,7 +2504,7 @@ module.System = {
<slot location>@source(../location/quote/!)</slot> <slot location>@source(../location/quote/!)</slot>
<slot edit/> <slot edit/>
<slot content> <slot content>
<macro editor src=".."/> <macro editor src=".." />
</slot>`}, </slot>`},
// XXX EXPERIMENTAL... // XXX EXPERIMENTAL...
ed: { ed: {
@ -2839,20 +2848,25 @@ module.Templates = {
// XXX for some reason this does not list files... // XXX for some reason this does not list files...
FlatNotes: { FlatNotes: {
text: object.doc` text: object.doc`
@var(template FlatNotes/EmptyPage)
<slot title/> <slot title/>
<slot header><content/><a href="#./$NOW/edit">&#128462;</a></slot> <slot header><content/><a href="#./$NOW/edit:template=@var(template)">&#128462;</a></slot>
<macro src="*:$ARGS"> <macro src="*:sort=-mtime:$ARGS" strict>
@var(path "@source(s ./path)") @var(path "@source(s ./path)")
<div class="item"> <div class="item">
<a href="#@var(path)/edit">@source(./title/quote)</a> <a href="#@var(path)/edit:template=@var(template)">@source(./title/quote)</a>
<a class="show-on-hover" href="#@var(path)/info">&#128712;</a> <a class="show-on-hover" href="#@var(path)/info">&#128712;</a>
<a class="show-on-hover" <a class="show-on-hover"
href="javascript:pwiki.delete('@var(path)')" href="javascript:pwiki.delete('@var(path)')"
>&times;</a> >&times;</a>
</div> </div>
<else>
<a href="#./$NOW/edit:template=@var(template)" class="placeholder">Empty</a>
</else>
</macro>` }, </macro>` },
// XXX this is not resolved... // XXX this is not resolved...
'FlatNotes/.templates/EmptyPage': {text: ' '}, 'FlatNotes/EmptyPage': {text: ' '},
} }
var Test = var Test =

View File

@ -163,6 +163,10 @@ body.loading .page.spinner span {
} }
} }
.placeholder {
opacity: 0.4;
}
/* TOC */ /* TOC */
toc { toc {