mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-30 18:40:08 +00:00
refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
eb462a220c
commit
db4121b84e
40
pwiki2.js
40
pwiki2.js
@ -32,6 +32,9 @@ var types = require('ig-types')
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// Path...
|
||||||
|
|
||||||
// XXX might be a good idea to make this compatible with node's path API...
|
// XXX might be a good idea to make this compatible with node's path API...
|
||||||
var path =
|
var path =
|
||||||
module.path = {
|
module.path = {
|
||||||
@ -148,6 +151,7 @@ module.path = {
|
|||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
// Store...
|
||||||
|
|
||||||
//
|
//
|
||||||
// To create a store adapter:
|
// To create a store adapter:
|
||||||
@ -570,6 +574,7 @@ function(name){
|
|||||||
module.path.relative(this.location, path),
|
module.path.relative(this.location, path),
|
||||||
...args) } }
|
...args) } }
|
||||||
|
|
||||||
|
// XXX PATH_VARS
|
||||||
// XXX HISTORY do we need history management???
|
// XXX HISTORY do we need history management???
|
||||||
// XXX FUNC need to handle functions in store...
|
// XXX FUNC need to handle functions in store...
|
||||||
// XXX EVENT add event triggers/handlers...
|
// XXX EVENT add event triggers/handlers...
|
||||||
@ -585,11 +590,11 @@ object.Constructor('BasePage', {
|
|||||||
|
|
||||||
// Path variables...
|
// Path variables...
|
||||||
//
|
//
|
||||||
// XXX should these be here???
|
// XXX PATH_VARS should these be here???
|
||||||
// other places path variables can be resolved:
|
// other places path variables can be resolved:
|
||||||
// - navigation (below)
|
// - navigation (below)
|
||||||
// - macro expansion...
|
// - macro expansion...
|
||||||
// XXX
|
// XXX EXPERIMENTAL...
|
||||||
path_vars: {
|
path_vars: {
|
||||||
NOW: function(){
|
NOW: function(){
|
||||||
return Date.now() },
|
return Date.now() },
|
||||||
@ -661,6 +666,8 @@ object.Constructor('BasePage', {
|
|||||||
// XXX should writing to this move the page???
|
// XXX should writing to this move the page???
|
||||||
//set dir(value){ },
|
//set dir(value){ },
|
||||||
|
|
||||||
|
// history...
|
||||||
|
//
|
||||||
//* XXX HISTORY...
|
//* XXX HISTORY...
|
||||||
// NOTE: set this to false to disable history...
|
// NOTE: set this to false to disable history...
|
||||||
__history: undefined,
|
__history: undefined,
|
||||||
@ -930,12 +937,6 @@ module.BaseParser = {
|
|||||||
|
|
||||||
// helpers...
|
// helpers...
|
||||||
//
|
//
|
||||||
getPositional: function(args){
|
|
||||||
return Object.entries(args)
|
|
||||||
.reduce(function(res, [key, value]){
|
|
||||||
/^[0-9]+$/.test(key)
|
|
||||||
&& (res[key*1] = value)
|
|
||||||
return res }, []) },
|
|
||||||
normalizeFilters: function(filters){
|
normalizeFilters: function(filters){
|
||||||
var skip = new Set()
|
var skip = new Set()
|
||||||
return filters
|
return filters
|
||||||
@ -947,6 +948,25 @@ module.BaseParser = {
|
|||||||
return filter[0] != '-' })
|
return filter[0] != '-' })
|
||||||
.filter(function(filter){
|
.filter(function(filter){
|
||||||
return !skip.has(filter) })},
|
return !skip.has(filter) })},
|
||||||
|
posArgs: function(args){
|
||||||
|
return Object.entries(args)
|
||||||
|
.reduce(function(res, [key, value]){
|
||||||
|
/^[0-9]+$/.test(key)
|
||||||
|
&& (res[key*1] = value)
|
||||||
|
return res }, []) },
|
||||||
|
//
|
||||||
|
// Spec format:
|
||||||
|
// [<orderd>, ... [<keyword>, ...]]
|
||||||
|
//
|
||||||
|
parseArgs: function(spec, args){
|
||||||
|
var ordered = spec.slice()
|
||||||
|
var bool = new Set(
|
||||||
|
ordered[ordered.length-1] instanceof Array ?
|
||||||
|
ordered.pop()
|
||||||
|
: [])
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
// Strip comments...
|
// Strip comments...
|
||||||
//
|
//
|
||||||
@ -1410,7 +1430,7 @@ object.Constructor('Page', BasePage, {
|
|||||||
// positional args...
|
// positional args...
|
||||||
var src = args.src //|| args[0]
|
var src = args.src //|| args[0]
|
||||||
var recursive = args.recursive || body
|
var recursive = args.recursive || body
|
||||||
var isolated = this.__parser__.getPositional(args).includes('isolated')
|
var isolated = this.__parser__.posArgs(args).includes('isolated')
|
||||||
|
|
||||||
if(!src){
|
if(!src){
|
||||||
return '' }
|
return '' }
|
||||||
@ -1561,7 +1581,7 @@ object.Constructor('Page', BasePage, {
|
|||||||
|
|
||||||
//var hidden = name in slots
|
//var hidden = name in slots
|
||||||
// XXX EXPERIMENTAL
|
// XXX EXPERIMENTAL
|
||||||
var pos = this.__parser__.getPositional(args)
|
var pos = this.__parser__.posArgs(args)
|
||||||
var hidden =
|
var hidden =
|
||||||
// 'hidden' has priority...
|
// 'hidden' has priority...
|
||||||
(pos.includes('hidden') || args.hidden)
|
(pos.includes('hidden') || args.hidden)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user