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:
Alex A. Naanou 2016-08-13 03:06:35 +03:00
parent 8965ff2124
commit e226acf115
22 changed files with 307 additions and 172 deletions

3
bootstrap.js vendored Executable file

File diff suppressed because one or more lines are too long

View 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
}
/*********************************************************************/

View 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
View 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>

View File

@ -0,0 +1 @@
@include(./outline)

View 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 : -->

View File

@ -0,0 +1 @@
@include(./todo)

View File

@ -0,0 +1,3 @@
<style>
@source(..)
</style>

View 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 : -->

View 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 : -->

View File

@ -0,0 +1 @@
@source(..)

View 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 : -->

View File

@ -0,0 +1,29 @@
@include(style/_css)
<div>
<a href="#pages" class="pages-list-button button">&#x2630;</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 : -->

View File

@ -0,0 +1,9 @@
<macro src="../**">
<div class="item">
[@source(./path)]
<span class="separator"/>
<a class="button" href="#@source(./path)/delete">&times;</a>
</div>
</macro>
<!-- vim:set ts=4 sw=4 : -->

View 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">&times;</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">&#x2630;</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 : -->

View File

@ -0,0 +1,9 @@
<macro src="../*">
<div class="item">
[@source(./path)]
<span class="separator"/>
<a class="button" href="#@source(./path)/delete">&times;</a>
</div>
</macro>
<!-- vim:set ts=4 sw=4 : -->

View File

@ -0,0 +1,7 @@
<macro name="item-pre-controls">
<input type="checkbox"/>
</macro>
<include src="../outline">
<!-- vim:set ts=4 sw=4 : -->

View File

@ -0,0 +1,15 @@
<div class="sortable">
<macro src="../*">
<div class="item">
<span class="sort-handle">&#x2630;</span>
<a href="#@source(./path)">@source(./title)</a>
<span class="separator"/>
<a class="button" href="#@source(./path)/delete">&times;</a>
</div>
<div style="padding-left: 30px">
<include style="display:block" src="@source(./path)/tree" />
</div>
</macro>
</div>
<!-- vim:set ts=4 sw=4 : -->

View File

@ -17,6 +17,7 @@
<script src="ext-lib/pouchdb.min.js"></script> <script src="ext-lib/pouchdb.min.js"></script>
<script src="ext-lib/peer.min.js"></script> <script src="ext-lib/peer.min.js"></script>
<script src="bootstrap.js"></script>
<script src="wiki.js"></script> <script src="wiki.js"></script>
<script> <script>
@ -210,6 +211,11 @@ $(() => {
&& go(event.state.wikipath) && go(event.state.wikipath)
}) })
if(window.Bootstrap){
Bootstrap.__proto__ = BaseData
data = Wiki.__wiki_data = Bootstrap
}
// load stored data... // load stored data...
Wiki.__wiki_data = localStorage['wiki-data'] ? Wiki.__wiki_data = localStorage['wiki-data'] ?
JSON.parse(localStorage['wiki-data']) JSON.parse(localStorage['wiki-data'])

41
make_bootstrap.js Normal file
View 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 : */

View File

@ -4,11 +4,15 @@
"author": "Alex A. Naanou <alex.nanou@gmail.com>", "author": "Alex A. Naanou <alex.nanou@gmail.com>",
"license": "BSD", "license": "BSD",
"dependencies": { "dependencies": {
"glob": "^7.0.5",
"jszip": "^2.6.1", "jszip": "^2.6.1",
"peer": "*", "peer": "*",
"pouch-replicate-webrtc": "0.0.9", "pouch-replicate-webrtc": "0.0.9",
"pouchdb": "^5.4.5", "pouchdb": "^5.4.5",
"showdown": "^1.4.2" "showdown": "^1.4.2"
}, },
"devDependencies": {} "devDependencies": {},
"scripts": {
"bootstrap": "node make_bootstrap.js"
}
} }

179
wiki.js
View File

@ -703,93 +703,8 @@ var BaseData = {
// } // }
// //
// XXX add .json support... // XXX add .json support...
/*
var data = { 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... // XXX might be a good idea to use this for outline...
'Templates/tree': { 'Templates/tree': {
//text: '<macro src="../**"> [@source(./path)]<br> </macro>\n' //text: '<macro src="../**"> [@source(./path)]<br> </macro>\n'
@ -811,17 +726,6 @@ var data = {
+'</macro>\n' +'</macro>\n'
+'</div>\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">&times;</a>\n'
+'</div>\n'
+'</macro>\n'
},
// XXX this is essentially identical to pages, except for the path... // XXX this is essentially identical to pages, except for the path...
'Templates/all_pages': { 'Templates/all_pages': {
//text: '<macro src="../**"> [@source(./path)]<br> </macro>\n' //text: '<macro src="../**"> [@source(./path)]<br> </macro>\n'
@ -855,7 +759,6 @@ var data = {
+'</macro>\n' +'</macro>\n'
+'\n' +'\n'
+'\n' +'\n'
//*
+'<div>\n' +'<div>\n'
// XXX select all on focus... // XXX select all on focus...
+'<span class="raw" contenteditable tabindex="0" ' +'<span class="raw" contenteditable tabindex="0" '
@ -864,7 +767,6 @@ var data = {
+'</span>\n' +'</span>\n'
+'</div>\n' +'</div>\n'
//+'<br>\n' //+'<br>\n'
//*/
+'<div class="sortable">\n' +'<div class="sortable">\n'
+'<macro src="../*">\n' +'<macro src="../*">\n'
+'<div class="item">\n' +'<div class="item">\n'
@ -882,11 +784,10 @@ var data = {
+'/>\n' +'/>\n'
+'</div>\n' +'</div>\n'
+'</div>\n' +'</div>\n'
/*// XXX do we need this or should we just use CSS??? // XXX do we need this or should we just use CSS???
+'<else>\n' //+'<else>\n'
+'<i>No items yet...</i>\n' // +'<i>No items yet...</i>\n'
+'</else>\n' //+'</else>\n'
//*/
+'</macro>\n' +'</macro>\n'
+'</div>\n' +'</div>\n'
+'\n', +'\n',
@ -904,72 +805,6 @@ var data = {
}, },
// Views... // 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">&#x2630;</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... // XXX experimental...
'Templates/_outline': { 'Templates/_outline': {
text: '' text: ''
@ -1001,8 +836,10 @@ var data = {
+'</slot>' +'</slot>'
+'\n' +'\n'
}, },
} }
//*/
data = {}
data.__proto__ = BaseData data.__proto__ = BaseData