added dot-files, hidden by default and the :all arg to show them...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-09-10 02:26:10 +03:00
parent e837b87663
commit b406ed04e8
3 changed files with 31 additions and 10 deletions

View File

@ -424,7 +424,6 @@ object.Constructor('BasePage', {
[await this.find(path)] [await this.find(path)]
: paths : paths
//*/ //*/
for(var path of paths){ for(var path of paths){
yield this.get('/'+ path) } }, yield this.get('/'+ path) } },
[Symbol.asyncIterator]: async function*(){ [Symbol.asyncIterator]: async function*(){
@ -837,7 +836,8 @@ object.Constructor('Page', BasePage, {
// not 100% correct manner focusing on path depth and ignoring // not 100% correct manner focusing on path depth and ignoring
// the context, this potentially can lead to false positives. // the context, this potentially can lead to false positives.
include: Macro( include: Macro(
['src', 'recursive', 'join', ['strict', 'nonstrict', 'isolated']], ['src', 'recursive', 'join',
['strict', 'nonstrict', 'isolated', 'all']],
async function*(args, body, state, key='included', handler){ async function*(args, body, state, key='included', handler){
var macro = 'include' var macro = 'include'
if(typeof(args) == 'string'){ if(typeof(args) == 'string'){
@ -924,7 +924,10 @@ object.Constructor('Page', BasePage, {
// include is rendered in the context of its page but with // include is rendered in the context of its page but with
// the same state... // the same state...
source: Macro( source: Macro(
['src'], // XXX should this have the same args as include???
['src', 'recursive', 'join',
['strict', 'nonstrict', 'isolated', 'all']],
//['src'],
async function*(args, body, state){ async function*(args, body, state){
yield* this.macros.include.call(this, yield* this.macros.include.call(this,
'source', 'source',
@ -952,7 +955,8 @@ object.Constructor('Page', BasePage, {
// //
// 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...
quote: Macro( quote: Macro(
['src', 'filter', 'text', 'join', ['expandactions']], ['src', 'filter', 'text', 'join',
['expandactions', 'all']],
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())
@ -1157,11 +1161,13 @@ object.Constructor('Page', BasePage, {
// //
// XXX SORT sorting not implemented yet.... // XXX SORT sorting not implemented yet....
macro: Macro( macro: Macro(
['name', 'src', 'sort', 'text', 'join', 'else', ['strict', 'nonstrict']], ['name', 'src', 'sort', 'text', 'join', 'else',
['strict', 'nonstrict', 'all']],
async function*(args, body, state){ async function*(args, body, state){
var that = this var that = this
var name = args.name //?? args[0] var name = args.name //?? args[0]
var src = args.src var src = args.src
var all = args.all
var base = this.get(this.path.split(/\*/).shift()) var base = this.get(this.path.split(/\*/).shift())
var sort = (args.sort ?? '') var sort = (args.sort ?? '')
.split(/\s+/g) .split(/\s+/g)
@ -1819,7 +1825,7 @@ module.System = {
<a href="#@source(../../path)/list">&#x21D1;</a> <a href="#@source(../../path)/list">&#x21D1;</a>
@source(../path) @source(../path)
</slot> </slot>
<macro src="../*" join="@source(line-separator)"> <macro src="../*:@(all)" join="@source(line-separator)">
<a href="#@source(./path)">@source(./name)</a> <a href="#@source(./path)">@source(./name)</a>
<sup> <sup>
<macro src="./isAction"> <macro src="./isAction">
@ -1836,7 +1842,7 @@ module.System = {
// XXX this is really slow... // XXX this is really slow...
tree: { tree: {
text: object.doc` text: object.doc`
<macro src="../*"> <macro src="../*:@(all)">
<div> <div>
<div class="item"> <div class="item">
<a href="#@source(./path)">@source(./name)</a> <a href="#@source(./path)">@source(./name)</a>
@ -1844,12 +1850,12 @@ module.System = {
<a class="show-on-hover" href="#@source(./path)/delete">&times;</a> <a class="show-on-hover" href="#@source(./path)/delete">&times;</a>
</div> </div>
<div style="padding-left: 30px"> <div style="padding-left: 30px">
@source(./tree) @source("./tree:@(all)")
</div> </div>
</div> </div>
</macro>` }, </macro>` },
all: { all: {
text: `@include(../**/path join="@source(line-separator)")`}, text: `@include("../**/path:@(all)" join="@source(line-separator)")`},
info: { info: {
text: object.doc` text: object.doc`
Path: @source(../path) Path: @source(../path)
@ -2012,6 +2018,10 @@ module.Test = {
'list/static': { 'list/static': {
text: [...'abcdef'] }, text: [...'abcdef'] },
// this is shown by most listers by adding an :all argument to the url...
'.hidden': {
text: 'Hidden page...' },
slots: { slots: {
text: object.doc` text: object.doc`
Sequential: Sequential:

View File

@ -324,6 +324,7 @@ module.BaseStore = {
|| path.includes('**')){ || path.includes('**')){
var order = (this.metadata(path) ?? {}).order || [] var order = (this.metadata(path) ?? {}).order || []
var {path, args} = pwpath.splitArgs(path) var {path, args} = pwpath.splitArgs(path)
var all = args.all
args = pwpath.joinArgs('', args) args = pwpath.joinArgs('', args)
// NOTE: we are matching full paths only here so leading and // NOTE: we are matching full paths only here so leading and
// trainling '/' are optional... // trainling '/' are optional...
@ -351,6 +352,9 @@ module.BaseStore = {
// skip metadata paths... // skip metadata paths...
if(p.includes('*')){ if(p.includes('*')){
return res } return res }
if(pwpath.basename(p)[0] == '.'
&& !all){
return res }
var m = p.match(pattern) var m = p.match(pattern)
m m
&& (!strict && (!strict
@ -389,6 +393,7 @@ module.BaseStore = {
if(path.includes('*') if(path.includes('*')
|| path.includes('**')){ || path.includes('**')){
var p = pwpath.splitArgs(path) var p = pwpath.splitArgs(path)
var all = p.args.all
var args = pwpath.joinArgs('', p.args) var args = pwpath.joinArgs('', p.args)
p = pwpath.split(p.path) p = pwpath.split(p.path)
var tail = [] var tail = []
@ -396,8 +401,12 @@ module.BaseStore = {
tail.unshift(p.pop()) } tail.unshift(p.pop()) }
tail = tail.join('/') tail = tail.join('/')
if(tail.length > 0){ if(tail.length > 0){
return (await this.match(p.join('/'), strict)) return (await this.match(
p.join('/') + (all ? ':all' : ''),
strict))
.map(function(p){ .map(function(p){
all &&
(p = p.replace(/:all/, ''))
return pwpath.join(p, tail) + args }) } } return pwpath.join(p, tail) + args }) } }
// direct... // direct...
return this.match(path, strict) }, return this.match(path, strict) },

View File

@ -1,6 +1,8 @@
/********************************************************************** /**********************************************************************
* *
* *
* XXX BUG: '@include(@(arg))' does not parse correctly while @include("@(arg)") does...
* ...likely due to the regexp not counting the brace balance...
* XXX BUG CHROME: can't .get(..) a generator... * XXX BUG CHROME: can't .get(..) a generator...
* https://bugs.chromium.org/p/chromium/issues/detail?id=1361981 * https://bugs.chromium.org/p/chromium/issues/detail?id=1361981
* when done test: * when done test: