| 
									
										
										
										
											2022-04-12 01:31:28 +03:00
										 |  |  | /********************************************************************** | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * | 
					
						
							| 
									
										
										
										
											2022-08-14 03:00:06 +03:00
										 |  |  | * XXX BUG: comments seem to be broken -- see: /Doc/About | 
					
						
							| 
									
										
										
										
											2022-08-14 02:08:27 +03:00
										 |  |  | * XXX BUG: browser: .get('/*').raw hangs... | 
					
						
							| 
									
										
										
										
											2022-08-07 08:44:01 +03:00
										 |  |  | * XXX add action to reset overloaded (bootstrap) pages... | 
					
						
							|  |  |  | * 		- per page | 
					
						
							|  |  |  | * 		- global | 
					
						
							| 
									
										
										
										
											2022-08-08 12:29:02 +03:00
										 |  |  | * XXX Q: can we access fs from a pwa??? | 
					
						
							| 
									
										
										
										
											2022-08-07 08:44:01 +03:00
										 |  |  | * | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | * XXX ROADMAP: | 
					
						
							|  |  |  | * 	- run in browser | 
					
						
							| 
									
										
										
										
											2022-08-04 14:29:25 +03:00
										 |  |  | * 		- basics, loading 							-- DONE | 
					
						
							|  |  |  | * 		- test localStorage / sessionStorage 		-- DONE | 
					
						
							|  |  |  | * 		- test pouch								-- DONE | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | * 		- render page								-- DONE | 
					
						
							| 
									
										
										
										
											2022-08-08 12:29:02 +03:00
										 |  |  | * 		- navigation								-- DONE | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | * 			- hash/anchor							-- DONE | 
					
						
							| 
									
										
										
										
											2022-08-14 03:00:06 +03:00
										 |  |  | * 		- basic editor and interactivity			-- DONE | 
					
						
							|  |  |  | * 		- export | 
					
						
							|  |  |  | * 			- json									-- DONE | 
					
						
							|  |  |  | * 			- zip | 
					
						
							| 
									
										
										
										
											2022-08-04 14:29:25 +03:00
										 |  |  | * 		- migrate bootstrap | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | * 		- store topology | 
					
						
							| 
									
										
										
										
											2022-08-11 23:56:43 +03:00
										 |  |  | * 		- sync and sync conf | 
					
						
							| 
									
										
										
										
											2022-08-11 10:39:55 +03:00
										 |  |  | * 	- markdown										-- DONE | 
					
						
							| 
									
										
										
										
											2022-08-10 15:29:45 +03:00
										 |  |  | * 	- WikiWord										-- DONE | 
					
						
							| 
									
										
										
										
											2022-08-10 18:21:00 +03:00
										 |  |  | * 	- dom filter mechanics							-- DONE | 
					
						
							|  |  |  | * 	- filters / dom filters: | 
					
						
							|  |  |  | * 		- wikiword (control) | 
					
						
							|  |  |  | * 			this can be done in one of two ways: | 
					
						
							|  |  |  | * 				- wrapping blocks in elemens | 
					
						
							|  |  |  | * 					...requires negative filter calls, either on -wikiword  | 
					
						
							|  |  |  | * 					or a different filter like nowikiwords... | 
					
						
							|  |  |  | * 				- tags (current) | 
					
						
							|  |  |  | * 		- raw / code | 
					
						
							|  |  |  | * 		- nl2br | 
					
						
							| 
									
										
										
										
											2022-08-13 14:57:53 +03:00
										 |  |  | * 		- path2link (wikiword?)						-- DONE	 | 
					
						
							| 
									
										
										
										
											2022-08-10 15:29:45 +03:00
										 |  |  | * 		- editor | 
					
						
							| 
									
										
										
										
											2022-08-13 14:57:53 +03:00
										 |  |  | * 			MediumEditor (markdown-plugin) | 
					
						
							|  |  |  | * 				https://github.com/yabwe/medium-editor
 | 
					
						
							|  |  |  | * 				https://github.com/IonicaBizau/medium-editor-markdown
 | 
					
						
							|  |  |  | * 					- heavy-ish markdown plugin | 
					
						
							|  |  |  | * 			ToastUI (markdown) | 
					
						
							|  |  |  | * 				https://github.com/nhn/tui.editor
 | 
					
						
							|  |  |  | * 					- quite heavy | 
					
						
							|  |  |  | * 			Pen (markdown) | 
					
						
							|  |  |  | * 				https://github.com/sofish/pen
 | 
					
						
							|  |  |  | * 					- no npm module | 
					
						
							|  |  |  | * 					- not sure if it works on mobile | 
					
						
							|  |  |  | * 					+ small | 
					
						
							|  |  |  | * 			tiptap (no-markdown, investigate y.js) | 
					
						
							| 
									
										
										
										
											2022-08-08 12:29:02 +03:00
										 |  |  | * 	- configuration | 
					
						
							|  |  |  | * 		- defaults | 
					
						
							|  |  |  | * 		- System/config (global) | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | * 	- pwa | 
					
						
							| 
									
										
										
										
											2022-08-08 12:29:02 +03:00
										 |  |  | * 		- service worker ??? | 
					
						
							|  |  |  | * 			...handle relative urls (???) | 
					
						
							| 
									
										
										
										
											2022-08-06 02:07:46 +03:00
										 |  |  | * 	- cli | 
					
						
							|  |  |  | * 		- basic wiki manipulations (1:1 methods) | 
					
						
							|  |  |  | * 		- import/export/sync | 
					
						
							|  |  |  | * 		- introspection/repl | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | * 	- archive old code | 
					
						
							|  |  |  | * 	- update docs | 
					
						
							|  |  |  | * 	- refactor and cleanup | 
					
						
							| 
									
										
										
										
											2022-08-08 12:29:02 +03:00
										 |  |  | * 		- module structure							-- REVISE | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | * 	- pack as electron app (???) | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							| 
									
										
										
										
											2022-08-04 14:29:25 +03:00
										 |  |  | * | 
					
						
							|  |  |  | * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * Architecture: | 
					
						
							|  |  |  | * 	store | 
					
						
							|  |  |  | * 	page | 
					
						
							|  |  |  | * 	renderer | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * Modules: | 
					
						
							|  |  |  | * 	page				- base pages and page APIs (XXX should this be in lib???) | 
					
						
							|  |  |  | * 	parser				- pWiki macro parser (XXX should this be in lib???) | 
					
						
							|  |  |  | * 	store				- stores | 
					
						
							|  |  |  | * 		base			- memory store and store utils | 
					
						
							|  |  |  | *		file			- file storage | 
					
						
							|  |  |  | *		localstorage	- localStorage / sessionStorage stores | 
					
						
							|  |  |  | *		pouchdb			- | 
					
						
							|  |  |  | * 		... | 
					
						
							|  |  |  | * 	filter				- page filters | 
					
						
							|  |  |  | * 		base			- base filters incl. wikiword | 
					
						
							|  |  |  | * 		markdown		- markdown renderer | 
					
						
							|  |  |  | * 		... | 
					
						
							|  |  |  | * 	pwiki2				- main cli / node entry point | 
					
						
							|  |  |  | * 	browser				- browser entry point | 
					
						
							|  |  |  | * 	pwiki2-test			- testing and experimenting (XXX move to test.js) | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * Q: can we make this a single module with +/- some plugins?? | 
					
						
							|  |  |  | * 	...this would make things quite a bit simpler but will negate the  | 
					
						
							|  |  |  | * 	use of high level libs like types... | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							| 
									
										
										
										
											2022-08-11 10:56:11 +03:00
										 |  |  | * XXX DOC: | 
					
						
							|  |  |  | * 		- paths in pWiki behave a bit differently than traditional  | 
					
						
							|  |  |  | * 			file-system paths, this is due to one key distinction: | 
					
						
							|  |  |  | * 				in pWiki there is no distinction between a file and a  | 
					
						
							|  |  |  | * 				directory | 
					
						
							|  |  |  | * 			i.e. each path can both contain data as a file and at the same | 
					
						
							|  |  |  | * 			time support sub-paths etc. | 
					
						
							|  |  |  | * 			for this reason behaviour of some APIs will differ, all paths | 
					
						
							|  |  |  | * 			within a page (a-la file) are relative to its children and not | 
					
						
							|  |  |  | * 			to it's siblings. For example, for page "/a/b/c" a link to "./x" | 
					
						
							|  |  |  | * 			will resolve to "/a/b/c/x" and this is independent of whether | 
					
						
							|  |  |  | * 			the base path is given as "/a/b/c/" or "/a/b/c" | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * 			NOTE: implementing things in a traditional manner would  | 
					
						
							|  |  |  | * 				introduce lots of edge-cases and subtle ways to make  | 
					
						
							|  |  |  | * 				mistakes, bugs and inconsistencies. | 
					
						
							|  |  |  | * 		-  | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							| 
									
										
										
										
											2022-07-11 18:14:11 +03:00
										 |  |  | * XXX weaknesses to review: | 
					
						
							|  |  |  | * 		- <store>.paths() as an index... | 
					
						
							|  |  |  | * 			+ decouples the search logic from the store backend | 
					
						
							|  |  |  | * 			- requires the whole list of pages to be in memory | 
					
						
							|  |  |  | * 				...need to be independent of the number of pages if at  | 
					
						
							|  |  |  | * 				all possible -- otherwise this will hinder long-term use... | 
					
						
							| 
									
										
										
										
											2022-08-06 11:12:52 +03:00
										 |  |  | * 			.paths() should be cached to make all path searches away from  | 
					
						
							|  |  |  | * 			async waits as we can test quite a number of paths before we  | 
					
						
							|  |  |  | * 			find a page... | 
					
						
							|  |  |  | * 			...another solution is to offload the search to the store backend | 
					
						
							|  |  |  | * 			but this would require the stores to reimplement most of pwiki/path | 
					
						
							| 
									
										
										
										
											2022-07-11 18:14:11 +03:00
										 |  |  | * 		-  | 
					
						
							| 
									
										
										
										
											2022-08-06 21:28:52 +03:00
										 |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							| 
									
										
										
										
											2022-08-07 08:44:01 +03:00
										 |  |  | * TODO?: | 
					
						
							| 
									
										
										
										
											2022-07-11 18:14:11 +03:00
										 |  |  | * 	- <page>.then() -- resolve when all pending write operations done ??? | 
					
						
							| 
									
										
										
										
											2022-07-25 23:58:23 +03:00
										 |  |  | * 	- an async REPL??? | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | * 	- custom element??? | 
					
						
							| 
									
										
										
										
											2022-08-07 08:44:01 +03:00
										 |  |  | * 	- might be a good idea to try signature based security: | 
					
						
							| 
									
										
										
										
											2022-04-16 10:53:41 +03:00
										 |  |  | * 		- sign changes | 
					
						
							|  |  |  | * 		- sign sync session | 
					
						
							|  |  |  | * 		- refuse changes with wrong signatures | 
					
						
							|  |  |  | * 		- public keys available on client and on server | 
					
						
							|  |  |  | * 			- check signatures localy | 
					
						
							|  |  |  | * 			- check signatures remotely | 
					
						
							|  |  |  | * 		- private key available only with author | 
					
						
							|  |  |  | * 		- keep both the last signed and superceding unsigned version | 
					
						
							|  |  |  | * 		- on sync ask to overwrite unsigned with signed | 
					
						
							|  |  |  | * 		- check if we can use the same mechanics as ssh... | 
					
						
							|  |  |  | * 		- in this view a user in the system is simply a set of keys and  | 
					
						
							|  |  |  | * 			a signature (a page =)) | 
					
						
							| 
									
										
										
										
											2022-04-12 01:31:28 +03:00
										 |  |  | * | 
					
						
							| 
									
										
										
										
											2022-08-10 18:21:00 +03:00
										 |  |  | * XXX RELATIVE relative urls are a bit odd... | 
					
						
							|  |  |  | * 			Path/to/page opens Moo	-> Path/to/Page/Moo | 
					
						
							|  |  |  | * 		should be (???): | 
					
						
							|  |  |  | * 			Path/to/page opens Moo	-> Path/to/Moo | 
					
						
							|  |  |  | * 		this boils down to how path.relative(..) works, treating the base | 
					
						
							|  |  |  | * 		as a directory always (current) vs. only if '/' is at the end, on  | 
					
						
							|  |  |  | * 		one hand the current approach is more uniform with less subtle ways | 
					
						
							|  |  |  | * 		to make mistakes but on the other hand this may introduce a lot  | 
					
						
							|  |  |  | * 		of complexity to the user writing links, e.g. how should the  | 
					
						
							|  |  |  | * 		following be interpreted? | 
					
						
							|  |  |  | * 			page: /SomePage | 
					
						
							|  |  |  | * 				link: SomeOtherPage | 
					
						
							|  |  |  | * 					-> /SomeOtherPage | 
					
						
							|  |  |  | * 					-> /SomePage/SomeOtherPage (current) | 
					
						
							|  |  |  | * 		the current approach does not seem to be intuitive... | 
					
						
							|  |  |  | * 		can this be fixed uniformly across the whole system??? | 
					
						
							|  |  |  | * 		XXX document this! | 
					
						
							|  |  |  | * | 
					
						
							| 
									
										
										
										
											2022-05-17 17:36:42 +03:00
										 |  |  | * XXX need to think about search -- page function argument syntax??? | 
					
						
							| 
									
										
										
										
											2022-05-17 01:26:39 +03:00
										 |  |  | * | 
					
						
							|  |  |  | * XXX might need to get all the links (macro-level) from a page... | 
					
						
							|  |  |  | * 		...would be useful for caching... | 
					
						
							|  |  |  | * | 
					
						
							| 
									
										
										
										
											2022-05-04 18:26:02 +03:00
										 |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							| 
									
										
										
										
											2022-04-12 01:31:28 +03:00
										 |  |  | **********************************************************************/ | 
					
						
							|  |  |  | ((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define) | 
					
						
							|  |  |  | (function(require){ var module={} // make module AMD/node compatible...
 | 
					
						
							|  |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-21 18:33:08 +03:00
										 |  |  | // XXX
 | 
					
						
							|  |  |  | //var object = require('lib/object')
 | 
					
						
							|  |  |  | var object = require('ig-object') | 
					
						
							| 
									
										
										
										
											2022-04-25 16:00:12 +03:00
										 |  |  | var types = require('ig-types') | 
					
						
							| 
									
										
										
										
											2022-04-21 18:33:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-06 11:09:25 +03:00
										 |  |  | var pwpath =  | 
					
						
							|  |  |  | module.path = | 
					
						
							|  |  |  | 	require('./pwiki/path') | 
					
						
							| 
									
										
										
										
											2022-08-05 18:21:18 +03:00
										 |  |  | var page = require('./pwiki/page') | 
					
						
							| 
									
										
										
										
											2022-04-12 01:31:28 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-05 18:21:18 +03:00
										 |  |  | var basestore = require('./pwiki/store/base') | 
					
						
							| 
									
										
										
										
											2022-04-12 02:07:19 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | //var localstoragestore = require('./store/localstorage')
 | 
					
						
							|  |  |  | // XXX for some reason this does not run quietly in browser
 | 
					
						
							|  |  |  | //var pouchdbstore = require('./store/pouchdb')
 | 
					
						
							|  |  |  | //var filestore = require('./store/file')
 | 
					
						
							| 
									
										
										
										
											2022-04-13 03:14:21 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-13 12:18:13 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-13 03:14:21 +03:00
										 |  |  | //---------------------------------------------------------------------
 | 
					
						
							| 
									
										
										
										
											2022-05-11 15:36:35 +03:00
										 |  |  | // Basic setup...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2022-05-11 16:46:27 +03:00
										 |  |  | // Store topology:
 | 
					
						
							| 
									
										
										
										
											2022-05-11 15:36:35 +03:00
										 |  |  | // 		
 | 
					
						
							|  |  |  | // 		root (BaseStore) ---next--- main (MetaStore)
 | 
					
						
							|  |  |  | // 										|
 | 
					
						
							|  |  |  | // 										+-- System/... (BaseStore)
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2022-05-11 16:46:27 +03:00
										 |  |  | // Alternative store topology:
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 		root (BaseStore) ---next--- main (MetaStore)
 | 
					
						
							|  |  |  | // 			System/... (static)
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2022-05-11 15:36:35 +03:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2022-04-22 12:00:48 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-10 23:58:13 +03:00
										 |  |  | var store =  | 
					
						
							|  |  |  | module.store =  | 
					
						
							| 
									
										
										
										
											2022-05-11 15:27:15 +03:00
										 |  |  | 	//BaseStore.nest()
 | 
					
						
							| 
									
										
										
										
											2022-08-03 01:35:19 +03:00
										 |  |  | 	// XXX clone...
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 	{ __proto__: basestore.BaseStore } | 
					
						
							|  |  |  | 		.nest({ __proto__: basestore.MetaStore }) | 
					
						
							| 
									
										
										
										
											2022-05-10 23:58:13 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-11 15:27:15 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-12 12:04:44 +03:00
										 |  |  | // XXX note sure how to organize the system actions -- there can be two 
 | 
					
						
							| 
									
										
										
										
											2022-05-11 15:27:15 +03:00
										 |  |  | // 		options:
 | 
					
						
							|  |  |  | // 			- a root ram store with all the static stuff and nest the rest
 | 
					
						
							|  |  |  | // 			- a nested store (as is the case here)
 | 
					
						
							|  |  |  | // XXX nested system store...
 | 
					
						
							| 
									
										
										
										
											2022-05-12 09:06:38 +03:00
										 |  |  | store.update('System',  | 
					
						
							| 
									
										
										
										
											2022-08-04 14:29:25 +03:00
										 |  |  | 	Object.create(basestore.BaseStore).load(page.System)) | 
					
						
							| 
									
										
										
										
											2022-08-14 03:00:06 +03:00
										 |  |  | store.update('Settings',  | 
					
						
							|  |  |  | 	Object.create(basestore.BaseStore).load(page.Settings)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-28 22:35:41 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-10 23:58:13 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-23 10:56:24 +03:00
										 |  |  | // NOTE: in general the root wiki api is simply a page instance.
 | 
					
						
							| 
									
										
										
										
											2022-05-03 16:47:43 +03:00
										 |  |  | // XXX not yet sure how to organize the actual client -- UI, hooks, .. etc
 | 
					
						
							| 
									
										
										
										
											2022-04-25 20:53:20 +03:00
										 |  |  | var pwiki = | 
					
						
							| 
									
										
										
										
											2022-04-22 12:00:48 +03:00
										 |  |  | module.pwiki =  | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 	page.Page('/', '/', store) | 
					
						
							| 
									
										
										
										
											2022-04-13 12:18:13 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-13 03:14:21 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-11 15:36:35 +03:00
										 |  |  | //---------------------------------------------------------------------
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | // comandline...
 | 
					
						
							| 
									
										
										
										
											2022-05-11 15:36:35 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | if(typeof(__filename) != 'undefined' | 
					
						
							|  |  |  | 		&& __filename == (require.main || {}).filename){ | 
					
						
							| 
									
										
										
										
											2022-05-11 15:36:35 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-25 20:53:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-04-25 20:53:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-12 01:31:28 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************** | 
					
						
							| 
									
										
										
										
											2022-04-28 14:12:02 +03:00
										 |  |  | * vim:set ts=4 sw=4 nowrap :                        */ return module }) |