mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-17 08:31:38 +00:00
moving to gen2, not done yet...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
bf47eca294
commit
7af3f9d742
112
index2.html
Executable file
112
index2.html
Executable file
@ -0,0 +1,112 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>pWiki</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<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">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script src="ext-lib/jquery.js"></script>
|
||||||
|
<script src="ext-lib/jquery-ui.min.js"></script>
|
||||||
|
<script src="ext-lib/jquery.ui.touch.js"></script>
|
||||||
|
<script src="ext-lib/showdown.min.js"></script>
|
||||||
|
|
||||||
|
<script src="ext-lib/FileSaver.js"></script>
|
||||||
|
<script src="ext-lib/jszip.min.js"></script>
|
||||||
|
|
||||||
|
<script src="ext-lib/pouchdb.min.js"></script>
|
||||||
|
<script src="ext-lib/peer.min.js"></script>
|
||||||
|
|
||||||
|
<script src="bootstrap.js"></script>
|
||||||
|
|
||||||
|
<script data-main="ui" src="ext-lib/require.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var exportZip = function(){
|
||||||
|
var zip = new JSZip()
|
||||||
|
|
||||||
|
var pwiki = zip.folder("pWiki")
|
||||||
|
pwiki.file("data.json", JSON.stringify(Wiki.__wiki_data))
|
||||||
|
|
||||||
|
zip.generateAsync({type:"blob"})
|
||||||
|
.then(function(content) {
|
||||||
|
// see FileSaver.js
|
||||||
|
saveAs(content, "pWiki.zip")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$(function(){requirejs(['pwiki'], function(pwiki){
|
||||||
|
|
||||||
|
var wiki = Object.create(pwiki.pWikiData)
|
||||||
|
var page = window.page = new pwiki.pWikiPage({
|
||||||
|
wiki: wiki,
|
||||||
|
})
|
||||||
|
|
||||||
|
// XXX load data...
|
||||||
|
var data = wiki.__data = {}
|
||||||
|
|
||||||
|
// load bootstrap data...
|
||||||
|
if(window.Bootstrap){
|
||||||
|
Bootstrap.__proto__ = pwiki.BaseData
|
||||||
|
data.__proto__ = Bootstrap
|
||||||
|
}
|
||||||
|
|
||||||
|
var client = window.client = new pwiki.pWikiClient()
|
||||||
|
client.page = page
|
||||||
|
client.dom = $('.wiki')
|
||||||
|
|
||||||
|
// XXX get and load page location...
|
||||||
|
client.location('WikiHome')
|
||||||
|
|
||||||
|
|
||||||
|
// XXX move to client setup...
|
||||||
|
// XXX need to resolve relative hashes...
|
||||||
|
$(window).on('hashchange', function(evt){
|
||||||
|
evt.preventDefault()
|
||||||
|
|
||||||
|
var path = location.hash.slice(1)
|
||||||
|
var hash = path.split('#')
|
||||||
|
path = hash.shift()
|
||||||
|
hash = hash.pop() || ''
|
||||||
|
|
||||||
|
// expand the path...
|
||||||
|
if(page.get(path).path() != path){
|
||||||
|
location.hash = page.get(path).path()
|
||||||
|
|
||||||
|
// open page...
|
||||||
|
} else {
|
||||||
|
client.location(path)
|
||||||
|
|
||||||
|
if(hash.length > 0){
|
||||||
|
// XXX focus anchor...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="wiki" />
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
<!-- vim:set sw=4 ts=4 : -->
|
||||||
50
macro.js
50
macro.js
@ -8,6 +8,41 @@
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
var setWikiWords = function(text, show_brackets, skip){
|
||||||
|
skip = skip || []
|
||||||
|
skip = skip instanceof Array ? skip : [skip]
|
||||||
|
return text
|
||||||
|
// set new...
|
||||||
|
.replace(
|
||||||
|
macro.__wiki_link__,
|
||||||
|
function(l){
|
||||||
|
// check if wikiword is escaped...
|
||||||
|
if(l[0] == '\\'){
|
||||||
|
return l.slice(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
var path = l[0] == '[' ? l.slice(1, -1) : l
|
||||||
|
var i = [].slice.call(arguments).slice(-2)[0]
|
||||||
|
|
||||||
|
// XXX HACK check if we are inside a tag...
|
||||||
|
var rest = text.slice(i+1)
|
||||||
|
if(rest.indexOf('>') < rest.indexOf('<')){
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
|
||||||
|
return skip.indexOf(l) < 0 ?
|
||||||
|
('<a '
|
||||||
|
+'class="wikiword" '
|
||||||
|
+'href="#'+ path +'" '
|
||||||
|
+'bracketed="'+ (show_brackets && l[0] == '[' ? 'yes' : 'no') +'" '
|
||||||
|
//+'onclick="event.preventDefault(); go($(this).attr(\'href\').slice(1))" '
|
||||||
|
+'>'
|
||||||
|
+ (!!show_brackets ? path : l)
|
||||||
|
+'</a>')
|
||||||
|
: l
|
||||||
|
})}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
@ -58,6 +93,14 @@ module = {
|
|||||||
'editor',
|
'editor',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// XXX should this be here???
|
||||||
|
__wiki_link__: RegExp('('+[
|
||||||
|
'\\\\?(\\./|\\.\\./|[A-Z][a-z0-9]+[A-Z/])[a-zA-Z0-9/]*',
|
||||||
|
'\\\\?\\[[^\\]]+\\]',
|
||||||
|
].join('|') +')', 'g'),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Macros...
|
// Macros...
|
||||||
//
|
//
|
||||||
// XXX add support for sort and reverse attrs in all relavant macros
|
// XXX add support for sort and reverse attrs in all relavant macros
|
||||||
@ -379,6 +422,8 @@ module = {
|
|||||||
// 1) set it H1 if it is the first tag in .text
|
// 1) set it H1 if it is the first tag in .text
|
||||||
// 2) set it to .location
|
// 2) set it to .location
|
||||||
//
|
//
|
||||||
|
// NOTE: we do not set the title tag here because this will be
|
||||||
|
// done for every included page...
|
||||||
title: function(context, elem){
|
title: function(context, elem){
|
||||||
elem = $(elem)
|
elem = $(elem)
|
||||||
var title = elem.find('.text h1').first()
|
var title = elem.find('.text h1').first()
|
||||||
@ -387,11 +432,6 @@ module = {
|
|||||||
if(elem.find('.text').text().trim().indexOf(title.text().trim()) == 0){
|
if(elem.find('.text').text().trim().indexOf(title.text().trim()) == 0){
|
||||||
title.detach()
|
title.detach()
|
||||||
elem.find('.title').html(title.html())
|
elem.find('.title').html(title.html())
|
||||||
$('title').html(title.text())
|
|
||||||
|
|
||||||
// show location...
|
|
||||||
} else {
|
|
||||||
$('title').text(context.location)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return elem
|
return elem
|
||||||
|
|||||||
38
pwiki.js
38
pwiki.js
@ -121,9 +121,11 @@ module.BaseData = {
|
|||||||
'System/text': function(){ return { text: this.get('..').text() } },
|
'System/text': function(){ return { text: this.get('..').text() } },
|
||||||
|
|
||||||
// XXX update these to the new format -- must return an object...
|
// XXX update these to the new format -- must return an object...
|
||||||
/*
|
|
||||||
// XXX move this to Wiki.children + rename...
|
// XXX move this to Wiki.children + rename...
|
||||||
|
// XXX
|
||||||
'System/list': function(){
|
'System/list': function(){
|
||||||
|
return 'NoImplemented'
|
||||||
|
|
||||||
var p = this.dir
|
var p = this.dir
|
||||||
|
|
||||||
return Object.keys(this.__wiki_data)
|
return Object.keys(this.__wiki_data)
|
||||||
@ -139,7 +141,10 @@ module.BaseData = {
|
|||||||
.join('<br>')
|
.join('<br>')
|
||||||
},
|
},
|
||||||
// list links to this page...
|
// list links to this page...
|
||||||
|
// XXX
|
||||||
'System/links': function(){
|
'System/links': function(){
|
||||||
|
return 'NoImplemented'
|
||||||
|
|
||||||
var that = this
|
var that = this
|
||||||
var p = this.dir
|
var p = this.dir
|
||||||
|
|
||||||
@ -159,7 +164,6 @@ module.BaseData = {
|
|||||||
.sort()
|
.sort()
|
||||||
.join('<br>')
|
.join('<br>')
|
||||||
},
|
},
|
||||||
//*/
|
|
||||||
|
|
||||||
// Page modifiers/actions...
|
// Page modifiers/actions...
|
||||||
// XXX these needs redirecting...
|
// XXX these needs redirecting...
|
||||||
@ -1310,6 +1314,7 @@ var pWikiUIActions = actions.Actions({
|
|||||||
'.title': function(elems){
|
'.title': function(elems){
|
||||||
var client = this
|
var client = this
|
||||||
var wiki = this.page
|
var wiki = this.page
|
||||||
|
|
||||||
elems
|
elems
|
||||||
.focus(function(){
|
.focus(function(){
|
||||||
var to = $(this).attr('saveto') || '.'
|
var to = $(this).attr('saveto') || '.'
|
||||||
@ -1332,11 +1337,16 @@ var pWikiUIActions = actions.Actions({
|
|||||||
|
|
||||||
client.reload()
|
client.reload()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/* XXX this messes up history for some reason...
|
||||||
|
$('title').text(elems.first().text())
|
||||||
|
//*/
|
||||||
},
|
},
|
||||||
// raw text editor...
|
// raw text editor...
|
||||||
'.raw': function(elems){
|
'.raw': function(elems){
|
||||||
var client = this
|
var client = this
|
||||||
var wiki = this.page
|
var wiki = this.page
|
||||||
|
|
||||||
elems
|
elems
|
||||||
.focus(function(){
|
.focus(function(){
|
||||||
var to = $(this).attr('saveto') || '.'
|
var to = $(this).attr('saveto') || '.'
|
||||||
@ -1358,6 +1368,7 @@ var pWikiUIActions = actions.Actions({
|
|||||||
'input[type="checkbox"].state': function(elems){
|
'input[type="checkbox"].state': function(elems){
|
||||||
var client = this
|
var client = this
|
||||||
var wiki = this.page
|
var wiki = this.page
|
||||||
|
|
||||||
elems
|
elems
|
||||||
// initial state...
|
// initial state...
|
||||||
.each(function(){
|
.each(function(){
|
||||||
@ -1384,7 +1395,7 @@ var pWikiUIActions = actions.Actions({
|
|||||||
//client.save()
|
//client.save()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
|
||||||
location: ['',
|
location: ['',
|
||||||
function(path){
|
function(path){
|
||||||
@ -1404,6 +1415,8 @@ var pWikiUIActions = actions.Actions({
|
|||||||
|
|
||||||
page.location(path)
|
page.location(path)
|
||||||
|
|
||||||
|
this.dom.attr('wiki-active', 'no')
|
||||||
|
|
||||||
this.reload()
|
this.reload()
|
||||||
}],
|
}],
|
||||||
reload: ['',
|
reload: ['',
|
||||||
@ -1412,9 +1425,10 @@ var pWikiUIActions = actions.Actions({
|
|||||||
var page = this.page
|
var page = this.page
|
||||||
|
|
||||||
this.dom
|
this.dom
|
||||||
|
.empty()
|
||||||
// update path and render page...
|
// update path and render page...
|
||||||
// XXX revise the default view approach...
|
// XXX revise the default view approach...
|
||||||
.html(page.title()[0] == '_' ?
|
.append(page.title()[0] == '_' ?
|
||||||
page.text()
|
page.text()
|
||||||
: page.get('./_view').text())
|
: page.get('./_view').text())
|
||||||
// activate page controls...
|
// activate page controls...
|
||||||
@ -1438,9 +1452,10 @@ var pWikiUIActions = actions.Actions({
|
|||||||
|| pWikiUIActions.__dom_filters__
|
|| pWikiUIActions.__dom_filters__
|
||||||
|
|
||||||
// apply dom filters...
|
// apply dom filters...
|
||||||
Object.keys(filters).forEach(function(pattern){
|
Object.keys(filters)
|
||||||
filters[pattern].call(that, dom.find(pattern))
|
.forEach(function(pattern){
|
||||||
})
|
// XXX for some reason this works but has no effect...
|
||||||
|
filters[pattern].call(that, dom.find(pattern)) })
|
||||||
}],
|
}],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1472,6 +1487,15 @@ var pWikiUI = pWikiFeatures.Feature({
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// XXX STUB: not sure if this is the right way...
|
||||||
|
var pWikiClient =
|
||||||
|
module.pWikiClient = object.makeConstructor('pWikiClient',
|
||||||
|
actions.mix(
|
||||||
|
// XXX not sure if we need this here...
|
||||||
|
//actions.MetaActions,
|
||||||
|
pWikiUIActions))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user