From 50991c004e510ede6b7cff7a68248967dc460931 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 17 Aug 2022 14:10:25 +0300 Subject: [PATCH] experimenting with slots... Signed-off-by: Alex A. Naanou --- pwiki/page.js | 32 +++++++++++++++++++++++------- pwiki2-test.js | 53 ++++++++++++++++++++++++++++++++++---------------- 2 files changed, 61 insertions(+), 24 deletions(-) diff --git a/pwiki/page.js b/pwiki/page.js index 9dc1484..35f6044 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -828,7 +828,7 @@ object.Constructor('Page', BasePage, { // // // NOTE: by default only the first slot with is visible, - // all other slot with will replace its content, unless + // all other slots with will replace its content, unless // explicit shown/hidden arguments are given. // NOTE: hidden has precedence over shown if both are given. // @@ -1217,9 +1217,18 @@ module.System = { // // XXX all of these should support pattern pages... _text: { - text: '@include(. isolated join="@source(file-separator)")' }, - _text2: { - text: '@include(. isolated)' }, + //text: '@include(. isolated join="@source(file-separator)")' }, + // XXX problem: the show slot + text: object.doc` + @source(./path)/_edit +
+ +
+ + + + @include(. join="@source(file-separator)") + ` }, // XXX add join... _raw: { text: '@quote(.)' }, @@ -1233,7 +1242,9 @@ module.System = { _edit: { //_edit: { text: - '' + '@source(./path)' + +'
' + +'' +'
@source(.)' },
+		text: `@source(.)` },
 	// XXX this is really slow...
 	// XXX for some reason replacing both @quote(..) with @source(..) in 
 	// 		the links will break macro parsing...
@@ -1285,6 +1296,13 @@ module.System = {
 		return this.path },
 	test_list: function(){
 		return 'abcdef'.split('') },
+	// XXX problem: it appears that we can't fill a slot from within a slot...
+	// 		...the "content" slot below does not override the content slot in _text
+	test_slots: {
+		text: object.doc`OUTER
+		HEADER
+		CONTENT
+		FOOTER `},
 
 
 	// page parts...
@@ -1298,7 +1316,7 @@ module.System = {
 	RecursionError: {
 		text: 'RECURSION ERROR: @quote(../path)' },
 	NotFoundError: { 
-		text: 'NOT FOUND ERROR: @quote(../path)' },
+		text: 'NOT FOUND ERROR: @quote(./path)' },
 
 	DeletingPage: {
 		text: 'Deleting: @source(../path)' },
diff --git a/pwiki2-test.js b/pwiki2-test.js
index fcd3218..bd18fc6 100755
--- a/pwiki2-test.js
+++ b/pwiki2-test.js
@@ -32,22 +32,21 @@ store.next.load(
 			return res }, {}))
 //*/
 
-// XXX these are async...
-// 		...see browser.js for a way to deal with this...
-pwiki.store.update('@file-ro', {
-	__proto__: filestore.FileStoreRO,
-	__path__: 'bootstrap',
-})
-
-pwiki.store.update('@file', {
-	__proto__: filestore.FileStore,
-	__path__: 'data/fs',
-})
-
-pwiki.store.update('@pouch', {
-	__proto__: pouchdbstore.PouchDBStore,
-	__path__: 'data/pouch',
-})
+module.setup = 
+Promise.all([
+	pwiki.store.update('@file-ro', {
+		__proto__: filestore.FileStoreRO,
+		__path__: 'bootstrap',
+	}),
+	pwiki.store.update('@file', {
+		__proto__: filestore.FileStore,
+		__path__: 'data/fs',
+	}),
+	pwiki.store.update('@pouch', {
+		__proto__: pouchdbstore.PouchDBStore,
+		__path__: 'data/pouch',
+	}),
+])
 
 
 //---------------------------------------------------------------------
@@ -165,7 +164,7 @@ pwiki.pwiki
 
 			@filter(wikiword markdown) `, })
 	.update({
-		location: '/test/slots',
+		location: '/test/slot',
 		text: object.doc`
 			Testing slot mechanics...
 
@@ -175,6 +174,26 @@ pwiki.pwiki
 
 			text is filling a slot
 		`, })
+	.update({
+		location: '/test/slots',
+		text: object.doc`
+			unfilled
+
+			filled
+
+			refilled `, })
+	.update({
+		location: '/test/nestedslots',
+		text: object.doc`
+			
+				unfilled
+				
+					filled
+					
+						refilled
+					
+				
+			 `, })
 	.update({
 		location: '/test/a',
 		text: 'a',