mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-16 16:11:39 +00:00
moved most of the templats out of wiki.js into bootstrap/* ...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
8965ff2124
commit
e226acf115
3
bootstrap.js
vendored
Executable file
3
bootstrap.js
vendored
Executable file
File diff suppressed because one or more lines are too long
34
bootstrap/System/settings.tpl
Normal file
34
bootstrap/System/settings.tpl
Normal file
@ -0,0 +1,34 @@
|
||||
/**********************************************************************
|
||||
* !EXPERIMENTAL!
|
||||
*
|
||||
* These filters are required for .code to be JSON compatible:
|
||||
* @filter(json) @filter(-wikiword)
|
||||
*
|
||||
* NOTE: currently inline editing may mess this up.
|
||||
* NOTE: all the comments will be removed before parsing.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
// The actual root data to be parsed...
|
||||
{
|
||||
// Wiki config...
|
||||
"HomePage": "WikiHome",
|
||||
"ShowSystemPages": false,
|
||||
"ShowBasePages": true,
|
||||
// NOTE: setting this to true will effectively allow pages to control
|
||||
// your wiki. This is a potential threat if you allow untrusted
|
||||
// content on your wiki...
|
||||
// You are doing this at your own risk!
|
||||
"AllowScripts": false,
|
||||
|
||||
// PeerJS API key...
|
||||
"PeerJS-API-key": "XXX",
|
||||
// PeerJS server URL (leave blank for default)...
|
||||
"PeerJS-Server": null,
|
||||
|
||||
// XXX
|
||||
"CouchDB-Server": null
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
43
bootstrap/System/style.tpl
Normal file
43
bootstrap/System/style.tpl
Normal file
@ -0,0 +1,43 @@
|
||||
.raw,
|
||||
.text {
|
||||
display: block;
|
||||
}
|
||||
|
||||
input[type="checkbox"][checked]~*,
|
||||
.checked {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.button {
|
||||
text-decoration: none;
|
||||
}
|
||||
.button:last-child {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.separator~* {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.item:hover {
|
||||
background-color: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
.item .button {
|
||||
display: none;
|
||||
}
|
||||
.item:hover .button {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.sort-handle {
|
||||
opacity: 0.1;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.item:hover .sort-handle {
|
||||
opacity: 0.3;
|
||||
}
|
||||
.sort-placeholder {
|
||||
display: block;
|
||||
}
|
||||
6
bootstrap/Templates.tpl
Normal file
6
bootstrap/Templates.tpl
Normal file
@ -0,0 +1,6 @@
|
||||
@filter(nl2br) @filter(-wikiword)
|
||||
|
||||
XXX Genereal template description...
|
||||
|
||||
<macro src="./*"><hr><h2><a href="#@source(./path)/_edit">@source(./path)</a></h2><div>@quote(./raw)</div></macro>
|
||||
|
||||
1
bootstrap/Templates/EmptyOutline.tpl
Normal file
1
bootstrap/Templates/EmptyOutline.tpl
Normal file
@ -0,0 +1 @@
|
||||
@include(./outline)
|
||||
8
bootstrap/Templates/EmptyPage.tpl
Normal file
8
bootstrap/Templates/EmptyPage.tpl
Normal file
@ -0,0 +1,8 @@
|
||||
<!-- place filters here so as not to takup page space: ... -->
|
||||
|
||||
Page @include(./path) is empty.<br><br>
|
||||
|
||||
Links to this page:<br>
|
||||
@include(./links)<br><br>
|
||||
|
||||
<!-- vim:set ts=4 sw=4 : -->
|
||||
1
bootstrap/Templates/EmptyToDo.tpl
Normal file
1
bootstrap/Templates/EmptyToDo.tpl
Normal file
@ -0,0 +1 @@
|
||||
@include(./todo)
|
||||
3
bootstrap/Templates/_css.tpl
Normal file
3
bootstrap/Templates/_css.tpl
Normal file
@ -0,0 +1,3 @@
|
||||
<style>
|
||||
@source(..)
|
||||
</style>
|
||||
13
bootstrap/Templates/_edit.tpl
Normal file
13
bootstrap/Templates/_edit.tpl
Normal file
@ -0,0 +1,13 @@
|
||||
<!-- @filter(-wikiword) -->
|
||||
|
||||
<include src="../_view"/>
|
||||
|
||||
<slot name="toggle-edit-link">(<a href="#..">view</a>)</slot>
|
||||
|
||||
<slot name="title" class="title" contenteditable saveto="..">@source(../title)</slot>
|
||||
|
||||
<slot name="page-content">
|
||||
<code><pre><quote src="../raw" class="raw" saveto=".." contenteditable/></pre></code>
|
||||
</slot>
|
||||
|
||||
<!-- vim:set ts=4 sw=4 : -->
|
||||
9
bootstrap/Templates/_outline.tpl
Normal file
9
bootstrap/Templates/_outline.tpl
Normal file
@ -0,0 +1,9 @@
|
||||
<include src="../_view"/>
|
||||
|
||||
<slot name="title" class="title" contenteditable saveto="..">@source(../title)</slot>
|
||||
|
||||
<slot name="page-content">
|
||||
@include(../outline)
|
||||
</slot>
|
||||
|
||||
<!-- vim:set ts=4 sw=4 : -->
|
||||
1
bootstrap/Templates/_raw.tpl
Normal file
1
bootstrap/Templates/_raw.tpl
Normal file
@ -0,0 +1 @@
|
||||
@source(..)
|
||||
9
bootstrap/Templates/_todo.tpl
Normal file
9
bootstrap/Templates/_todo.tpl
Normal file
@ -0,0 +1,9 @@
|
||||
<include src="../_view"/>
|
||||
|
||||
<slot name="title" class="title" contenteditable saveto="..">@source(../title)</slot>
|
||||
|
||||
<slot name="page-content">
|
||||
@include(../todo)
|
||||
</slot>
|
||||
|
||||
<!-- vim:set ts=4 sw=4 : -->
|
||||
29
bootstrap/Templates/_view.tpl
Normal file
29
bootstrap/Templates/_view.tpl
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
@include(style/_css)
|
||||
|
||||
<div>
|
||||
<a href="#pages" class="pages-list-button button">☰</a>
|
||||
|
||||
[@source(../path)]
|
||||
|
||||
<slot name="toggle-edit-link"> (<a href="#./_edit">edit</a>) </slot>
|
||||
|
||||
<span class="separator"/>
|
||||
|
||||
<a href="#NewPage/_edit" class="new-page-button button">+</a>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<h1 saveto="..">
|
||||
<slot name="title">@source(../title)</slot>
|
||||
</h1>
|
||||
<br>
|
||||
|
||||
<slot name="page-content">
|
||||
<include src=".." class="text" saveto=".." tabindex="0"/>
|
||||
</slot>
|
||||
|
||||
<hr>
|
||||
<a href="#/">home</a>
|
||||
|
||||
<!-- vim:set ts=4 sw=4 : -->
|
||||
9
bootstrap/Templates/all_pages.tpl
Normal file
9
bootstrap/Templates/all_pages.tpl
Normal file
@ -0,0 +1,9 @@
|
||||
<macro src="../**">
|
||||
<div class="item">
|
||||
[@source(./path)]
|
||||
<span class="separator"/>
|
||||
<a class="button" href="#@source(./path)/delete">×</a>
|
||||
</div>
|
||||
</macro>
|
||||
|
||||
<!-- vim:set ts=4 sw=4 : -->
|
||||
47
bootstrap/Templates/outline.tpl
Normal file
47
bootstrap/Templates/outline.tpl
Normal file
@ -0,0 +1,47 @@
|
||||
<macro name="item-pre-controls"/>
|
||||
|
||||
<macro name="item-content">
|
||||
<include
|
||||
class="raw"
|
||||
contenteditable
|
||||
tabindex="0"
|
||||
style="display:inline-block"
|
||||
saveto="@source(./path)"
|
||||
src="." />
|
||||
</macro>
|
||||
|
||||
<macro name="item-post-controls">
|
||||
<a class="button" href="#@source(./path)/delete">×</a>
|
||||
</macro>
|
||||
|
||||
|
||||
<div>
|
||||
<span
|
||||
class="raw"
|
||||
contenteditable
|
||||
tabindex="0"
|
||||
saveto="@source(../path)/@now()"
|
||||
style="display:inline-block" >
|
||||
+
|
||||
</span>
|
||||
</div>
|
||||
<div class="sortable">
|
||||
<macro src="../*">
|
||||
<div class="item">
|
||||
<div>
|
||||
<span class="sort-handle">☰</span>
|
||||
<macro name="item-pre-controls" src="."/>
|
||||
<macro name="item-content" src="."/>
|
||||
<span class="separator"/>
|
||||
<macro name="item-post-controls" src="."/>
|
||||
</div>
|
||||
<div style="padding-left: 30px">
|
||||
<include
|
||||
style="display:block"
|
||||
src="@source(./path)/outline" />
|
||||
</div>
|
||||
</div>
|
||||
</macro>
|
||||
</div>
|
||||
|
||||
<!-- vim:set ts=4 sw=4 : -->
|
||||
9
bootstrap/Templates/pages.tpl
Normal file
9
bootstrap/Templates/pages.tpl
Normal file
@ -0,0 +1,9 @@
|
||||
<macro src="../*">
|
||||
<div class="item">
|
||||
[@source(./path)]
|
||||
<span class="separator"/>
|
||||
<a class="button" href="#@source(./path)/delete">×</a>
|
||||
</div>
|
||||
</macro>
|
||||
|
||||
<!-- vim:set ts=4 sw=4 : -->
|
||||
7
bootstrap/Templates/todo.tpl
Normal file
7
bootstrap/Templates/todo.tpl
Normal file
@ -0,0 +1,7 @@
|
||||
<macro name="item-pre-controls">
|
||||
<input type="checkbox"/>
|
||||
</macro>
|
||||
|
||||
<include src="../outline">
|
||||
|
||||
<!-- vim:set ts=4 sw=4 : -->
|
||||
15
bootstrap/Templates/tree.tpl
Normal file
15
bootstrap/Templates/tree.tpl
Normal file
@ -0,0 +1,15 @@
|
||||
<div class="sortable">
|
||||
<macro src="../*">
|
||||
<div class="item">
|
||||
<span class="sort-handle">☰</span>
|
||||
<a href="#@source(./path)">@source(./title)</a>
|
||||
<span class="separator"/>
|
||||
<a class="button" href="#@source(./path)/delete">×</a>
|
||||
</div>
|
||||
<div style="padding-left: 30px">
|
||||
<include style="display:block" src="@source(./path)/tree" />
|
||||
</div>
|
||||
</macro>
|
||||
</div>
|
||||
|
||||
<!-- vim:set ts=4 sw=4 : -->
|
||||
@ -17,6 +17,7 @@
|
||||
<script src="ext-lib/pouchdb.min.js"></script>
|
||||
<script src="ext-lib/peer.min.js"></script>
|
||||
|
||||
<script src="bootstrap.js"></script>
|
||||
<script src="wiki.js"></script>
|
||||
|
||||
<script>
|
||||
@ -210,6 +211,11 @@ $(() => {
|
||||
&& go(event.state.wikipath)
|
||||
})
|
||||
|
||||
if(window.Bootstrap){
|
||||
Bootstrap.__proto__ = BaseData
|
||||
data = Wiki.__wiki_data = Bootstrap
|
||||
}
|
||||
|
||||
// load stored data...
|
||||
Wiki.__wiki_data = localStorage['wiki-data'] ?
|
||||
JSON.parse(localStorage['wiki-data'])
|
||||
|
||||
41
make_bootstrap.js
Normal file
41
make_bootstrap.js
Normal file
@ -0,0 +1,41 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
var fs = require('fs')
|
||||
var glob = require('glob')
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
var bootstrap = {}
|
||||
|
||||
glob('bootstrap/**/*.tpl')
|
||||
.on('match', function(path){
|
||||
var p = path
|
||||
.replace('bootstrap/', '')
|
||||
.replace('.tpl', '')
|
||||
|
||||
if(p)
|
||||
|
||||
console.log('Found:', p)
|
||||
bootstrap[p] = {
|
||||
text: fs.readFileSync(path).toString(),
|
||||
}
|
||||
})
|
||||
.on('end', function(){
|
||||
var txt = '// This file is generated automatically, '
|
||||
+'all changes made here will be lost.'
|
||||
+'\n\n'
|
||||
+'var Bootstrap = ' + JSON.stringify(bootstrap)
|
||||
|
||||
console.log('Writing:', 'bootstrap.js')
|
||||
fs.writeFileSync('bootstrap.js', txt)
|
||||
})
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* vim:set ts=4 sw=4 : */
|
||||
@ -4,11 +4,15 @@
|
||||
"author": "Alex A. Naanou <alex.nanou@gmail.com>",
|
||||
"license": "BSD",
|
||||
"dependencies": {
|
||||
"glob": "^7.0.5",
|
||||
"jszip": "^2.6.1",
|
||||
"peer": "*",
|
||||
"pouch-replicate-webrtc": "0.0.9",
|
||||
"pouchdb": "^5.4.5",
|
||||
"showdown": "^1.4.2"
|
||||
},
|
||||
"devDependencies": {}
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
"bootstrap": "node make_bootstrap.js"
|
||||
}
|
||||
}
|
||||
|
||||
179
wiki.js
179
wiki.js
@ -703,93 +703,8 @@ var BaseData = {
|
||||
// }
|
||||
//
|
||||
// XXX add .json support...
|
||||
/*
|
||||
var data = {
|
||||
// System pages...
|
||||
'System/style': {
|
||||
text: ''
|
||||
+'.raw,\n'
|
||||
+'.text {\n'
|
||||
+' display: block;\n'
|
||||
+'}\n'
|
||||
+'\n'
|
||||
+'input[type="checkbox"][checked]~*,\n'
|
||||
+'.checked {\n'
|
||||
+' text-decoration: line-through;\n'
|
||||
+'}\n'
|
||||
+'\n'
|
||||
+'.button {\n'
|
||||
+' text-decoration: none;\n'
|
||||
+'}\n'
|
||||
+'.button:last-child {\n'
|
||||
+' margin-right: 5px;\n'
|
||||
+'}\n'
|
||||
+'\n'
|
||||
+'.separator~* {\n'
|
||||
+' float: right;\n'
|
||||
+'}\n'
|
||||
+'\n'
|
||||
+'.item:hover {\n'
|
||||
+' background-color: rgba(0, 0, 0, 0.05);\n'
|
||||
+'}\n'
|
||||
+'.item .button {\n'
|
||||
+' display: none;\n'
|
||||
+'}\n'
|
||||
+'.item:hover .button {\n'
|
||||
+' display: inline-block;\n'
|
||||
+'}\n'
|
||||
+'\n'
|
||||
+'.sort-handle {\n'
|
||||
+' opacity: 0.1;\n'
|
||||
+' padding-left: 5px;\n'
|
||||
+' padding-right: 5px;\n'
|
||||
+' cursor: pointer;\n'
|
||||
+'}\n'
|
||||
+'.item:hover .sort-handle {\n'
|
||||
+' opacity: 0.3;\n'
|
||||
+'}\n'
|
||||
+'.sort-placeholder {\n'
|
||||
+' display: block;\n'
|
||||
+'}\n'
|
||||
+'',
|
||||
},
|
||||
'System/settings': {
|
||||
text: JSON.stringify({}),
|
||||
},
|
||||
|
||||
// Templates...
|
||||
'Templates': {
|
||||
text: '@filter(nl2br) @filter(-wikiword)'
|
||||
+'XXX Genereal template description...\n'
|
||||
+'\n'
|
||||
+'<macro src="./*">'
|
||||
+'<hr>'
|
||||
+'<h2><a href="#@source(./path)/_edit">@source(./path)</a></h2>'
|
||||
+'<div>@quote(./raw)</div>'
|
||||
+'</macro>\n'
|
||||
+'\n',
|
||||
},
|
||||
'Templates/EmptyPage': {
|
||||
text: ''
|
||||
+'<!-- place filters here so as not to takup page space: ... -->\n'
|
||||
+'\n'
|
||||
+'Page @include(./path) is empty.' +'<br><br>\n'
|
||||
+'\n'
|
||||
+'Links to this page:' +'<br>\n'
|
||||
+'@include(./links)' +'<br><br>\n'
|
||||
+'\n',
|
||||
},
|
||||
// XXX this is not used yet...
|
||||
'Templates/EmptyToDo': {
|
||||
text: ''
|
||||
+'@include(./todo)'
|
||||
+'',
|
||||
},
|
||||
'Templates/EmptyOutline': {
|
||||
text: ''
|
||||
+'@include(./outline)'
|
||||
+'',
|
||||
},
|
||||
|
||||
// XXX might be a good idea to use this for outline...
|
||||
'Templates/tree': {
|
||||
//text: '<macro src="../**"> [@source(./path)]<br> </macro>\n'
|
||||
@ -811,17 +726,6 @@ var data = {
|
||||
+'</macro>\n'
|
||||
+'</div>\n'
|
||||
},
|
||||
'Templates/pages': {
|
||||
//text: '<macro src="../*"> [@source(./path)]<br> </macro>\n'
|
||||
text: ''
|
||||
+'<macro src="../*">\n'
|
||||
+'<div class="item">\n'
|
||||
+'[@source(./path)]\n'
|
||||
+'<span class="separator"/>\n'
|
||||
+'<a class="button" href="#@source(./path)/delete">×</a>\n'
|
||||
+'</div>\n'
|
||||
+'</macro>\n'
|
||||
},
|
||||
// XXX this is essentially identical to pages, except for the path...
|
||||
'Templates/all_pages': {
|
||||
//text: '<macro src="../**"> [@source(./path)]<br> </macro>\n'
|
||||
@ -855,7 +759,6 @@ var data = {
|
||||
+'</macro>\n'
|
||||
+'\n'
|
||||
+'\n'
|
||||
//*
|
||||
+'<div>\n'
|
||||
// XXX select all on focus...
|
||||
+'<span class="raw" contenteditable tabindex="0" '
|
||||
@ -864,7 +767,6 @@ var data = {
|
||||
+'</span>\n'
|
||||
+'</div>\n'
|
||||
//+'<br>\n'
|
||||
//*/
|
||||
+'<div class="sortable">\n'
|
||||
+'<macro src="../*">\n'
|
||||
+'<div class="item">\n'
|
||||
@ -882,11 +784,10 @@ var data = {
|
||||
+'/>\n'
|
||||
+'</div>\n'
|
||||
+'</div>\n'
|
||||
/*// XXX do we need this or should we just use CSS???
|
||||
+'<else>\n'
|
||||
+'<i>No items yet...</i>\n'
|
||||
+'</else>\n'
|
||||
//*/
|
||||
// XXX do we need this or should we just use CSS???
|
||||
//+'<else>\n'
|
||||
// +'<i>No items yet...</i>\n'
|
||||
//+'</else>\n'
|
||||
+'</macro>\n'
|
||||
+'</div>\n'
|
||||
+'\n',
|
||||
@ -904,72 +805,6 @@ var data = {
|
||||
},
|
||||
|
||||
// Views...
|
||||
'Templates/_raw': {
|
||||
text: '@source(..)',
|
||||
},
|
||||
'Templates/_css': {
|
||||
text: '<style>\n'
|
||||
+'@source(..)\n'
|
||||
+'</style>',
|
||||
},
|
||||
'Templates/_view': {
|
||||
text: '\n'
|
||||
+'@include(style/_css)\n'
|
||||
+'\n'
|
||||
+'<div>\n'
|
||||
+'<a href="#pages" class="pages-list-button button">☰</a> \n'
|
||||
+'[@source(../path)]\n'
|
||||
+'\n'
|
||||
+'<slot name="toggle-edit-link">\n'
|
||||
+'(<a href="#./_edit">edit</a>)\n'
|
||||
+'</slot>\n'
|
||||
+'\n'
|
||||
+'<span class="separator"/>\n'
|
||||
+'\n'
|
||||
+'<a href="#NewPage/_edit" class="new-page-button button">+</a>\n'
|
||||
+'</div>\n'
|
||||
+'\n'
|
||||
+'<hr>\n'
|
||||
//+'<h1 class="title" contenteditable tabindex="0" saveto="..">'
|
||||
+'<h1 saveto="..">'
|
||||
+'<slot name="title">'
|
||||
+'@source(../title)'
|
||||
+'</slot>'
|
||||
+'\n'
|
||||
+'</h1>\n'
|
||||
+'<br>\n'
|
||||
+'\n'
|
||||
+'<slot name="page-content">\n'
|
||||
+'<include src=".." class="text" saveto=".." tabindex="0"/>\n'
|
||||
+'</slot>\n'
|
||||
+'\n'
|
||||
+'<hr>\n'
|
||||
+'<a href="#/">home</a>\n'
|
||||
+'\n',
|
||||
},
|
||||
'Templates/_edit': {
|
||||
text: '\n'
|
||||
+'<!-- @filter(-wikiword) -->\n'
|
||||
+'\n'
|
||||
+'<include src="../_view"/>\n'
|
||||
+'\n'
|
||||
+'<slot name="toggle-edit-link">'
|
||||
+'(<a href="#..">view</a>)'
|
||||
+'</slot>\n'
|
||||
+'\n'
|
||||
// XXX temporary until I figure out how to deal with the saveto=".."
|
||||
// in implicit vs. explicit _view
|
||||
+'<slot name="title" class="title" contenteditable saveto="..">'
|
||||
+'@source(../title)'
|
||||
+'</slot>\n'
|
||||
+'\n'
|
||||
+'<slot name="page-content">\n'
|
||||
+'<code><pre>'
|
||||
+'<quote src="../raw" class="raw" saveto=".." contenteditable/>'
|
||||
+'</pre></code>\n'
|
||||
+'</slot>'
|
||||
+'',
|
||||
},
|
||||
// XXX experimental...
|
||||
'Templates/_outline': {
|
||||
text: ''
|
||||
@ -1001,8 +836,10 @@ var data = {
|
||||
+'</slot>'
|
||||
+'\n'
|
||||
},
|
||||
|
||||
}
|
||||
//*/
|
||||
|
||||
data = {}
|
||||
data.__proto__ = BaseData
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user