From f8e5b88a09f5133ed7a1198be4fe9c43acffc1af Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 20 Aug 2022 09:37:05 +0300 Subject: [PATCH] experimenting and notes... Signed-off-by: Alex A. Naanou --- browser.js | 6 +++-- pwiki/page.js | 65 +++++++++++++++++++++++++++++++++++++++++++++------ pwiki2.js | 7 ++++-- 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/browser.js b/browser.js index 627f835..f222dd1 100755 --- a/browser.js +++ b/browser.js @@ -33,10 +33,12 @@ module.setup = Promise.all([ // static stores... // - store.update('System', - Object.create(basestore.BaseStore).load(page.System)), store.update('Settings', Object.create(basestore.BaseStore).load(page.Settings)), + store.update('System', + Object.create(basestore.BaseStore).load(page.System)), + store.update('Test', + Object.create(basestore.BaseStore).load(page.Test)), // persistent stores... // diff --git a/pwiki/page.js b/pwiki/page.js index a4ab2a9..78dddb7 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -1435,7 +1435,6 @@ module.System = { return this.get('..').path }, location: function(){ return this.get('..').path }, - // XXX this can be a list for pattern paths... resolved: async function(){ return this.get('..').resolve() }, dir: function(){ @@ -1460,10 +1459,10 @@ module.System = { // XXX return '' }, // XXX links to pages... - to: function(){ + LinksTo: function(){ return (this.get('..').data || {}).to ?? [] }, // XXX pages linking to us... - 'from': function(){ + LinksFrom: function(){ return (this.get('..').data || {})['from'] ?? [] }, @@ -1480,16 +1479,68 @@ module.System = { // show info about the delete operation... return target.get('DeletingPage').text }, + // XXX EXPERIMENTAL + // move page one level up... + moveUp: function(){ + var target = this.get('..') + var to = '../../'+target.name + + target.move(to) + + // redirect... + this.render_root + && (this.render_root.location = to) + // show info about the move operation... + return this.render_root.path }, + // moves page to current location... + // Example + // /path/to/page/moveDown + // /path/page -> /path/to/page + moveDown: function(){ + var to = this.get('..') + var target = to.get('../../'+ to.name) + + target.move(to.path) + + // redirect... + this.render_root + && (this.render_root.location = to.path) + return this.render_root.path }, + + // syntax: + // //to:/move + // + // XXX the syntax works, but there are problems with .move(..) method... + move: async function(){ + var [from, to] = this.get('..').path.split(/\/to:/) + // can't move... + if(!from || !to){ + console.warn(`move: can't move: "${from}" -> "${to}"`) + return '' } + + await this.get(from).move(to) + + // redirect... + this.render_root + && (this.render_root.location = to) + return '' }, + // XXX System/back // XXX System/forward // XXX System/sort // XXX System/reverse - // XXX broken... - test_list: function(){ - return 'abcdef'.split('') }, - test_slots: { +} + +var Test = +module.Test = { + 'list/action': function(){ + return [...'abcdef'] }, + 'list/statuc': { + text: [...'abcdef'] }, + + slots: { text: object.doc` Sequential: unfilled diff --git a/pwiki2.js b/pwiki2.js index 6bf87e1..08bead4 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -1,8 +1,6 @@ /********************************************************************** * * -* XXX does @macro(..) have to follow the same overloading rules as @slot(..)??? -* ...does it?? * XXX GENERATOR make pattern path parsing a generator... * ...experiment with a controllable iterator/range thing... * This would require: @@ -19,6 +17,11 @@ * ...might be a good idea to make filters local only... * XXX slots/macros might also pose a problem... * 2) all the macros that can source pages to produce generators (DONE) +* XXX BUG: .move(..) behaves in an odd way... +* see: System/move page action +* ...deletes the original and moves an empty page -- sync error??? +* XXX does @macro(..) have to follow the same overloading rules as @slot(..)??? +* ...does it?? * XXX ranges in pattern paths -- page-size=X page=Y | from=X to=Y / ... * ...url syntax??? * XXX differenced in behaviour between _abc and abc, either need to make