more tweaking to sort...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-11-27 02:34:40 +03:00
parent f1b71c69d8
commit 5bf57405df
3 changed files with 16 additions and 5 deletions

View File

@ -2474,7 +2474,7 @@ module.System = {
<div> <div>
<b>Nested pages:</b><br> <b>Nested pages:</b><br>
<div style="padding-left: 30px"> <div style="padding-left: 30px">
<macro src="./*" join="<br>" else="@slot(nested)"> <macro src="./*:$ARGS" join="<br>" else="@slot(nested)">
<a href="#@source(s ./path)">@source(./title)</a> <a href="#@source(s ./path)">@source(./title)</a>
</macro> </macro>
</div> </div>

View File

@ -897,6 +897,12 @@ module.BaseStore = {
// actual existing pages, while in non-strict mode the pattern will // actual existing pages, while in non-strict mode the pattern will
// match all sub-paths. // match all sub-paths.
// //
// Handled path arguments:
// all
// sort=<methods>
// sortnewlast (default)
// sortnewfirst
//
__match_args__: { __match_args__: {
// //
// <tag-name>: function(value, args){ // <tag-name>: function(value, args){
@ -974,6 +980,11 @@ module.BaseStore = {
var all = args.all var all = args.all
var sort = args.sort var sort = args.sort
var newlast =
args.sortnewlast
?? !(args.sortnewfirst
// default is sortnewlast...
?? false)
var test = await this.__match_args(args) var test = await this.__match_args(args)
args = pwpath.joinArgs('', args) args = pwpath.joinArgs('', args)
@ -1034,7 +1045,10 @@ module.BaseStore = {
that that
.sort(this, ...sort.split(/\s*[,\s]+/g)) .sort(this, ...sort.split(/\s*[,\s]+/g))
:this :this
.sortAs(order) }) .sortAs(order,
newlast ?
'head'
: 'tail') })
.map(function(p){ .map(function(p){
return p+args })} return p+args })}
// direct search... // direct search...

View File

@ -37,9 +37,6 @@
* - * -
* *
* *
* XXX sort: for saved order, how do we handle items not in the metadata?
* ...there are three ways to handle this, put them first, last or
* add an option with a reasonable default...
* XXX sort: revise how we store order... * XXX sort: revise how we store order...
* .metadata.order = [ .. ] * .metadata.order = [ .. ]
* .metadata.order_<name> = [ .. ] * .metadata.order_<name> = [ .. ]