mirror of
https://github.com/flynx/pWiki.git
synced 2026-01-06 01:51:08 +00:00
fixed broken cache...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
323eb39c1b
commit
4059b988a9
@ -122,14 +122,20 @@ object.Constructor('BasePage', {
|
|||||||
// XXX should this be able to prevent navigation???
|
// XXX should this be able to prevent navigation???
|
||||||
onBeforeNavigate: types.event.Event('beforeNavigate'),
|
onBeforeNavigate: types.event.Event('beforeNavigate'),
|
||||||
onNavigate: types.event.Event('navigate',
|
onNavigate: types.event.Event('navigate',
|
||||||
function(handle, path){
|
function(handle, location){
|
||||||
this.onBeforeNavigate(path)
|
this.onBeforeNavigate(location)
|
||||||
this.referrer = this.location
|
this.referrer = this.location
|
||||||
|
var {path, args} = pwpath.splitArgs(location)
|
||||||
var cur = this.__location =
|
var cur = this.__location =
|
||||||
this.resolvePathVars(
|
this.resolvePathVars(
|
||||||
pwpath.relative(
|
// NOTE: this is done instead of simply assigning
|
||||||
this.location,
|
// location as-is to normalize the paths and
|
||||||
path))
|
// arguments...
|
||||||
|
pwpath.joinArgs(
|
||||||
|
pwpath.relative(
|
||||||
|
this.path,
|
||||||
|
path),
|
||||||
|
pwpath.obj2args(args)))
|
||||||
// trigger handlers...
|
// trigger handlers...
|
||||||
handle() }),
|
handle() }),
|
||||||
|
|
||||||
@ -1331,6 +1337,13 @@ function(obj, name, value){
|
|||||||
var CachedPage =
|
var CachedPage =
|
||||||
module.CachedPage =
|
module.CachedPage =
|
||||||
object.Constructor('CachedPage', Page, {
|
object.Constructor('CachedPage', Page, {
|
||||||
|
// Sets what to use for cache id...
|
||||||
|
//
|
||||||
|
// Can be:
|
||||||
|
// 'location' (default)
|
||||||
|
// 'path'
|
||||||
|
cache_id: 'location',
|
||||||
|
|
||||||
// NOTE: set this to null/undefined/0 to disable...
|
// NOTE: set this to null/undefined/0 to disable...
|
||||||
cache_timeout: '20m',
|
cache_timeout: '20m',
|
||||||
|
|
||||||
@ -1343,21 +1356,21 @@ object.Constructor('CachedPage', Page, {
|
|||||||
;(this.root ?? this).__cachestore = value },
|
;(this.root ?? this).__cachestore = value },
|
||||||
|
|
||||||
get cache(){
|
get cache(){
|
||||||
this.checkCache(this.path)
|
this.checkCache(this[this.cache_id])
|
||||||
return ((this.cachestore ?? {})[this.path] ?? {}).value },
|
return ((this.cachestore ?? {})[this[this.cache_id]] ?? {}).value },
|
||||||
// XXX check * paths for matches...
|
// 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 id = this[this.cache_id ?? 'location']
|
||||||
// clear...
|
// clear...
|
||||||
if(value == null){
|
if(value == null){
|
||||||
delete (this.cachestore ?? {})[path]
|
delete (this.cachestore ?? {})[id]
|
||||||
// set...
|
// set...
|
||||||
} else {
|
} else {
|
||||||
var prev = ((this.cachestore = this.cachestore ?? {})[path] ?? {}).value ?? {}
|
var prev = ((this.cachestore = this.cachestore ?? {})[id] ?? {}).value ?? {}
|
||||||
;(this.cachestore = this.cachestore ?? {})[path] = {
|
;(this.cachestore = this.cachestore ?? {})[id] = {
|
||||||
created: Date.now(),
|
created: Date.now(),
|
||||||
// XXX
|
// XXX
|
||||||
valid: undefined,
|
valid: undefined,
|
||||||
@ -1373,7 +1386,7 @@ object.Constructor('CachedPage', Page, {
|
|||||||
// i.e. if we match * as a single path item then we might
|
// i.e. if we match * as a single path item then we might
|
||||||
// miss creating a subtree (ex: /tree), while matching
|
// miss creating a subtree (ex: /tree), while matching
|
||||||
// /* to anything will give us lots of false positives...
|
// /* to anything will give us lots of false positives...
|
||||||
if(key != path && deps.has(path)){
|
if(key != id && deps.has(id)){
|
||||||
delete this.cachestore[key] } } },
|
delete this.cachestore[key] } } },
|
||||||
|
|
||||||
checkCache: function(...paths){
|
checkCache: function(...paths){
|
||||||
@ -1665,12 +1678,12 @@ module.System = {
|
|||||||
tree: {
|
tree: {
|
||||||
text: object.doc`
|
text: object.doc`
|
||||||
<macro src="../*">
|
<macro src="../*">
|
||||||
<div class="item">
|
<div>
|
||||||
<a href="#@source(./path)">@source(./name)</a>
|
<div class="item">
|
||||||
<span class="show-on-hover">
|
<a href="#@source(./path)">@source(./name)</a>
|
||||||
<a href="#@source(./path)/info">🛈</a>
|
<a class="show-on-hover" href="#@source(./path)/info">🛈</a>
|
||||||
<a href="#@source(./path)/delete">×</a>
|
<a class="show-on-hover" href="#@source(./path)/delete">×</a>
|
||||||
</span>
|
</div>
|
||||||
<div style="padding-left: 30px">
|
<div style="padding-left: 30px">
|
||||||
@source(./tree)
|
@source(./tree)
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -269,7 +269,6 @@ module = {
|
|||||||
: [name, ...this.ALTERNATIVE_PAGES] },
|
: [name, ...this.ALTERNATIVE_PAGES] },
|
||||||
|
|
||||||
|
|
||||||
// XXX EXPERIMENTAL...
|
|
||||||
//
|
//
|
||||||
// .splitArgs(<path>)
|
// .splitArgs(<path>)
|
||||||
// -> <spec>
|
// -> <spec>
|
||||||
@ -284,8 +283,6 @@ module = {
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Syntax:
|
// Syntax:
|
||||||
// <path>/<name>:<value>/<name>:<value>/../action
|
|
||||||
// XXX or?
|
|
||||||
// <path> ::= <path>:<args>
|
// <path> ::= <path>:<args>
|
||||||
// <args> ::=
|
// <args> ::=
|
||||||
// <arg> | <arg>:<args>
|
// <arg> | <arg>:<args>
|
||||||
@ -304,7 +301,7 @@ module = {
|
|||||||
path,
|
path,
|
||||||
args: args.reduce(function(res, arg){
|
args: args.reduce(function(res, arg){
|
||||||
var [name, value] = arg.split(/=(.*)/)
|
var [name, value] = arg.split(/=(.*)/)
|
||||||
res[name] = value ?? true
|
res[name.trim()] = value ?? true
|
||||||
return res }, {}),
|
return res }, {}),
|
||||||
} },
|
} },
|
||||||
obj2args: function(args){
|
obj2args: function(args){
|
||||||
@ -313,12 +310,15 @@ module = {
|
|||||||
.map(function([key, value]){
|
.map(function([key, value]){
|
||||||
return value === true ?
|
return value === true ?
|
||||||
key
|
key
|
||||||
//: value === false ?
|
: key +'='+ ((value + '').replace(/:/g, '\\:')) })
|
||||||
// []
|
|
||||||
: key +':'+ (value.toString().replace(/:/g, '\\:'))
|
|
||||||
})
|
|
||||||
.join(':')
|
.join(':')
|
||||||
: args },
|
: args },
|
||||||
|
joinArgs: function(path, args={}){
|
||||||
|
path = this.join(path)
|
||||||
|
args = this.obj2args(args)
|
||||||
|
return args == '' ?
|
||||||
|
path
|
||||||
|
: path +':'+ args },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,13 @@
|
|||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
* XXX ASAP prevent paths from using reserved chars like: ":", "#", ...
|
||||||
* XXX FEATURE list macro paging...
|
* XXX FEATURE list macro paging...
|
||||||
* ...should this be macro level or handled in .each()
|
* ...should this be macro level or handled in .each()
|
||||||
* what mode?
|
* what mode?
|
||||||
* - count + block-offset (preferred)
|
* - count + block-offset (preferred)
|
||||||
* - count + elem-offset
|
* - count + elem-offset
|
||||||
* - from + to
|
* - from + to
|
||||||
* XXX what should page caching use?
|
|
||||||
* - .path (current)
|
|
||||||
* - .location
|
|
||||||
* - .path + normalized .args
|
|
||||||
* ...should this be configurable???
|
|
||||||
* XXX FEATURE tags and accompanying API...
|
* XXX FEATURE tags and accompanying API...
|
||||||
* - add tags to page -- macro/filter
|
* - add tags to page -- macro/filter
|
||||||
* <page>.text -> <page>.tags (cached on .update(..))
|
* <page>.text -> <page>.tags (cached on .update(..))
|
||||||
@ -157,6 +153,9 @@
|
|||||||
* - get --
|
* - get --
|
||||||
* - download --
|
* - download --
|
||||||
* - upload --
|
* - upload --
|
||||||
|
* - tags
|
||||||
|
* - get tags from page --
|
||||||
|
* - show tagged pages --
|
||||||
* - search
|
* - search
|
||||||
* - paths
|
* - paths
|
||||||
* - text
|
* - text
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user