mirror of
https://github.com/flynx/pWiki.git
synced 2025-11-01 03:20:08 +00:00
added energetic actions (experimental)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
ce7c1ed377
commit
12c602ff65
@ -166,18 +166,21 @@ object.Constructor('BasePage', {
|
|||||||
// page data...
|
// page data...
|
||||||
//
|
//
|
||||||
strict: undefined,
|
strict: undefined,
|
||||||
|
energetic: undefined,
|
||||||
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 (i.e. bind action to page)....
|
// its context (i.e. bind action to page)....
|
||||||
if(this.isPattern
|
if(this.isPattern
|
||||||
// XXX ENERGETIC...
|
// XXX ENERGETIC...
|
||||||
&& !this.store.isEnergetic(this.path)){
|
&& !(this.energetic
|
||||||
|
|| await this.store.isEnergetic(this.path))){
|
||||||
return this
|
return this
|
||||||
.map(function(page){
|
.map(function(page){
|
||||||
return page.data }) }
|
return page.data }) }
|
||||||
// single page...
|
// single page...
|
||||||
var res = await this.store.get(this.location, !!this.strict)
|
// XXX ENERGETIC...
|
||||||
|
var res = await this.store.get(this.location, !!this.strict, !!this.energetic)
|
||||||
return typeof(res) == 'function' ?
|
return typeof(res) == 'function' ?
|
||||||
res.bind(this)
|
res.bind(this)
|
||||||
: res }).call(this) },
|
: res }).call(this) },
|
||||||
@ -299,7 +302,8 @@ object.Constructor('BasePage', {
|
|||||||
: this.path
|
: this.path
|
||||||
var paths = path.includes('*')
|
var paths = path.includes('*')
|
||||||
// XXX ENERGETIC...
|
// XXX ENERGETIC...
|
||||||
&& !await this.store.isEnergetic(path) ?
|
&& !(this.energetic
|
||||||
|
|| await this.store.isEnergetic(path)) ?
|
||||||
this.resolve(path)
|
this.resolve(path)
|
||||||
: path
|
: path
|
||||||
paths = paths instanceof Array ?
|
paths = paths instanceof Array ?
|
||||||
@ -1527,9 +1531,9 @@ module.System = {
|
|||||||
_view: {
|
_view: {
|
||||||
text: object.doc`
|
text: object.doc`
|
||||||
<slot name="header">
|
<slot name="header">
|
||||||
<a href="#/list">☰</a>
|
<a href="#/list">☰</a>
|
||||||
@source(./!path)
|
@source(./path/!)
|
||||||
<a href="#@source(./!path)/_edit">(edit)</a>
|
<a href="#@source(./path/!)/_edit">(edit)</a>
|
||||||
</slot>
|
</slot>
|
||||||
<hr>
|
<hr>
|
||||||
<slot name="content"></slot>
|
<slot name="content"></slot>
|
||||||
@ -1611,7 +1615,7 @@ module.System = {
|
|||||||
list: {
|
list: {
|
||||||
text: object.doc`
|
text: object.doc`
|
||||||
<slot name="header">
|
<slot name="header">
|
||||||
/list
|
<a href="#/list">☰</a>
|
||||||
<a href="#@source(../../path)/list">⇑</a>
|
<a href="#@source(../../path)/list">⇑</a>
|
||||||
@source(../path)
|
@source(../path)
|
||||||
</slot>
|
</slot>
|
||||||
@ -1625,7 +1629,7 @@ module.System = {
|
|||||||
</else>
|
</else>
|
||||||
</macro>
|
</macro>
|
||||||
</sup>
|
</sup>
|
||||||
(<a href="#@source(./path)/list">@include(./*/!count)</a>)
|
(<a href="#@source(./path)/list">@include(./*/count/!)</a>)
|
||||||
|
|
||||||
<a href="#@source(./path)/delete">×</a>
|
<a href="#@source(./path)/delete">×</a>
|
||||||
</macro>` },
|
</macro>` },
|
||||||
@ -1712,11 +1716,6 @@ 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(){
|
||||||
@ -1731,11 +1730,6 @@ module.System = {
|
|||||||
?? p.name },
|
?? p.name },
|
||||||
count: async function(){
|
count: async function(){
|
||||||
return this.get('..').length },
|
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 ?
|
||||||
@ -1747,6 +1741,13 @@ module.System = {
|
|||||||
(new Date(date)).getTimeStamp()
|
(new Date(date)).getTimeStamp()
|
||||||
: date },
|
: date },
|
||||||
|
|
||||||
|
// XXX ENERGETIC -- a better name???
|
||||||
|
// XXX test this with pages...
|
||||||
|
'!': Object.assign(
|
||||||
|
async function(){
|
||||||
|
return this.get('..', {energetic: true}).raw },
|
||||||
|
{energetic: true}),
|
||||||
|
|
||||||
// XXX EXPERIMENTAL -- page types...
|
// XXX EXPERIMENTAL -- page types...
|
||||||
type: async function(){
|
type: async function(){
|
||||||
return await this.get('..').type },
|
return await this.get('..').type },
|
||||||
|
|||||||
@ -354,13 +354,15 @@ module.BaseStore = {
|
|||||||
// XXX should this return a map for pattern matches???
|
// XXX should this return a map for pattern matches???
|
||||||
__get__: async function(key){
|
__get__: async function(key){
|
||||||
return this.data[key] },
|
return this.data[key] },
|
||||||
get: async function(path, strict=false){
|
get: async function(path, strict=false, energetic=false){
|
||||||
var that = this
|
var that = this
|
||||||
/* XXX ENERGETIC...
|
/* XXX ENERGETIC...
|
||||||
path = await this.resolve(path, strict)
|
path = await this.resolve(path, strict)
|
||||||
/*/
|
/*/
|
||||||
path = path.includes('*')
|
path = path.includes('*')
|
||||||
&& await this.isEnergetic(path)
|
&& (energetic == true ?
|
||||||
|
await this.find(path)
|
||||||
|
: await this.isEnergetic(path))
|
||||||
|| await this.resolve(path, strict)
|
|| await this.resolve(path, strict)
|
||||||
//*/
|
//*/
|
||||||
return path instanceof Array ?
|
return path instanceof Array ?
|
||||||
|
|||||||
92
pwiki2.js
92
pwiki2.js
@ -1,20 +1,13 @@
|
|||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* XXX FEATURE need to be able to call some actions on the root page
|
* XXX ENERGETIC do we need to make this a path syntax thing???
|
||||||
* before it gets .each()'ed...
|
* ...i.e.
|
||||||
* ...for things like:
|
* /some/path/action/! (current)
|
||||||
* - count
|
* vs.
|
||||||
* - unexpandedpath (name?)
|
* /some/path/!action
|
||||||
* - ...
|
* ..."!" is removed before the <store>.__<name>__(..) calls...
|
||||||
* this can be done in one of two ways:
|
* XXX ENERGETIC revise naming...
|
||||||
* - 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(..))
|
||||||
@ -22,6 +15,43 @@
|
|||||||
* - tag cache <store>.tags
|
* - tag cache <store>.tags
|
||||||
* - tag-path filtering...
|
* - tag-path filtering...
|
||||||
* i.e. only show tags within a specific path/pattern...
|
* i.e. only show tags within a specific path/pattern...
|
||||||
|
* - path integration...
|
||||||
|
* i.e. a way to pass tags through path...
|
||||||
|
* /some/path:tags=a,b,c
|
||||||
|
* XXX FEATURE add a uniform way to track some state in links in pwiki
|
||||||
|
* for things like paging and the like with simple user/macro
|
||||||
|
* access (???)...
|
||||||
|
* ...the simplest that comes to mind is to store in in path
|
||||||
|
* somehow:
|
||||||
|
* - <path>?<arg>=<value>&...
|
||||||
|
* traditional "query string"...
|
||||||
|
* - <path>/<arg>:<valu>/<arg>:<value>/.../<action>
|
||||||
|
* stack-style arguments...
|
||||||
|
* + simple to implement
|
||||||
|
* - goes through page search???
|
||||||
|
* - <path>:<value>:<name>=<value>:...
|
||||||
|
* - ...
|
||||||
|
* the general idea is to be:
|
||||||
|
* - flexible enough to allow the basics done
|
||||||
|
* - restrictive enough to prevent misuse
|
||||||
|
* ...the rest of the state can simply be stored in the root pwiki
|
||||||
|
* object in one of the following ways:
|
||||||
|
* - directly (attrs/dict)
|
||||||
|
* - a special page
|
||||||
|
* - virtual (path-specific)
|
||||||
|
* e.g.
|
||||||
|
* /some/path/@state/page -> 4
|
||||||
|
* ...might be fun to implement a basic json editor
|
||||||
|
* and viewer with this api...
|
||||||
|
* ...controlled via js
|
||||||
|
* ...or special actions:
|
||||||
|
* /some/path/@state/page/next (increment)
|
||||||
|
* /some/path/@state/page/prev (decrement)
|
||||||
|
* /some/path/@state/page=10 (assign)
|
||||||
|
* ...
|
||||||
|
* - session
|
||||||
|
* - stored (config)
|
||||||
|
* ...css selector as path....
|
||||||
* XXX revise/update sort...
|
* XXX revise/update sort...
|
||||||
* XXX fs store: metadata and cache...
|
* XXX fs store: metadata and cache...
|
||||||
* XXX sub/nested store mixing...
|
* XXX sub/nested store mixing...
|
||||||
@ -67,40 +97,6 @@
|
|||||||
* XXX FEATURE self-doc:
|
* XXX FEATURE self-doc:
|
||||||
* - some thing lile Action(<name>, <doc>, <func>|<str>)
|
* - some thing lile Action(<name>, <doc>, <func>|<str>)
|
||||||
* - System/doc -- show <doc> for action...
|
* - System/doc -- show <doc> for action...
|
||||||
* XXX FEATURE add a uniform way to track some state in links in pwiki
|
|
||||||
* for things like paging and the like with simple user/macro
|
|
||||||
* access (???)...
|
|
||||||
* ...the simplest that comes to mind is to store in in path
|
|
||||||
* somehow:
|
|
||||||
* - <path>?<arg>=<value>&...
|
|
||||||
* traditional "query string"...
|
|
||||||
* - <path>/<arg>:<valu>/<arg>:<value>/.../<action>
|
|
||||||
* stack-style arguments...
|
|
||||||
* + simple to implement
|
|
||||||
* - goes through page search???
|
|
||||||
* - <path>:<value>:<name>=<value>:...
|
|
||||||
* - ...
|
|
||||||
* the general idea is to be:
|
|
||||||
* - flexible enough to allow the basics done
|
|
||||||
* - restrictive enough to prevent misuse
|
|
||||||
* ...the rest of the state can simply be stored in the root pwiki
|
|
||||||
* object in one of the following ways:
|
|
||||||
* - directly (attrs/dict)
|
|
||||||
* - a special page
|
|
||||||
* - virtual (path-specific)
|
|
||||||
* e.g.
|
|
||||||
* /some/path/@state/page -> 4
|
|
||||||
* ...might be fun to implement a basic json editor
|
|
||||||
* and viewer with this api...
|
|
||||||
* ...controlled via js
|
|
||||||
* ...or special actions:
|
|
||||||
* /some/path/@state/page/next (increment)
|
|
||||||
* /some/path/@state/page/prev (decrement)
|
|
||||||
* /some/path/@state/page=10 (assign)
|
|
||||||
* ...
|
|
||||||
* - session
|
|
||||||
* - stored (config)
|
|
||||||
* ...css selector as path....
|
|
||||||
* XXX GENERATOR make pattern path parsing a generator...
|
* XXX GENERATOR make pattern path parsing a generator...
|
||||||
* ...experiment with a controllable iterator/range thing...
|
* ...experiment with a controllable iterator/range thing...
|
||||||
* This would require:
|
* This would require:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user