mirror of
https://github.com/flynx/pWiki.git
synced 2025-11-01 03:20: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(){
|
get data(){ return (async function(){
|
||||||
var that = this
|
var that = this
|
||||||
// NOTE: we need to make sure each page gets the chance to handle
|
// NOTE: we need to make sure each page gets the chance to handle
|
||||||
// its context....
|
// its context (i.e. bind action to page)....
|
||||||
if(this.isPattern){
|
if(this.isPattern
|
||||||
|
// XXX ENERGETIC...
|
||||||
|
&& !this.store.isEnergetic(this.path)){
|
||||||
return this
|
return this
|
||||||
.map(function(page){
|
.map(function(page){
|
||||||
return page.data }) }
|
return page.data }) }
|
||||||
@ -179,7 +181,6 @@ object.Constructor('BasePage', {
|
|||||||
return typeof(res) == 'function' ?
|
return typeof(res) == 'function' ?
|
||||||
res.bind(this)
|
res.bind(this)
|
||||||
: res }).call(this) },
|
: res }).call(this) },
|
||||||
//return this.store.get(this.location, !!this.strict) },
|
|
||||||
set data(value){
|
set data(value){
|
||||||
this.__update__(value) },
|
this.__update__(value) },
|
||||||
|
|
||||||
@ -296,7 +297,9 @@ object.Constructor('BasePage', {
|
|||||||
path = path ?
|
path = path ?
|
||||||
pwpath.relative(this.path, path)
|
pwpath.relative(this.path, path)
|
||||||
: this.path
|
: this.path
|
||||||
var paths = path.includes('*') ?
|
var paths = path.includes('*')
|
||||||
|
// XXX ENERGETIC...
|
||||||
|
&& !await this.store.isEnergetic(path) ?
|
||||||
this.resolve(path)
|
this.resolve(path)
|
||||||
: path
|
: path
|
||||||
paths = paths instanceof Array ?
|
paths = paths instanceof Array ?
|
||||||
@ -1525,14 +1528,15 @@ module.System = {
|
|||||||
text: object.doc`
|
text: object.doc`
|
||||||
<slot name="header">
|
<slot name="header">
|
||||||
<a href="#/list">☰</a>
|
<a href="#/list">☰</a>
|
||||||
@source(/rootpath)
|
@source(./!path)
|
||||||
<a href="#@source(/rootpath)/_edit">(edit)</a>
|
<a href="#@source(./!path)/_edit">(edit)</a>
|
||||||
</slot>
|
</slot>
|
||||||
<hr>
|
<hr>
|
||||||
<slot name="content"></slot>
|
<slot name="content"></slot>
|
||||||
<hr>
|
<hr>
|
||||||
<slot name="footer"></slot>
|
<slot name="footer"></slot>
|
||||||
|
|
||||||
|
<!-- fill slots defaults -->
|
||||||
<slot name="content" hidden>
|
<slot name="content" hidden>
|
||||||
@include(. join="@source(file-separator)" recursive="")
|
@include(. join="@source(file-separator)" recursive="")
|
||||||
</slot>` },
|
</slot>` },
|
||||||
@ -1612,15 +1616,17 @@ module.System = {
|
|||||||
@source(../path)
|
@source(../path)
|
||||||
</slot>
|
</slot>
|
||||||
<macro src="../*" join="@source(line-separator)">
|
<macro src="../*" join="@source(line-separator)">
|
||||||
<a href="#@source(./path)/list">@source(./name)</a>
|
<a href="#@source(./path)">@source(./name)</a>
|
||||||
<i>
|
<sup>
|
||||||
<macro src="./isAction">
|
<macro src="./isAction">
|
||||||
a
|
a
|
||||||
<else>
|
<else>
|
||||||
<macro src="./isStore">s</macro>
|
<macro src="./isStore">s</macro>
|
||||||
</else>
|
</else>
|
||||||
</macro>
|
</macro>
|
||||||
</i>
|
</sup>
|
||||||
|
(<a href="#@source(./path)/list">@include(./*/!count)</a>)
|
||||||
|
|
||||||
<a href="#@source(./path)/delete">×</a>
|
<a href="#@source(./path)/delete">×</a>
|
||||||
</macro>` },
|
</macro>` },
|
||||||
// XXX this is really slow...
|
// XXX this is really slow...
|
||||||
@ -1706,6 +1712,11 @@ module.System = {
|
|||||||
return this.get('..').location },
|
return this.get('..').location },
|
||||||
path: function(){
|
path: function(){
|
||||||
return this.get('..').path },
|
return this.get('..').path },
|
||||||
|
// XXX ENERGETIC...
|
||||||
|
'!path': Object.assign(
|
||||||
|
function(){
|
||||||
|
return this.get('..').path },
|
||||||
|
{energetic: true}),
|
||||||
rootpath: function(){
|
rootpath: function(){
|
||||||
return this.root.path },
|
return this.root.path },
|
||||||
resolved: async function(){
|
resolved: async function(){
|
||||||
@ -1718,6 +1729,13 @@ module.System = {
|
|||||||
var p = this.get('..')
|
var p = this.get('..')
|
||||||
return p.title
|
return p.title
|
||||||
?? p.name },
|
?? 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(){
|
ctime: async function(){
|
||||||
var date = (await this.get('..').data).ctime
|
var date = (await this.get('..').data).ctime
|
||||||
return date ?
|
return date ?
|
||||||
|
|||||||
@ -60,14 +60,14 @@ function(name, get, update, ...args){
|
|||||||
// - overload:
|
// - overload:
|
||||||
// .__paths__()
|
// .__paths__()
|
||||||
// -> <keys>
|
// -> <keys>
|
||||||
// .__exists__(..)
|
// .__exists__(path, ..)
|
||||||
// -> <path>
|
// -> <path>
|
||||||
// -> false
|
// -> false
|
||||||
// .__get__(..)
|
// .__get__(path, ..)
|
||||||
// -> <data>
|
// -> <data>
|
||||||
// - optionally (for writable stores)
|
// - optionally (for writable stores)
|
||||||
// .__update__(..)
|
// .__update__(path, ..)
|
||||||
// .__delete__(..)
|
// .__delete__(path, ..)
|
||||||
// .load(..)
|
// .load(..)
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -356,8 +356,13 @@ module.BaseStore = {
|
|||||||
return this.data[key] },
|
return this.data[key] },
|
||||||
get: async function(path, strict=false){
|
get: async function(path, strict=false){
|
||||||
var that = this
|
var that = this
|
||||||
//path = this.match(path, strict)
|
/* XXX ENERGETIC...
|
||||||
path = await this.resolve(path, strict)
|
path = await this.resolve(path, strict)
|
||||||
|
/*/
|
||||||
|
path = path.includes('*')
|
||||||
|
&& await this.isEnergetic(path)
|
||||||
|
|| await this.resolve(path, strict)
|
||||||
|
//*/
|
||||||
return path instanceof Array ?
|
return path instanceof Array ?
|
||||||
// XXX should we return matched paths???
|
// XXX should we return matched paths???
|
||||||
Promise.iter(path)
|
Promise.iter(path)
|
||||||
@ -371,6 +376,12 @@ module.BaseStore = {
|
|||||||
?? ((this.next || {}).__get__
|
?? ((this.next || {}).__get__
|
||||||
&& this.next.get(path, strict))) },
|
&& 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...
|
// Get metadata...
|
||||||
// .metadata(<path>)
|
// .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...
|
* 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(..))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user