pWiki/pwiki2.html

134 lines
3.5 KiB
HTML
Raw Normal View History

<!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>
<!-- XXX do we need this??? -->
<script src="bootstrap.js"></script>
<!--script data-main="pwiki2" src="ext-lib/require.js"></script-->
<script src="ext-lib/require.js"></script>
<script>
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 }, {}) }
require.config({
paths: {
...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',
],
// external stuff...
...makeFallbacks({
'jszip': 'node_modules/jszip/dist/jszip',
'pouchdb': 'node_modules/pouchdb/dist/pouchdb',
'showdown': 'node_modules/showdown/dist/showdown',
}, ['ext-lib']),
},
packages: [
'ig-types',
]
})
document.pwikiloaded = new Event('pwikiloaded')
// start loading pWiki...
require(['./browser'], function(pwiki){
pwiki = window.pwiki = pwiki.pwiki
pwiki.dom = document.querySelector('#pWiki')
// handle location.hash/history (both directions)
window.addEventListener('hashchange', function(evt){
evt.preventDefault()
var [path, hash] = location.hash.slice(1).split('#')
path = path.trim() == '' ?
'/'
: path
pwiki.path = path })
pwiki
.onNavigate(function(){
// NOTE: we do not need to directly update location.hash here as
// that will push an extra history item...
history.replaceState({path: pwiki.path}, pwiki.title, '#'+pwiki.path)
// NOTE: we are intentionally not awaiting for this -- this
// separates the navigate and load events...
pwiki.refresh() })
.onLoad(function(evt){
// handle title...
document.querySelector('title').innerHTML = this.title
// XXX when loaded us <elem>.scrollIntoView() to get to hash...
// ...would also be nice to keep hash within location.hash...
})
// show current page...
pwiki.path = location.hash.slice(1)
})
</script>
<body>
<div id="pWiki" />
</body>
</html>
<!-- vim:set sw=4 ts=4 : -->