mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 10:00:08 +00:00
added "energetic" pages, still thinking about the exact API...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6febaa72f8
commit
ce7c1ed377
@ -169,8 +169,10 @@ object.Constructor('BasePage', {
|
||||
get data(){ return (async function(){
|
||||
var that = this
|
||||
// NOTE: we need to make sure each page gets the chance to handle
|
||||
// its context....
|
||||
if(this.isPattern){
|
||||
// its context (i.e. bind action to page)....
|
||||
if(this.isPattern
|
||||
// XXX ENERGETIC...
|
||||
&& !this.store.isEnergetic(this.path)){
|
||||
return this
|
||||
.map(function(page){
|
||||
return page.data }) }
|
||||
@ -179,7 +181,6 @@ object.Constructor('BasePage', {
|
||||
return typeof(res) == 'function' ?
|
||||
res.bind(this)
|
||||
: res }).call(this) },
|
||||
//return this.store.get(this.location, !!this.strict) },
|
||||
set data(value){
|
||||
this.__update__(value) },
|
||||
|
||||
@ -296,7 +297,9 @@ object.Constructor('BasePage', {
|
||||
path = path ?
|
||||
pwpath.relative(this.path, path)
|
||||
: this.path
|
||||
var paths = path.includes('*') ?
|
||||
var paths = path.includes('*')
|
||||
// XXX ENERGETIC...
|
||||
&& !await this.store.isEnergetic(path) ?
|
||||
this.resolve(path)
|
||||
: path
|
||||
paths = paths instanceof Array ?
|
||||
@ -1525,14 +1528,15 @@ module.System = {
|
||||
text: object.doc`
|
||||
<slot name="header">
|
||||
<a href="#/list">☰</a>
|
||||
@source(/rootpath)
|
||||
<a href="#@source(/rootpath)/_edit">(edit)</a>
|
||||
@source(./!path)
|
||||
<a href="#@source(./!path)/_edit">(edit)</a>
|
||||
</slot>
|
||||
<hr>
|
||||
<slot name="content"></slot>
|
||||
<hr>
|
||||
<slot name="footer"></slot>
|
||||
|
||||
<!-- fill slots defaults -->
|
||||
<slot name="content" hidden>
|
||||
@include(. join="@source(file-separator)" recursive="")
|
||||
</slot>` },
|
||||
@ -1612,15 +1616,17 @@ module.System = {
|
||||
@source(../path)
|
||||
</slot>
|
||||
<macro src="../*" join="@source(line-separator)">
|
||||
<a href="#@source(./path)/list">@source(./name)</a>
|
||||
<i>
|
||||
<a href="#@source(./path)">@source(./name)</a>
|
||||
<sup>
|
||||
<macro src="./isAction">
|
||||
a
|
||||
<else>
|
||||
<macro src="./isStore">s</macro>
|
||||
</else>
|
||||
</macro>
|
||||
</i>
|
||||
</sup>
|
||||
(<a href="#@source(./path)/list">@include(./*/!count)</a>)
|
||||
|
||||
<a href="#@source(./path)/delete">×</a>
|
||||
</macro>` },
|
||||
// XXX this is really slow...
|
||||
@ -1706,6 +1712,11 @@ module.System = {
|
||||
return this.get('..').location },
|
||||
path: function(){
|
||||
return this.get('..').path },
|
||||
// XXX ENERGETIC...
|
||||
'!path': Object.assign(
|
||||
function(){
|
||||
return this.get('..').path },
|
||||
{energetic: true}),
|
||||
rootpath: function(){
|
||||
return this.root.path },
|
||||
resolved: async function(){
|
||||
@ -1718,6 +1729,13 @@ module.System = {
|
||||
var p = this.get('..')
|
||||
return p.title
|
||||
?? p.name },
|
||||
count: async function(){
|
||||
return this.get('..').length },
|
||||
// XXX ENERGETIC...
|
||||
'!count': Object.assign(
|
||||
async function(){
|
||||
return this.get('..').length },
|
||||
{energetic: true}),
|
||||
ctime: async function(){
|
||||
var date = (await this.get('..').data).ctime
|
||||
return date ?
|
||||
|
||||
@ -60,14 +60,14 @@ function(name, get, update, ...args){
|
||||
// - overload:
|
||||
// .__paths__()
|
||||
// -> <keys>
|
||||
// .__exists__(..)
|
||||
// .__exists__(path, ..)
|
||||
// -> <path>
|
||||
// -> false
|
||||
// .__get__(..)
|
||||
// .__get__(path, ..)
|
||||
// -> <data>
|
||||
// - optionally (for writable stores)
|
||||
// .__update__(..)
|
||||
// .__delete__(..)
|
||||
// .__update__(path, ..)
|
||||
// .__delete__(path, ..)
|
||||
// .load(..)
|
||||
//
|
||||
//
|
||||
@ -356,8 +356,13 @@ module.BaseStore = {
|
||||
return this.data[key] },
|
||||
get: async function(path, strict=false){
|
||||
var that = this
|
||||
//path = this.match(path, strict)
|
||||
/* XXX ENERGETIC...
|
||||
path = await this.resolve(path, strict)
|
||||
/*/
|
||||
path = path.includes('*')
|
||||
&& await this.isEnergetic(path)
|
||||
|| await this.resolve(path, strict)
|
||||
//*/
|
||||
return path instanceof Array ?
|
||||
// XXX should we return matched paths???
|
||||
Promise.iter(path)
|
||||
@ -371,6 +376,12 @@ module.BaseStore = {
|
||||
?? ((this.next || {}).__get__
|
||||
&& this.next.get(path, strict))) },
|
||||
|
||||
// XXX EXPERIMENTAL...
|
||||
isEnergetic: async function(path){
|
||||
var p = await this.find(path)
|
||||
return !!(await this.get(p, true) ?? {}).energetic
|
||||
&& p },
|
||||
|
||||
//
|
||||
// Get metadata...
|
||||
// .metadata(<path>)
|
||||
|
||||
14
pwiki2.js
14
pwiki2.js
@ -1,6 +1,20 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
*
|
||||
* XXX FEATURE need to be able to call some actions on the root page
|
||||
* before it gets .each()'ed...
|
||||
* ...for things like:
|
||||
* - count
|
||||
* - unexpandedpath (name?)
|
||||
* - ...
|
||||
* this can be done in one of two ways:
|
||||
* - syntax
|
||||
* + will enable any action to be called energetically...
|
||||
* - a complication...
|
||||
* - special actions
|
||||
* + transparent
|
||||
* - extra concept -- might be confusing
|
||||
* - duplicate actions
|
||||
* XXX FEATURE tags and accompanying API...
|
||||
* - add tags to page -- macro/filter
|
||||
* <page>.text -> <page>.tags (cached on .update(..))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user