minor tweak...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-04-08 19:57:31 +03:00
parent 716c7058af
commit 0f2df5714e
3 changed files with 72 additions and 17 deletions

View File

@ -47,14 +47,18 @@ are likely to change, the implementation / API **will definitely** change! ;)_
### General Documentation: ### General Documentation:
<pwiki-comment> <pwiki-comment>
- [General info](README.md) - This document. - [General info](README.md) - This document.
- [Bootstrap path](bootstrap/Doc/Path.md) - Path mechanics. - [Bootstrap path](bootstrap/Doc/Path.md) - Path mechanics.
- [Bootstrap macros](bootstrap/Doc/Macros.md) - Macro documentation - [Bootstrap macros](bootstrap/Doc/Macros.md) - Macro documentation
</pwiki-comment> </pwiki-comment>
<!--[pWiki[ <!--[pWiki[
- [Doc/About] - This document. - [Doc/About] - This document.
- [Doc/Path] - Path mechanics. - [Doc/Path] - Path mechanics.
- [Doc/Macros] - Macro documentation - [Doc/Macros] - Macro documentation
]]--> ]]-->

View File

@ -252,13 +252,17 @@ module = {
return e } return e }
// see if we need to overload attrs... // see if we need to overload attrs...
sort = sort == null ? (elem.attr('sort') || '') : sort sort = sort == null ?
(elem.attr('sort') || '')
: sort
sort = sort sort = sort
.split(/\s+/g) .split(/\s+/g)
.filter(function(e){ return e && e != '' }) .filter(function(e){ return e && e != '' })
// do the sorting... // do the sorting...
pages = sort.length > 0 ? pages.sort(sort) : pages pages = sort.length > 0 ?
pages.sort(sort)
: pages
// fill with pages... // fill with pages...
elem = elem.clone() elem = elem.clone()

View File

@ -71,13 +71,31 @@ module.normalizePath = function(path){
return path2list(path).join('/') } return path2list(path).join('/') }
// XXX add pattern to match all subpaths above...
// Ex:
// 'a/b/c/^' shold mathc 'a/b/c', 'a/b', 'a'
var path2re = var path2re =
module.path2re = function(path){ module.path2re = function(path){
return RegExp('^' return RegExp('^'
+normalizePath(path) +normalizePath(path)
// quote regexp chars... /*/ quote regexp chars...
.replace(/([\.\\\/\(\)\[\]\$\+\-\{\}\@\^\&\?\<\>])/g, '\\$1') .replace(/([\.\\\/\(\)\[\]\$\+\-\{\}\@\^\&\?\<\>])/g, '\\$1')
/*/// XXX experimental...
.replace(/([\.\\\/\(\)\[\]\$\+\-\{\}\@\^\&\?\>])/g, '\\$1')
// '<' -> handle subpath matching...
// XXX this needs * up the stack...
.replace(/.*</, function(match){
return `(${ match
.replace(/(\\[\\\/])?<$/, '')
.split(/\\[\\\/]/)
.reduce(function(res, e){
return res.concat([
(res.length > 0 ?
res[res.length-1] +'\/'
: '')
+ e]) }, [])
.join('|') })` })
//*/
// convert '*' and '**' to regexp... // convert '*' and '**' to regexp...
.replace(/\*\*/g, '.*') .replace(/\*\*/g, '.*')
.replace(/^\*|([^.])\*/g, '$1[^\\/]*') .replace(/^\*|([^.])\*/g, '$1[^\\/]*')
@ -185,17 +203,43 @@ module.BaseData = {
// Page modifiers/actions... // Page modifiers/actions...
// XXX these needs redirecting... // XXX these needs redirecting...
// ...not sure if using history here is the right way to go...
'System/_sort': function(){
this.get('..').sort() },
'System/sort': function(){ 'System/sort': function(){
return this.get('..').sort() }, // XXX does not work for some reason...
//this.get('../_sort')
this.get('..').sort()
history
&& history.back() },
'System/_reverse': function(){
this.get('..').reverse() },
'System/reverse': function(){ 'System/reverse': function(){
return this.get('..').reverse() }, // XXX does not work for some reason...
//this.get('../_reverse')
this.get('..').reverse()
history
&& history.back() },
'System/_delete': function(){
this.get('..').clear() },
'System/delete': function(){ 'System/delete': function(){
// XXX does not work for some reason...
//this.get('../_delete')
this.get('..').clear() this.get('..').clear()
// XXX need a propper redirect... history
return this.get('..') && history.back() },
},
//*/ 'System/back': function(){
history.go(-2) },
// XXX not sure how to deal with this...
//'System/foreward': function(){
// history.go(1) },
// XXX need to support simple functions...
// ...return a list to simulate a list of pages...
'System/test': function(){
return ['list', 'of', 'links'] },
} }
@ -255,13 +299,11 @@ module.pWikiData = {
return !data.hasOwnProperty(e) })) return !data.hasOwnProperty(e) }))
.filter(function(p){ .filter(function(p){
return pattern.test(p) }) return pattern.test(p) })
// page... // page...
.slice(from, .slice(from,
count ? count ?
from + count from + count
: undefined) : undefined)
// prepare to sort... // prepare to sort...
.map(function(p, i){ .map(function(p, i){
return sort return sort
@ -274,13 +316,19 @@ module.pWikiData = {
return i } return i }
// drop the reversal marker... // drop the reversal marker...
method = method[0] == '-' ? method.slice(1) : method method = method[0] == '-' ?
method.slice(1)
: method
// stored order... // stored order...
if(method == 'order'){ if(method == 'order'){
i = order.indexOf(p) i = order.indexOf(p)
i = i < 0 ? order.indexOf('*') : i i = i < 0 ?
i = i < 0 ? order.length : i order.indexOf('*')
: i
i = i < 0 ?
order.length
: i
return i } return i }
return method == 'path' ? return method == 'path' ?
@ -297,8 +345,7 @@ module.pWikiData = {
1 1
: 0) : 0)
// attr... // attr...
: data[p][method] : data[p][method] })
})
.concat([i, p]) }) .concat([i, p]) })
// sort... // sort...
.sort(function(a, b){ .sort(function(a, b){