mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Save the tiddler index
This commit is contained in:
parent
66cdd8a639
commit
5a4a121ee4
10
dbld.sh
10
dbld.sh
@ -6,10 +6,10 @@ pushd tw5dropbox/appwiki > /dev/null
|
||||
|
||||
node ../../core/boot.js \
|
||||
--verbose \
|
||||
--savetiddler $:/core/templates/tw5dropbox.template.js ../../../../../Apps/Static\ Web\ Apps/TiddlyWiki5/public/tw5dropbox.js text/plain [!is[shadow]] \
|
||||
--savetiddler $:/core/templates/index.template.html ../../../../../Apps/TiddlyWiki5/My\ TiddlyWiki/index.html text/plain [!is[shadow]] \
|
||||
--savetiddler $:/core/templates/index.template.html ../../../../../Apps/Static\ Web\ Apps/TiddlyWiki5/public/apptemplate.html text/plain [!is[shadow]] \
|
||||
--savetiddler $:/core/templates/styles.template.css ../../../../../Apps/Static\ Web\ Apps/TiddlyWiki5/public/styles.css text/plain [!is[shadow]] \
|
||||
--savetiddler $:/plugins/dropbox/tw5dropbox.template.js ../../../../../Apps/Static\ Web\ Apps/TiddlyWiki5/public/tw5dropbox.js text/plain [!is[shadow]] \
|
||||
--savetiddler $:/plugins/dropbox/index.template.html ../../../../../Apps/TiddlyWiki5/My\ TiddlyWiki/index.html text/plain [!is[shadow]] \
|
||||
--savetiddler $:/plugins/dropbox/index.template.html ../../../../../Apps/Static\ Web\ Apps/TiddlyWiki5/public/apptemplate.html text/plain [!is[shadow]] \
|
||||
--savetiddler $:/plugins/dropbox/styles.template.css ../../../../../Apps/Static\ Web\ Apps/TiddlyWiki5/public/styles.css text/plain [!is[shadow]] \
|
||||
|| exit 1
|
||||
|
||||
popd > /dev/null
|
||||
@ -18,7 +18,7 @@ pushd tw5dropbox/mainwiki > /dev/null
|
||||
|
||||
node ../../core/boot.js \
|
||||
--verbose \
|
||||
--savetiddler $:/core/templates/index.template.html ../../../../../Apps/Static\ Web\ Apps/TiddlyWiki5/public/index.html text/plain [!is[shadow]] \
|
||||
--savetiddler $:/plugins/dropbox/index.template.html ../../../../../Apps/Static\ Web\ Apps/TiddlyWiki5/public/index.html text/plain [!is[shadow]] \
|
||||
|| exit 1
|
||||
|
||||
popd > /dev/null
|
||||
|
@ -28,8 +28,11 @@ exports.startup = function() {
|
||||
$tw.plugins.dropbox.wikiName = wikiName;
|
||||
$tw.wiki.addTiddler({title: titleWikiName, text: $tw.plugins.dropbox.wikiName},true);
|
||||
// Load tiddlers
|
||||
$tw.plugins.dropbox.loadTiddlerFiles("/" + $tw.plugins.dropbox.wikiName + "/tiddlers",function() {
|
||||
console.log("Loaded all tiddlers",$tw.wiki.tiddlers);
|
||||
$tw.plugins.dropbox.loadTiddlerFiles("/" + $tw.plugins.dropbox.wikiName + "/tiddlers",function(fileRevisions) {
|
||||
// Save the tiddler index
|
||||
$tw.plugins.dropbox.saveTiddlerIndex("/" + $tw.plugins.dropbox.wikiName + "/index.html",fileRevisions,function(error) {
|
||||
console.log("Saved tiddler index");
|
||||
});
|
||||
});
|
||||
} else {
|
||||
alert("This TiddlyWiki file must be in Dropbox");
|
||||
|
@ -1,4 +1,4 @@
|
||||
title: $:/core/templates/index.template.html
|
||||
title: $:/plugins/dropbox/index.template.html
|
||||
type: text/x-tiddlywiki-html
|
||||
|
||||
<!doctype html>
|
||||
@ -16,9 +16,12 @@ type: text/x-tiddlywiki-html
|
||||
" />
|
||||
<title><<tiddler "$:/core/wiki/title">></title>
|
||||
<<serialize "[tag[$:/core/wiki/rawmarkup]]" text/plain>>
|
||||
<link rel="stylesheet" href="//dl-web.dropbox.com/spa/4f6lw6nhu5zn5pr/TiddlyWiki5/public/styles.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<link rel="stylesheet" href="//dl-web.dropbox.com/spa/4f6lw6nhu5zn5pr/TiddlyWiki5/public/styles.css" type="text/css" />
|
||||
<div id="shadowArea" style="display:none;">
|
||||
<<serialize "[[$:/plugins/dropbox/Index]]" application/x-tiddler-html-div>>
|
||||
</div>
|
||||
</body>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/dropbox.js/0.6.1/dropbox.min.js"></script>
|
||||
<script src="//dl-web.dropbox.com/spa/4f6lw6nhu5zn5pr/TiddlyWiki5/public/tw5dropbox.js"></script>
|
||||
|
@ -1,4 +1,4 @@
|
||||
title: $:/core/templates/styles.template.css
|
||||
title: $:/plugins/dropbox/styles.template.css
|
||||
type: text/x-tiddlywiki-html
|
||||
|
||||
<<serialize "[is[shadow]type[text/css]]" text/plain>>
|
||||
|
@ -1,4 +1,4 @@
|
||||
title: $:/core/templates/tw5dropbox.template.js
|
||||
title: $:/plugins/dropbox/tw5dropbox.template.js
|
||||
type: text/x-tiddlywiki-html
|
||||
|
||||
<<serialize "[is[shadow]type[application/javascript]library[yes]] -[[$:/library/sjcl.js]]" text/plain>>
|
||||
|
@ -1,4 +1,4 @@
|
||||
title: $:/core/templates/index.template.html
|
||||
title: $:/plugins/dropbox/index.template.html
|
||||
type: text/x-tiddlywiki-html
|
||||
|
||||
<!doctype html>
|
||||
|
@ -19,7 +19,9 @@ var apiKey = "m+qwjj8wFRA=|1TSoitGS9Nz2RTwv+jrUJnsAj0yy57NhQJ4TkZ/+Hw==";
|
||||
var titleIsLoggedIn = "$:/plugins/dropbox/IsLoggedIn",
|
||||
titleUserName = "$:/plugins/dropbox/UserName",
|
||||
titlePublicAppUrl = "$:/plugins/dropbox/PublicAppUrl",
|
||||
titleAppTemplateHtml = "$:/plugins/dropbox/apptemplate.html";
|
||||
titleAppTemplateHtml = "$:/plugins/dropbox/apptemplate.html",
|
||||
titleTiddlerIndex = "$:/plugins/dropbox/Index",
|
||||
titleAppIndexTemplate = "$:/plugins/dropbox/index.template.html";
|
||||
|
||||
// Query string marker for forcing authentication
|
||||
var queryLoginMarker = "login=true";
|
||||
@ -112,7 +114,13 @@ $tw.plugins.dropbox.loadTiddlerFiles = function(path,callback) {
|
||||
$tw.plugins.dropbox.loadTiddlerFile(task.path,task.type,task.stats,callback);
|
||||
}, 2);
|
||||
// Call the callback when we've processed all the files
|
||||
q.drain = callback;
|
||||
q.drain = function() {
|
||||
var fileRevisions = {};
|
||||
for(var t=0; t<stats.length; t++) {
|
||||
fileRevisions[stats[t].name] = stats[t].versionTag;
|
||||
}
|
||||
callback(fileRevisions);
|
||||
};
|
||||
// Push a task onto the queue for each file to be processed
|
||||
for(var s=0; s<stats.length; s++) {
|
||||
var stat = stats[s],
|
||||
@ -276,6 +284,30 @@ $tw.plugins.dropbox.createWiki = function(wikiName) {
|
||||
});
|
||||
};
|
||||
|
||||
// Save the index file
|
||||
$tw.plugins.dropbox.saveTiddlerIndex = function(path,fileRevisions,callback) {
|
||||
// Get the tiddler index information
|
||||
var index = {tiddlers: [],shadows: [], fileRevisions: {}}
|
||||
// First all the tiddlers
|
||||
$tw.wiki.forEachTiddler(function(title,tiddler) {
|
||||
if(tiddler.isShadow) {
|
||||
index.tiddlers.push(tiddler.fields);
|
||||
} else {
|
||||
index.shadows.push(tiddler.fields);
|
||||
}
|
||||
});
|
||||
// Then all the revision information
|
||||
index.fileRevisions = fileRevisions;
|
||||
// Save everything to a tiddler
|
||||
$tw.wiki.addTiddler({title: titleTiddlerIndex, type: "application/json", text: JSON.stringify(index)});
|
||||
// Generate the index file
|
||||
var file = $tw.wiki.renderTiddler("text/plain",titleAppIndexTemplate);
|
||||
// Save the index to Dropbox
|
||||
$tw.plugins.dropbox.client.writeFile(path,file,function(error,stat) {
|
||||
callback(error);
|
||||
});
|
||||
};
|
||||
|
||||
exports.startup = function() {
|
||||
if(!$tw.browser) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user