| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | /********************************************************************** | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | **********************************************************************/ | 
					
						
							|  |  |  | ((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define) | 
					
						
							|  |  |  | (function(require){ var module={} // make module AMD/node compatible...
 | 
					
						
							|  |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-06 01:26:31 +03:00
										 |  |  | var object = require('ig-object') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | var pwiki = require('./pwiki2') | 
					
						
							| 
									
										
										
										
											2022-08-06 11:09:25 +03:00
										 |  |  | module.path = pwiki.path | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | // XXX for some reason this does not run quietly in browser
 | 
					
						
							| 
									
										
										
										
											2022-08-05 18:21:18 +03:00
										 |  |  | var pouchdbstore = require('./pwiki/store/pouchdb') | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | // XXX need to prevent this from breaking in browser...
 | 
					
						
							| 
									
										
										
										
											2022-08-05 18:21:18 +03:00
										 |  |  | var filestore = require('./pwiki/store/file') | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | // XXX this fails silently in browser...
 | 
					
						
							| 
									
										
										
										
											2022-11-10 21:04:20 +03:00
										 |  |  | //var bootstrap = require('./bootstrap')
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //---------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*/ // XXX chained system store...
 | 
					
						
							|  |  |  | store.next.load( | 
					
						
							|  |  |  | 	// Create a new system action-set with paths starting with 'System/'
 | 
					
						
							|  |  |  | 	Object.entries(System) | 
					
						
							|  |  |  | 		.reduce(function(res, [key, func]){ | 
					
						
							|  |  |  | 			res[pwpath.join('System', key)] = func | 
					
						
							|  |  |  | 			return res }, {})) | 
					
						
							|  |  |  | //*/
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-17 14:10:25 +03:00
										 |  |  | 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', | 
					
						
							|  |  |  | 	}), | 
					
						
							|  |  |  | ]) | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //---------------------------------------------------------------------
 | 
					
						
							|  |  |  | // XXX experiments and testing...
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // XXX for persistent stores test if the data is already loaded here...
 | 
					
						
							| 
									
										
										
										
											2022-08-05 02:47:31 +03:00
										 |  |  | //pwiki.store.load(bootstrap)
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // XXX TEST...
 | 
					
						
							|  |  |  | // XXX add filter tests...
 | 
					
						
							|  |  |  | pwiki.pwiki | 
					
						
							| 
									
										
										
										
											2022-08-15 14:29:45 +03:00
										 |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/markdown', | 
					
						
							|  |  |  | 		text: object.doc`
 | 
					
						
							|  |  |  | 		some text with inline @source(./path) macros... | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		@filter(markdown)` })
 | 
					
						
							| 
									
										
										
										
											2022-08-17 11:46:50 +03:00
										 |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/recursion', | 
					
						
							|  |  |  | 		text: object.doc` @include(.) ` }) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/recursionA', | 
					
						
							|  |  |  | 		text: object.doc` @include(../recursionB) ` }) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/recursionB', | 
					
						
							|  |  |  | 		text: object.doc` @include(../recursionA) ` }) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/recursionC', | 
					
						
							|  |  |  | 		text: object.doc` @include(recursionC) ` }) | 
					
						
							| 
									
										
										
										
											2022-08-14 23:54:02 +03:00
										 |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/sort/*', | 
					
						
							|  |  |  | 		order: ['a', 'c', 'b'], }) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/sort/a', | 
					
						
							|  |  |  | 		text: 'a', }) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/sort/b', | 
					
						
							|  |  |  | 		text: 'b', }) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/sort/c', | 
					
						
							|  |  |  | 		text: 'c', }) | 
					
						
							| 
									
										
										
										
											2022-08-14 03:10:24 +03:00
										 |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/comments', | 
					
						
							|  |  |  | 		text: object.doc`
 | 
					
						
							|  |  |  | 		<!--[pWiki[ This text should be visible... ]]--> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		<!--[pWiki[ | 
					
						
							|  |  |  | 			This text should be visible too...  | 
					
						
							|  |  |  | 		]]--> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		<pwiki-comment> | 
					
						
							|  |  |  | 			And this should not be visible... | 
					
						
							|  |  |  | 		</pwiki-comment> | 
					
						
							|  |  |  | 		`,
 | 
					
						
							|  |  |  | 	}) | 
					
						
							| 
									
										
										
										
											2022-08-14 02:08:27 +03:00
										 |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/test', | 
					
						
							|  |  |  | 		text: 'test', }) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/filter', | 
					
						
							|  |  |  | 		text: object.doc`
 | 
					
						
							|  |  |  | 		Should be: AAAAaaaaAAAAaaaa : test<filter -test>test</filter>@include(../test)@include(../test isolated) | 
					
						
							|  |  |  | 		@filter(test) | 
					
						
							|  |  |  | 		`, })
 | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/filter-local', | 
					
						
							|  |  |  | 		text: object.doc`
 | 
					
						
							|  |  |  | 		Should be: aaaaAAAAaaaa : test<filter test>test</filter>test | 
					
						
							|  |  |  | 		`, })
 | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/filter-isolated', | 
					
						
							|  |  |  | 		text: object.doc`
 | 
					
						
							|  |  |  | 		Should be: AAAAaaaaAAAA : test<filter isolated>test</filter>test | 
					
						
							|  |  |  | 		@filter(test) | 
					
						
							|  |  |  | 		`, })
 | 
					
						
							| 
									
										
										
										
											2022-08-13 14:57:53 +03:00
										 |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/quote', | 
					
						
							|  |  |  | 		text: object.doc`
 | 
					
						
							|  |  |  | 			Inline quoted text: | 
					
						
							|  |  |  | 			--- | 
					
						
							|  |  |  | 			<quote> | 
					
						
							| 
									
										
										
										
											2022-08-14 02:08:27 +03:00
										 |  |  | 				this test should not get expanded: @now() | 
					
						
							| 
									
										
										
										
											2022-08-13 14:57:53 +03:00
										 |  |  | 			</quote> | 
					
						
							|  |  |  | 			--- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			Included quoted text: | 
					
						
							|  |  |  | 			--- | 
					
						
							|  |  |  | 			<quote src="/test/slots"/> | 
					
						
							| 
									
										
										
										
											2022-08-13 16:24:35 +03:00
										 |  |  | 			--- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			Quote filters: | 
					
						
							|  |  |  | 			--- | 
					
						
							| 
									
										
										
										
											2022-08-14 02:08:27 +03:00
										 |  |  | 			<quote filter="quote-tags test"> | 
					
						
							|  |  |  | 				test <now />... | 
					
						
							| 
									
										
										
										
											2022-08-13 16:24:35 +03:00
										 |  |  | 			</quote> | 
					
						
							|  |  |  | 			--- | 
					
						
							| 
									
										
										
										
											2022-08-14 02:08:27 +03:00
										 |  |  | 		`, })
 | 
					
						
							| 
									
										
										
										
											2022-08-14 23:54:02 +03:00
										 |  |  | 	// XXX BUG: this prints '' for each <quote>
 | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/macro-quote', | 
					
						
							|  |  |  | 		text: object.doc`
 | 
					
						
							|  |  |  | 		Outside of macro: | 
					
						
							|  |  |  | 		<quote src="/test/a"/> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		In macro: | 
					
						
							|  |  |  | 		<macro src="/test/*/path" join="\n">-- <quote src="/test/a"/></macro> | 
					
						
							|  |  |  | 		`, })
 | 
					
						
							| 
									
										
										
										
											2022-08-06 01:26:31 +03:00
										 |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/wikiword', | 
					
						
							|  |  |  | 		text: object.doc`
 | 
					
						
							|  |  |  | 			This is a basic WikiWord test, all   | 
					
						
							|  |  |  | 			the [basic] forms and Versions of   | 
					
						
							|  |  |  | 			/inline/links. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-14 02:08:27 +03:00
										 |  |  | 			@filter(wikiword markdown) `, })
 | 
					
						
							| 
									
										
										
										
											2022-08-06 01:26:31 +03:00
										 |  |  | 	.update({ | 
					
						
							| 
									
										
										
										
											2022-08-17 14:10:25 +03:00
										 |  |  | 		location: '/test/slot', | 
					
						
							| 
									
										
										
										
											2022-08-06 01:26:31 +03:00
										 |  |  | 		text: object.doc`
 | 
					
						
							|  |  |  | 			Testing slot mechanics... | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-06 01:37:34 +03:00
										 |  |  | 			This slot is (<slot name="empty">unfilled</slot>) | 
					
						
							| 
									
										
										
										
											2022-08-06 01:26:31 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-06 01:37:34 +03:00
										 |  |  | 			...while this (<slot name="non-empty">text should be replaced...</slot>) | 
					
						
							| 
									
										
										
										
											2022-08-06 01:26:31 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			<slot name="non-empty">text is filling a slot</slot> | 
					
						
							| 
									
										
										
										
											2022-08-14 02:08:27 +03:00
										 |  |  | 		`, })
 | 
					
						
							| 
									
										
										
										
											2022-08-17 14:10:25 +03:00
										 |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/slots', | 
					
						
							|  |  |  | 		text: object.doc`
 | 
					
						
							| 
									
										
										
										
											2022-08-17 15:45:30 +03:00
										 |  |  | 			Sequential: | 
					
						
							|  |  |  | 			<slot name="sequential">unfilled</slot> | 
					
						
							|  |  |  | 			<slot name="sequential">filled</slot> | 
					
						
							|  |  |  | 			<slot name="sequential">refilled</slot>  | 
					
						
							| 
									
										
										
										
											2022-08-17 23:38:24 +03:00
										 |  |  | 			<br><br> | 
					
						
							| 
									
										
										
										
											2022-08-17 15:45:30 +03:00
										 |  |  | 			Nested: | 
					
						
							|  |  |  | 			<slot name="nested"> | 
					
						
							| 
									
										
										
										
											2022-08-17 14:10:25 +03:00
										 |  |  | 				unfilled | 
					
						
							| 
									
										
										
										
											2022-08-17 15:45:30 +03:00
										 |  |  | 				<slot name="nested"> | 
					
						
							| 
									
										
										
										
											2022-08-17 14:10:25 +03:00
										 |  |  | 					filled | 
					
						
							| 
									
										
										
										
											2022-08-17 15:45:30 +03:00
										 |  |  | 					<slot name="nested"> | 
					
						
							| 
									
										
										
										
											2022-08-17 14:10:25 +03:00
										 |  |  | 						refilled | 
					
						
							|  |  |  | 					</slot> | 
					
						
							|  |  |  | 				</slot> | 
					
						
							| 
									
										
										
										
											2022-08-18 01:23:49 +03:00
										 |  |  | 			</slot>  | 
					
						
							|  |  |  | 			<br><br> | 
					
						
							|  |  |  | 			Content: A B C: | 
					
						
							|  |  |  | 			<slot name="slot-content">A</slot> | 
					
						
							|  |  |  | 			<slot name="slot-content"><content/> B</slot> | 
					
						
							|  |  |  | 			<slot name="slot-conten"><content/> C</slot> | 
					
						
							|  |  |  | 			<br><br> | 
					
						
							|  |  |  | 			Nested content: A B C: | 
					
						
							|  |  |  | 			<slot name="nested-slot-content"> | 
					
						
							|  |  |  | 				A | 
					
						
							|  |  |  | 				<slot name="nested-slot-content"> | 
					
						
							|  |  |  | 					<content/> B | 
					
						
							|  |  |  | 					<slot name="nested-slot-content"> | 
					
						
							|  |  |  | 						<content/> C | 
					
						
							|  |  |  | 					</slot> | 
					
						
							|  |  |  | 				</slot> | 
					
						
							| 
									
										
										
										
											2022-08-19 13:13:17 +03:00
										 |  |  | 			</slot> | 
					
						
							|  |  |  | 			<br><br> | 
					
						
							|  |  |  | 			Mixed content: X A B C Z: | 
					
						
							|  |  |  | 			<slot name="mixed-slot-content"> | 
					
						
							|  |  |  | 				X | 
					
						
							|  |  |  | 			</slot> | 
					
						
							|  |  |  | 			<slot name="mixed-slot-content"> | 
					
						
							|  |  |  | 				<content/> A | 
					
						
							|  |  |  | 				<slot name="mixed-slot-content"> | 
					
						
							|  |  |  | 					<content/> B | 
					
						
							|  |  |  | 					<slot name="mixed-slot-content"> | 
					
						
							|  |  |  | 						<content/> C | 
					
						
							|  |  |  | 					</slot> | 
					
						
							|  |  |  | 				</slot> | 
					
						
							|  |  |  | 			</slot>  | 
					
						
							|  |  |  | 			<slot name="mixed-slot-content"> | 
					
						
							|  |  |  | 				<content/> Z | 
					
						
							| 
									
										
										
										
											2022-08-17 14:10:25 +03:00
										 |  |  | 			</slot> `, }) | 
					
						
							| 
									
										
										
										
											2022-08-17 23:38:24 +03:00
										 |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/nesting', | 
					
						
							|  |  |  | 		text: object.doc`
 | 
					
						
							|  |  |  | 			Quote in macro: | 
					
						
							|  |  |  | 			<macro src="."> | 
					
						
							|  |  |  | 				<quote src="./path"/> | 
					
						
							|  |  |  | 			</macro> | 
					
						
							|  |  |  | 			<hr> | 
					
						
							|  |  |  | 			Quote in slot: | 
					
						
							|  |  |  | 			<slot name="moo"> | 
					
						
							|  |  |  | 				<quote src="./path"/> | 
					
						
							|  |  |  | 			</slot>` }) | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/a', | 
					
						
							|  |  |  | 		text: 'a', | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/b', | 
					
						
							|  |  |  | 		text: 'b', | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/c', | 
					
						
							|  |  |  | 		text: 'c', | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/c/x', | 
					
						
							|  |  |  | 		text: 'x', | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/c/y', | 
					
						
							|  |  |  | 		text: 'y', | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test/d/z', | 
					
						
							|  |  |  | 		text: 'z', | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/page', | 
					
						
							| 
									
										
										
										
											2022-08-05 12:46:00 +03:00
										 |  |  | 		text: '>>> PAGE\n' | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 			+'\n' | 
					
						
							|  |  |  | 			+'@include(/test recursive="Recursion type 2 (<now/>)")\n' | 
					
						
							|  |  |  | 			+'\n' | 
					
						
							| 
									
										
										
										
											2022-08-05 12:46:00 +03:00
										 |  |  | 			+'@slot(name=b text="filled slot")\n' | 
					
						
							|  |  |  | 			+ '<<< PAGE\n', | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 	}) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/other', | 
					
						
							|  |  |  | 		text: 'OTHER', | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | 	.update({ | 
					
						
							|  |  |  | 		location: '/test', | 
					
						
							|  |  |  | 		text: 'TEST\n' | 
					
						
							|  |  |  | 			+'\n' | 
					
						
							|  |  |  | 			+'globally filtered test text...\n' | 
					
						
							|  |  |  | 			+'\n' | 
					
						
							| 
									
										
										
										
											2022-08-05 12:46:00 +03:00
										 |  |  | 			// XXX this does not seem to work...
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 			+'<filter -test>...unfiltered test text</filter>\n' | 
					
						
							|  |  |  | 			+'\n' | 
					
						
							|  |  |  | 			//+'<filter test>locally filtered test text</filter>\n'
 | 
					
						
							|  |  |  | 			+'\n' | 
					
						
							| 
									
										
										
										
											2022-08-05 12:46:00 +03:00
										 |  |  | 			// XXX slots do not seem to work...
 | 
					
						
							|  |  |  | 			+'@slot(name=a text="non-filled slot a")\n' | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 			+'\n' | 
					
						
							| 
									
										
										
										
											2022-08-05 12:46:00 +03:00
										 |  |  | 			+'@slot(name=b text="non-filled slot b")\n' | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 			+'\n' | 
					
						
							|  |  |  | 			+'Including /other #1: @include(/other)\n' | 
					
						
							| 
									
										
										
										
											2022-08-05 12:46:00 +03:00
										 |  |  | 			+'Including /other #2: @include(/other)\n' | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 			+'\n' | 
					
						
							|  |  |  | 			+'Including /test: @include(/test recursive="Recursion type 1 (<now/>)")\n' | 
					
						
							|  |  |  | 			+'\n' | 
					
						
							|  |  |  | 			+'Including /page: @include(/page recursive="...")\n' | 
					
						
							|  |  |  | 			+'\n' | 
					
						
							| 
									
										
										
										
											2022-08-05 12:46:00 +03:00
										 |  |  | 			+'Sourceing /: \\@include(/)\n' | 
					
						
							|  |  |  | 			+'\n' | 
					
						
							|  |  |  | 			// XXX slots do not seem to work...
 | 
					
						
							|  |  |  | 			+'<slot name="a">filled slot a</slot>\n' | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 			+'\n' | 
					
						
							|  |  |  | 			+'@filter(test)', | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | //*/
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.pwiki = pwiki.pwiki | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************** | 
					
						
							|  |  |  | * vim:set ts=4 sw=4 :                               */ return module }) |