mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-16 08:01:39 +00:00
notes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
94dfb638b4
commit
51700e2f92
@ -1059,7 +1059,7 @@ object.Constructor('Page', BasePage, {
|
|||||||
[text, join] = state.macros[name] } }
|
[text, join] = state.macros[name] } }
|
||||||
|
|
||||||
if(src){
|
if(src){
|
||||||
src = await base.parse(src, state)
|
var base = this.get(await base.parse(src, state))
|
||||||
|
|
||||||
join = _getBlock('join')
|
join = _getBlock('join')
|
||||||
?? join
|
?? join
|
||||||
@ -1070,11 +1070,11 @@ object.Constructor('Page', BasePage, {
|
|||||||
// of the iterated pages, that is handled by the
|
// of the iterated pages, that is handled by the
|
||||||
// respective include/source/.. macros, this however
|
// respective include/source/.. macros, this however
|
||||||
// only depends on page count...
|
// only depends on page count...
|
||||||
depends.add(src)
|
depends.add(base.path)
|
||||||
|
|
||||||
// expand matches...
|
// expand matches...
|
||||||
var first = true
|
var first = true
|
||||||
for await(var page of this.get(src).asPages(strict)){
|
for await(var page of base.asPages(strict)){
|
||||||
if(join && !first){
|
if(join && !first){
|
||||||
yield join }
|
yield join }
|
||||||
first = false
|
first = false
|
||||||
@ -1273,27 +1273,38 @@ object.Constructor('CachedPage', Page, {
|
|||||||
get cache(){
|
get cache(){
|
||||||
this.checkCache(this.path)
|
this.checkCache(this.path)
|
||||||
return ((this.cachestore ?? {})[this.path] ?? {}).value },
|
return ((this.cachestore ?? {})[this.path] ?? {}).value },
|
||||||
|
// XXX check * paths for matches...
|
||||||
set cache(value){
|
set cache(value){
|
||||||
if(this.cachestore === false
|
if(this.cachestore === false
|
||||||
|| this.cache == value){
|
|| this.cache == value){
|
||||||
return }
|
return }
|
||||||
var path = this.path
|
var path = this.path
|
||||||
|
// clear...
|
||||||
if(value == null){
|
if(value == null){
|
||||||
delete (this.cachestore ?? {})[path]
|
delete (this.cachestore ?? {})[path]
|
||||||
|
// set...
|
||||||
} else {
|
} else {
|
||||||
|
var prev = ((this.cachestore = this.cachestore ?? {})[path] ?? {}).value ?? {}
|
||||||
;(this.cachestore = this.cachestore ?? {})[path] = {
|
;(this.cachestore = this.cachestore ?? {})[path] = {
|
||||||
created: Date.now(),
|
created: Date.now(),
|
||||||
// XXX
|
// XXX
|
||||||
valid: undefined,
|
valid: undefined,
|
||||||
value,
|
value: {
|
||||||
|
...prev,
|
||||||
|
...value,
|
||||||
|
},
|
||||||
} }
|
} }
|
||||||
// clear depended pages from cache...
|
// clear depended pages from cache...
|
||||||
for(var [key, deps] of Object.entries(this.dependencies)){
|
for(var [key, deps] of Object.entries(this.dependencies)){
|
||||||
|
// XXX also check pattern paths...
|
||||||
|
// ...the problem here is that it's getting probabilistic,
|
||||||
|
// i.e. if we match * as a single path item then we might
|
||||||
|
// miss creating a subtree (ex: /tree), while matching
|
||||||
|
// /* to anything will give us lots of false positives...
|
||||||
if(key != path && deps.has(path)){
|
if(key != path && deps.has(path)){
|
||||||
//console.log('CACHE: DROP:', key)
|
//console.log('CACHE: DROP:', key)
|
||||||
delete this.cachestore[key] } } },
|
delete this.cachestore[key] } } },
|
||||||
|
|
||||||
// XXX should this return something useful???
|
|
||||||
checkCache: function(...paths){
|
checkCache: function(...paths){
|
||||||
if(!this.cache_timeout || !this.cachestore){
|
if(!this.cache_timeout || !this.cachestore){
|
||||||
return this }
|
return this }
|
||||||
@ -1311,6 +1322,14 @@ object.Constructor('CachedPage', Page, {
|
|||||||
//console.log('CACHE: DROP:', this.path)
|
//console.log('CACHE: DROP:', this.path)
|
||||||
delete this.cachestore[path] } } }
|
delete this.cachestore[path] } } }
|
||||||
return this },
|
return this },
|
||||||
|
clearCache: function(...paths){
|
||||||
|
if(this.cachestore){
|
||||||
|
if(arguments.length == 0){
|
||||||
|
this.cachestore = null
|
||||||
|
} else {
|
||||||
|
for(var path of paths){
|
||||||
|
delete this.cachestore[path] } } }
|
||||||
|
return this },
|
||||||
|
|
||||||
|
|
||||||
__update__: function(){
|
__update__: function(){
|
||||||
@ -1331,11 +1350,12 @@ object.Constructor('CachedPage', Page, {
|
|||||||
this.path)
|
this.path)
|
||||||
//*/
|
//*/
|
||||||
|
|
||||||
var text = this.cache
|
var text = this.cache ?
|
||||||
?? object.parentProperty(CachedPage.prototype, 'text').get.call(this)
|
this.cache.text
|
||||||
|
: object.parentProperty(CachedPage.prototype, 'text').get.call(this)
|
||||||
text instanceof Promise
|
text instanceof Promise
|
||||||
&& text.then(function(text){
|
&& text.then(function(text){
|
||||||
that.cache = text })
|
that.cache = {text} })
|
||||||
return text },
|
return text },
|
||||||
set text(value){
|
set text(value){
|
||||||
object.parentProperty(CachedPage.prototype, 'text').set.call(this, value) },
|
object.parentProperty(CachedPage.prototype, 'text').set.call(this, value) },
|
||||||
@ -1710,55 +1730,10 @@ module.System = {
|
|||||||
this.render_root
|
this.render_root
|
||||||
&& (this.render_root.location = this.referrer)
|
&& (this.render_root.location = this.referrer)
|
||||||
// show info about the delete operation...
|
// show info about the delete operation...
|
||||||
return target.get('DeletingPage').text },
|
return target.get('DeletingPage/_text').text },
|
||||||
|
|
||||||
/*/ XXX EXPERIMENTAL -- page management...
|
|
||||||
// move page one level up...
|
|
||||||
moveUp: function(){
|
|
||||||
var target = this.get('..')
|
|
||||||
var to = '../../'+target.name
|
|
||||||
|
|
||||||
target.move(to)
|
|
||||||
|
|
||||||
// redirect...
|
|
||||||
this.render_root
|
|
||||||
&& (this.render_root.location = to)
|
|
||||||
// show info about the move operation...
|
|
||||||
return this.render_root.path },
|
|
||||||
// moves page to current location...
|
|
||||||
// Example
|
|
||||||
// /path/to/page/moveDown
|
|
||||||
// /path/page -> /path/to/page
|
|
||||||
moveDown: function(){
|
|
||||||
var to = this.get('..')
|
|
||||||
var target = to.get('../../'+ to.name)
|
|
||||||
|
|
||||||
target.move(to.path)
|
|
||||||
|
|
||||||
// redirect...
|
|
||||||
this.render_root
|
|
||||||
&& (this.render_root.location = to.path)
|
|
||||||
return this.render_root.path },
|
|
||||||
//
|
|
||||||
// syntax:
|
|
||||||
// /<path-from>/to:<path-to>/move
|
|
||||||
//
|
|
||||||
// XXX the syntax works, but there are problems with .move(..) method...
|
|
||||||
move: async function(){
|
|
||||||
var [from, to] = this.get('..').path.split(/\/to:/)
|
|
||||||
// can't move...
|
|
||||||
if(!from || !to){
|
|
||||||
console.warn(`move: can't move: "${from}" -> "${to}"`)
|
|
||||||
return '' }
|
|
||||||
|
|
||||||
await this.get(from).move(to)
|
|
||||||
|
|
||||||
// redirect...
|
|
||||||
this.render_root
|
|
||||||
&& (this.render_root.location = to)
|
|
||||||
return '' },
|
|
||||||
//*/
|
|
||||||
|
|
||||||
|
// XXX copy/move/...
|
||||||
|
// ...need arguments
|
||||||
|
|
||||||
// XXX System/back
|
// XXX System/back
|
||||||
// XXX System/forward
|
// XXX System/forward
|
||||||
|
|||||||
@ -235,7 +235,6 @@ module = {
|
|||||||
// <name>:<value>,
|
// <name>:<value>,
|
||||||
// ...
|
// ...
|
||||||
// }
|
// }
|
||||||
// action: <action>
|
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Syntax:
|
// Syntax:
|
||||||
@ -246,37 +245,22 @@ module = {
|
|||||||
// <arg> | <arg>:<args>
|
// <arg> | <arg>:<args>
|
||||||
// <arg> ::=
|
// <arg> ::=
|
||||||
// <value>
|
// <value>
|
||||||
// | <name>:<value>
|
// | <name>=<value>
|
||||||
//
|
//
|
||||||
// XXX the problem here is that we could legitimately create path
|
// XXX the problem here is that we could legitimately create path
|
||||||
// items containing ":" -- it either needs to be a reserved char
|
// items containing ":" -- it either needs to be a reserved char
|
||||||
// or this scheme will not work...
|
// or this scheme will not work...
|
||||||
splitArgs: function(path){
|
splitArgs: function(path){
|
||||||
path = this.normalize(path, 'array')
|
path = this.normalize(path, 'string')
|
||||||
|
var [path, ...args] = path.split(/:/g)
|
||||||
|
|
||||||
var res = {
|
return {
|
||||||
path: '',
|
path,
|
||||||
args: {},
|
args: args.reduce(function(res, arg){
|
||||||
actions: path.pop(),
|
var [name, value] = arg.split('=')
|
||||||
}
|
res[name] = value ?? true
|
||||||
var state = 'path'
|
return res }, {}),
|
||||||
var cur, value
|
} },
|
||||||
for(var elem of path){
|
|
||||||
if(elem.includes(':')){
|
|
||||||
state = 'arg' }
|
|
||||||
|
|
||||||
if(state == 'path'){
|
|
||||||
res.path += '/'+ elem
|
|
||||||
|
|
||||||
} else if(state == 'arg'){
|
|
||||||
;[cur, value] = elem.split(':')
|
|
||||||
res[cur] = value
|
|
||||||
state = value
|
|
||||||
|
|
||||||
} else if(state == 'value'){
|
|
||||||
res[cur] += '/'+ value } }
|
|
||||||
|
|
||||||
return res },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,9 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* XXX CACHE track store changes...
|
* XXX CACHE track store changes...
|
||||||
|
* XXX CACHE/DEPENDS might be a good idea to add a dependencyUpdated event...
|
||||||
|
* ...and use it for cache invalidation...
|
||||||
|
* XXX CACHE creating a new page does not invalidate /tree cache...
|
||||||
* XXX need a uniform way to track some state in links in pwiki for things
|
* XXX need a uniform way to track some state in links in pwiki for things
|
||||||
* like paging and the like with simple user/macro access (???)...
|
* like paging and the like with simple user/macro access (???)...
|
||||||
* ...the simplest that comes to mind is to store in in path
|
* ...the simplest that comes to mind is to store in in path
|
||||||
@ -61,6 +64,7 @@
|
|||||||
* XXX BUG: .move(..) behaves in an odd way...
|
* XXX BUG: .move(..) behaves in an odd way...
|
||||||
* see: System/move page action
|
* see: System/move page action
|
||||||
* ...deletes the original and moves an empty page -- sync error???
|
* ...deletes the original and moves an empty page -- sync error???
|
||||||
|
* XXX DELETE ./delete is triggered twice...
|
||||||
* XXX differences in behaviour between _abc and abc, either need to make
|
* XXX differences in behaviour between _abc and abc, either need to make
|
||||||
* them the same or document the differences and the reasons behind
|
* them the same or document the differences and the reasons behind
|
||||||
* them...
|
* them...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user