| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | <!DOCTYPE html> | 
					
						
							|  |  |  | <html> | 
					
						
							|  |  |  | <!--html manifest="pwiki.appcache"--> | 
					
						
							|  |  |  | <head> | 
					
						
							|  |  |  | <title>pWiki</title> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <meta charset="utf-8"> | 
					
						
							|  |  |  | <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <link rel="manifest" href="manifest.json"> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Bold.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-BoldItalic.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-ExtraBold.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-ExtraBoldItalic.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Italic.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Light.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-LightItalic.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Regular.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Semibold.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-SemiboldItalic.ttf"> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <link rel="stylesheet" href="css/fonts.css"> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </head> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <style> | 
					
						
							|  |  |  | </style> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | <!-- XXX do we need this??? --> | 
					
						
							|  |  |  | <script src="bootstrap.js"></script> | 
					
						
							| 
									
										
										
										
											2022-08-04 14:29:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | <!--script data-main="pwiki2" src="ext-lib/require.js"></script--> | 
					
						
							|  |  |  | <script src="ext-lib/require.js"></script> | 
					
						
							|  |  |  | <script> | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var makeFallbacks =  | 
					
						
							|  |  |  | function(paths, search=['lib']){ | 
					
						
							|  |  |  | 	return Object.entries(paths) | 
					
						
							|  |  |  | 		.map(function([key, path]){ | 
					
						
							|  |  |  | 			// package... | 
					
						
							|  |  |  | 			if(path.endsWith('/')){ | 
					
						
							|  |  |  | 				return [key, path] } | 
					
						
							|  |  |  | 			return [ | 
					
						
							|  |  |  | 				key, | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					path, | 
					
						
							|  |  |  | 					...search | 
					
						
							|  |  |  | 						.map(function(base){ | 
					
						
							|  |  |  | 							return base +'/'+ path.split(/[\\\/]+/g).pop() }), | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 			] }) | 
					
						
							|  |  |  | 		.reduce(function(res, [key, value]){ | 
					
						
							|  |  |  | 			res[key] = value | 
					
						
							|  |  |  | 			return res }, {}) } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | require.config({ | 
					
						
							|  |  |  | 	paths: { | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 		...makeFallbacks({ | 
					
						
							|  |  |  | 			'ig-doc': 'node_modules/ig-doc/doc', | 
					
						
							|  |  |  | 			'ig-stoppable': 'node_modules/ig-stoppable/stoppable', | 
					
						
							|  |  |  | 			'object-run': 'node_modules/object-run/run', | 
					
						
							|  |  |  | 			'ig-object': 'node_modules/ig-object/object', | 
					
						
							|  |  |  | 		}), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// packages... | 
					
						
							|  |  |  | 		'ig-types': [ | 
					
						
							|  |  |  | 			'node_modules/ig-types', | 
					
						
							|  |  |  | 			'lib/types', | 
					
						
							|  |  |  | 		], | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 		// external stuff... | 
					
						
							|  |  |  | 		...makeFallbacks({ | 
					
						
							|  |  |  | 			'jszip': 'node_modules/jszip/dist/jszip', | 
					
						
							|  |  |  | 			'pouchdb': 'node_modules/pouchdb/dist/pouchdb', | 
					
						
							|  |  |  | 			'showdown': 'node_modules/showdown/dist/showdown', | 
					
						
							|  |  |  | 		}, ['ext-lib']), | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 	packages: [ | 
					
						
							|  |  |  | 		'ig-types', | 
					
						
							|  |  |  | 	] | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-06 11:09:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | document.pwikiloaded = new Event('pwikiloaded') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | // start loading pWiki... | 
					
						
							| 
									
										
										
										
											2022-08-16 11:00:23 +03:00
										 |  |  | require(['./browser'], function(browser){  | 
					
						
							|  |  |  | 	pwiki = window.pwiki = browser.pwiki  | 
					
						
							| 
									
										
										
										
											2022-08-06 11:09:25 +03:00
										 |  |  | 	pwiki.dom = document.querySelector('#pWiki') | 
					
						
							| 
									
										
										
										
											2022-08-16 11:00:23 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-10 11:42:31 +03:00
										 |  |  | 	// handle location.hash/history (both directions) | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 	window.addEventListener('hashchange', function(evt){ | 
					
						
							|  |  |  | 		evt.preventDefault() | 
					
						
							|  |  |  | 		var [path, hash] = location.hash.slice(1).split('#') | 
					
						
							|  |  |  | 		path = path.trim() == '' ?  | 
					
						
							| 
									
										
										
										
											2022-08-10 15:29:45 +03:00
										 |  |  | 			pwiki.path | 
					
						
							|  |  |  | 			//'/' | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 			: path | 
					
						
							| 
									
										
										
										
											2022-08-11 10:39:55 +03:00
										 |  |  | 		// treat links as absolute unless explicitly relative... | 
					
						
							| 
									
										
										
										
											2022-08-10 15:29:45 +03:00
										 |  |  | 		path = /^\.\.?([\\\/].*)?$/.test(path) ? | 
					
						
							|  |  |  | 			path | 
					
						
							|  |  |  | 			: '/'+path | 
					
						
							| 
									
										
										
										
											2022-08-11 10:39:55 +03:00
										 |  |  | 		pwiki.path = [path, hash] }) | 
					
						
							| 
									
										
										
										
											2022-08-10 11:42:31 +03:00
										 |  |  | 	pwiki | 
					
						
							|  |  |  | 		.onNavigate(function(){ | 
					
						
							|  |  |  | 			// NOTE: we do not need to directly update location.hash here as | 
					
						
							|  |  |  | 			//		that will push an extra history item... | 
					
						
							| 
									
										
										
										
											2022-08-10 15:29:45 +03:00
										 |  |  | 			history.replaceState( | 
					
						
							|  |  |  | 				{path: this.path},  | 
					
						
							|  |  |  | 				this.title,  | 
					
						
							|  |  |  | 				'#'+this.path  | 
					
						
							|  |  |  | 					+(this.hash ?  | 
					
						
							|  |  |  | 						'#'+this.hash  | 
					
						
							|  |  |  | 						: '')) | 
					
						
							| 
									
										
										
										
											2022-08-10 11:42:31 +03:00
										 |  |  | 			// NOTE: we are intentionally not awaiting for this -- this  | 
					
						
							|  |  |  | 			//		separates the navigate and load events... | 
					
						
							| 
									
										
										
										
											2022-08-10 15:29:45 +03:00
										 |  |  | 			this.refresh() }) | 
					
						
							| 
									
										
										
										
											2022-08-10 11:42:31 +03:00
										 |  |  | 		.onLoad(function(evt){ | 
					
						
							|  |  |  | 			// handle title... | 
					
						
							|  |  |  | 			document.querySelector('title').innerHTML = this.title | 
					
						
							| 
									
										
										
										
											2022-08-10 15:29:45 +03:00
										 |  |  | 			// scroll to anchor element... | 
					
						
							|  |  |  | 			this.hash | 
					
						
							|  |  |  | 				&& this.dom | 
					
						
							|  |  |  | 					.querySelector('#'+ this.hash) | 
					
						
							|  |  |  | 					.scrollIntoView() }) | 
					
						
							| 
									
										
										
										
											2022-08-16 11:00:23 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// wait for stuff to finish... | 
					
						
							|  |  |  | 	browser.setup.then(function(){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// show current page... | 
					
						
							|  |  |  | 		pwiki.path = location.hash.slice(1) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	}) })  | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-13 14:57:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-14 03:00:06 +03:00
										 |  |  | // XXX make this a 2 stage save -- first cache and then save to store... | 
					
						
							|  |  |  | // XXX versioning??? | 
					
						
							|  |  |  | var SAVE_TIMEOUT = 5000 | 
					
						
							|  |  |  | var SAVE_QUEUE = {} | 
					
						
							|  |  |  | var saveContent = function(path, text){ | 
					
						
							|  |  |  | 	SAVE_QUEUE[path] = text } | 
					
						
							|  |  |  | var saveNow = function(){ | 
					
						
							|  |  |  | 	var queue = Object.entries(SAVE_QUEUE) | 
					
						
							|  |  |  | 	SAVE_QUEUE = {} | 
					
						
							|  |  |  | 	queue | 
					
						
							|  |  |  | 		.forEach(function([path, text]){ | 
					
						
							|  |  |  | 			console.log('saving changes to:', path) | 
					
						
							|  |  |  | 			pwiki.get(path).raw = text }) } | 
					
						
							|  |  |  | setInterval(saveNow, 5000) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-13 14:57:53 +03:00
										 |  |  | // XXX | 
					
						
							| 
									
										
										
										
											2022-08-14 03:00:06 +03:00
										 |  |  | var exportData = async function(){ | 
					
						
							| 
									
										
										
										
											2022-08-13 14:57:53 +03:00
										 |  |  | 	var blob = new Blob([await pwiki.store.json(true)], {type: "text/plain;charset=utf-8"}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var a = document.createElement('a') | 
					
						
							|  |  |  |     var blobURL = a.href = URL.createObjectURL(blob) | 
					
						
							|  |  |  |     a.download = 'pWiki-dump.json' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //document.body.appendChild(a) | 
					
						
							|  |  |  |     a.dispatchEvent(new MouseEvent("click")) | 
					
						
							|  |  |  |     //document.body.removeChild(a) | 
					
						
							|  |  |  |     //URL.revokeObjectURL(blobURL) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | </script> | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | <body> | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-11 10:39:55 +03:00
										 |  |  | <!-- XXX need to add something passive but animated here... --> | 
					
						
							|  |  |  | <div id="pWiki">Loading...</div> | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | </body> | 
					
						
							|  |  |  | </html> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <!-- vim:set sw=4 ts=4 : --> |