From 66cdd8a639cb5093e3130951588d6aebbf77f5b7 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 13 Oct 2012 13:23:47 +0100 Subject: [PATCH] Set default title for tiddler files without metadata --- tw5dropbox/plugins/dropbox.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tw5dropbox/plugins/dropbox.js b/tw5dropbox/plugins/dropbox.js index 2cc06667e..d864273cf 100644 --- a/tw5dropbox/plugins/dropbox.js +++ b/tw5dropbox/plugins/dropbox.js @@ -143,16 +143,22 @@ $tw.plugins.dropbox.loadTiddlerFile = function(path,mimeType,stats,callback) { callback(error); return $tw.plugins.dropbox.showError(error); } + // Compute the default title + var defaultTitle = path, + p = path.lastIndexOf("/"); + if(p !== -1) { + defaultTitle = path.substr(p+1); + } // Deserialise the tiddler(s) out of the text var tiddlers; if(isBinary) { tiddlers = [{ - title: path, + title: defaultTitle, text: $tw.plugins.dropbox.base64EncodeString(data), type: mimeType }]; } else { - tiddlers = $tw.wiki.deserializeTiddlers(mimeType,data,{title: path}); + tiddlers = $tw.wiki.deserializeTiddlers(mimeType,data,{title: defaultTitle}); } // Check to see if there's a metafile var metafilePath = path + ".meta",