mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-10-01 16:30:46 +00:00
Compute wikiname from document URL
This commit is contained in:
parent
07798ccff3
commit
149216ff7d
@ -12,11 +12,28 @@ Startup the Dropbox wiki app
|
|||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var titleWikiName = "$:/plugins/dropbox/WikiName";
|
||||||
|
|
||||||
exports.startup = function() {
|
exports.startup = function() {
|
||||||
// Load tiddlers
|
// Check that we've been loaded from the dropbox
|
||||||
$tw.plugins.dropbox.loadTiddlerFiles("/My TiddlyWiki/tiddlers",function() {
|
var url = (window.location.protocol + "//" + window.location.host + window.location.pathname),
|
||||||
console.log("Loaded all tiddlers",$tw.wiki.tiddlers);
|
wikiName;
|
||||||
});
|
if(url.indexOf($tw.plugins.dropbox.userInfo.publicAppUrl) === 0) {
|
||||||
|
var p = url.indexOf("/",$tw.plugins.dropbox.userInfo.publicAppUrl.length + 1);
|
||||||
|
if(p !== -1 && url.substr(p) === "/index.html") {
|
||||||
|
wikiName = decodeURIComponent(url.substring($tw.plugins.dropbox.userInfo.publicAppUrl.length + 1,p));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(wikiName) {
|
||||||
|
$tw.plugins.dropbox.wikiName = wikiName;
|
||||||
|
$tw.wiki.addTiddler({title: titleWikiName, text: $tw.plugins.dropbox.wikiName});
|
||||||
|
// Load tiddlers
|
||||||
|
$tw.plugins.dropbox.loadTiddlerFiles("/" + $tw.plugins.dropbox.wikiName + "/tiddlers",function() {
|
||||||
|
console.log("Loaded all tiddlers",$tw.wiki.tiddlers);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert("This TiddlyWiki file must be in Dropbox");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user