bugfix + some tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-10-27 02:36:14 +03:00
parent 59eff6cf05
commit 54ca3252bf
3 changed files with 30 additions and 12 deletions

View File

@ -126,14 +126,16 @@ object.Constructor('BasePage', {
},
resolvePathVars: function(path='', context={}){
var that = this
return pwpath.normalize(
Object.entries(this.path_vars)
.reduce(function(res, [key, func]){
return res
.replace(
new RegExp('(\\${'+key+'}|\\$'+key+')', 'g'),
func.call(that, context))
}, path)) },
return path == '.' ?
path
: pwpath.normalize(
Object.entries(this.path_vars)
.reduce(function(res, [key, func]){
return res
.replace(
new RegExp('(\\${'+key+'}|\\$'+key+')', 'g'),
func.call(that, context))
}, path)) },
// page location...
//
@ -990,7 +992,8 @@ object.Constructor('Page', BasePage, {
depends,
renderer: state.renderer,
})}
: this.get(src)
//: this.get(src)
: this
.parse(state) }
var first = true
@ -2064,7 +2067,12 @@ module.System = {
type: @source(../type)<br>
tags: @source(../tags join=", ")<br>
tags:
<macro name="list-tags" src="../tags">
<a href="#/**/path:tags=@source(.)">@source(.)</a>
</macro><br>
related tags:
<macro name="list-tags" src="../relatedTags"/><br>
ctime: @source(../ctime)<br>
mtime: @source(../mtime)<br>

View File

@ -283,13 +283,14 @@ module.BaseStore = {
return this.__tags() },
relatedTags: function*(...tags){
var cur = tags
var cur = new Set(tags)
var {tags, paths} = this.tags
var seen = new Set()
for(var tag of cur){
for(var p of tags[tag] ?? []){
for(var t of paths[p] ?? []){
if(!seen.has(t)){
if(!seen.has(t)
&& !cur.has(t)){
seen.add(t)
yield t } } } } },

View File

@ -18,6 +18,15 @@
* - CLI -
*
*
* XXX BUG: parser:
* This will break:
* <macro src=../tags join=", ">@source(.)</macro><br>
* This will not:
* <macro src="../tags" join=", ">@source(.)</macro><br>
* XXX LIST BUG: <macro>: sourcing an element of a list does not work...
* Example:
* await pwiki.parse('<macro src="/WikiHome/tags">@source(.)</macro>')
* XXX do we need a way to index a list item via path???
* XXX TAGS
* - add tags to page -- macro/filter
* - <page>.text -> <page>.tags (cached on .update(..))