mirror of
https://github.com/flynx/pWiki.git
synced 2025-11-03 20:40:10 +00:00
tweaks and fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
a6f7234e36
commit
004c854eb7
@ -62,6 +62,7 @@ object.Constructor('BasePage', {
|
|||||||
'path',
|
'path',
|
||||||
'name',
|
'name',
|
||||||
'dir',
|
'dir',
|
||||||
|
'title',
|
||||||
'resolved',
|
'resolved',
|
||||||
'rootpath',
|
'rootpath',
|
||||||
'renderer',
|
'renderer',
|
||||||
@ -185,6 +186,13 @@ object.Constructor('BasePage', {
|
|||||||
get dir(){
|
get dir(){
|
||||||
return pwpath.dirname(this.path) },
|
return pwpath.dirname(this.path) },
|
||||||
//set dir(value){ },
|
//set dir(value){ },
|
||||||
|
|
||||||
|
get title(){ return async function(){
|
||||||
|
return (await this.data).title
|
||||||
|
?? this.path }.call(this) },
|
||||||
|
set title(value){
|
||||||
|
this.__update__({title: value}) },
|
||||||
|
|
||||||
get isPattern(){
|
get isPattern(){
|
||||||
return this.path.includes('*') },
|
return this.path.includes('*') },
|
||||||
|
|
||||||
@ -230,16 +238,18 @@ object.Constructor('BasePage', {
|
|||||||
var res = (this.isPattern
|
var res = (this.isPattern
|
||||||
&& !this.__energetic
|
&& !this.__energetic
|
||||||
&& !page[name].energetic) ?
|
&& !page[name].energetic) ?
|
||||||
page
|
await page
|
||||||
.map(function(page){
|
.map(function(page){
|
||||||
var res = page[name]
|
var res = page[name]
|
||||||
return typeof(res) == 'function' ?
|
return typeof(res) == 'function' ?
|
||||||
res.bind(page)
|
res.bind(page)
|
||||||
: function(){
|
: function(){
|
||||||
return res } })
|
return res } })
|
||||||
: page[name]
|
: await page[name]
|
||||||
return typeof(res) == 'function' ?
|
return typeof(res) == 'function' ?
|
||||||
res.bind(page)
|
res.bind(page)
|
||||||
|
: res instanceof Array ?
|
||||||
|
res
|
||||||
: function(){
|
: function(){
|
||||||
return res } }
|
return res } }
|
||||||
|
|
||||||
@ -1561,7 +1571,6 @@ object.Constructor('pWikiPageElement', Page, {
|
|||||||
actions: new Set([
|
actions: new Set([
|
||||||
...CachedPage.prototype.actions,
|
...CachedPage.prototype.actions,
|
||||||
|
|
||||||
'title',
|
|
||||||
'hash'
|
'hash'
|
||||||
]),
|
]),
|
||||||
|
|
||||||
@ -1589,14 +1598,19 @@ object.Constructor('pWikiPageElement', Page, {
|
|||||||
object.parentProperty(pWikiPageElement.prototype, 'location')
|
object.parentProperty(pWikiPageElement.prototype, 'location')
|
||||||
.set.call(this, value) },
|
.set.call(this, value) },
|
||||||
|
|
||||||
// XXX this is not persistent, is this what we want???
|
/*/ XXX this is not persistent, is this what we want???
|
||||||
// XXX should this default to .path or to .name???
|
// XXX should this default to .path or to .name???
|
||||||
get title(){
|
get title(){
|
||||||
return this.dom.getAttribute('title')
|
return this.dom.getAttribute('title')
|
||||||
|| (this.dom.querySelector('h1') || {}).innerText
|
|| (this.dom.querySelector('h1') || {}).innerText
|
||||||
|| this.path },
|
|| this.path
|
||||||
|
|| object.parentProperty(pWikiPageElement.prototype, 'title')
|
||||||
|
.get.call(this) },
|
||||||
set title(value){
|
set title(value){
|
||||||
this.dom.setAttribute('title', value) },
|
this.dom.setAttribute('title', value)
|
||||||
|
object.parentProperty(pWikiPageElement.prototype, 'title')
|
||||||
|
.set.call(this, value) },
|
||||||
|
//*/
|
||||||
|
|
||||||
// events...
|
// events...
|
||||||
//
|
//
|
||||||
@ -1984,7 +1998,6 @@ module.Test = {
|
|||||||
./tree <br>
|
./tree <br>
|
||||||
./**/path <br> ` },
|
./**/path <br> ` },
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate pages...
|
// Generate pages...
|
||||||
PAGES=100
|
PAGES=100
|
||||||
for(var i=0; i<PAGES; i++){
|
for(var i=0; i<PAGES; i++){
|
||||||
|
|||||||
@ -779,23 +779,27 @@ module.CachedStore = {
|
|||||||
get cache(){
|
get cache(){
|
||||||
return (this.__cache = this.__cache ?? {}) },
|
return (this.__cache = this.__cache ?? {}) },
|
||||||
set cache(value){
|
set cache(value){
|
||||||
this.__cache_data = value },
|
this.__cache = value },
|
||||||
|
|
||||||
clearCache: function(){
|
clearCache: function(){
|
||||||
this.cache = {}
|
this.cache = {}
|
||||||
return this },
|
return this },
|
||||||
|
|
||||||
exists: async function(path){
|
exists: async function(path){
|
||||||
return path in this.cache
|
return path in this.cache ?
|
||||||
|| object.parentCall(CachedStore.exists, this, ...arguments) },
|
path
|
||||||
|
: object.parentCall(CachedStore.exists, this, ...arguments) },
|
||||||
// XXX this sometimes caches promises...
|
// XXX this sometimes caches promises...
|
||||||
get: async function(path){
|
get: async function(path){
|
||||||
return this.cache[path]
|
return this.cache[path]
|
||||||
?? (this.cache[path] =
|
?? (this.cache[path] =
|
||||||
await object.parentCall(CachedStore.get, this, ...arguments)) },
|
await object.parentCall(CachedStore.get, this, ...arguments)) },
|
||||||
update: async function(path, data){
|
update: async function(path, data){
|
||||||
this.cache[path] = data
|
var that = this
|
||||||
return object.parentCall(CachedStore.update, this, ...arguments) },
|
var res = object.parentCall(CachedStore.update, this, ...arguments)
|
||||||
|
res.then(async function(){
|
||||||
|
that.cache[path] = await that.get(path) })
|
||||||
|
return res },
|
||||||
/* XXX
|
/* XXX
|
||||||
metadata: async function(path, data){
|
metadata: async function(path, data){
|
||||||
if(data){
|
if(data){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user