2012-10-10 09:47:05 +00:00
|
|
|
/*\
|
|
|
|
title: $:/plugins/dropbox/dropbox.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: startup
|
|
|
|
|
|
|
|
Startup the Dropbox integration plugin
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
// Obfuscated API key
|
|
|
|
var apiKey = "m+qwjj8wFRA=|1TSoitGS9Nz2RTwv+jrUJnsAj0yy57NhQJ4TkZ/+Hw==";
|
|
|
|
|
2012-10-11 14:43:34 +00:00
|
|
|
// Query string marker for forcing authentication
|
|
|
|
var queryLoginMarker = "login=true";
|
|
|
|
|
2012-10-10 09:47:05 +00:00
|
|
|
$tw.plugins.dropbox = {
|
2012-10-13 16:31:07 +00:00
|
|
|
client: null, // Dropbox.js client object
|
2012-10-13 22:31:15 +00:00
|
|
|
fileInfo: {}, // Hashmap of each file as retrieved from Dropbox: {versionTag:,title:}
|
2012-10-13 16:31:07 +00:00
|
|
|
titleIsLoggedIn: "$:/plugins/dropbox/IsLoggedIn",
|
|
|
|
titleUserName: "$:/plugins/dropbox/UserName",
|
|
|
|
titlePublicAppUrl: "$:/plugins/dropbox/PublicAppUrl",
|
|
|
|
titleAppTemplateHtml: "$:/plugins/dropbox/apptemplate.html",
|
|
|
|
titleTiddlerIndex: "$:/plugins/dropbox/Index",
|
|
|
|
titleAppIndexTemplate: "$:/plugins/dropbox/index.template.html",
|
|
|
|
titleWikiName: "$:/plugins/dropbox/WikiName",
|
|
|
|
titleLoadedWikis: "$:/plugins/dropbox/LoadedWikis"
|
2012-10-10 09:47:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Error handling
|
|
|
|
$tw.plugins.dropbox.showError = function(error) {
|
|
|
|
alert("Dropbox error: " + error);
|
|
|
|
console.log("Dropbox error: " + error);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Authenticate
|
|
|
|
$tw.plugins.dropbox.login = function() {
|
|
|
|
$tw.plugins.dropbox.client.authenticate(function(error, client) {
|
|
|
|
if(error) {
|
|
|
|
return $tw.plugins.dropbox.showError(error);
|
|
|
|
}
|
|
|
|
// Mark us as logged in
|
2012-10-13 16:31:07 +00:00
|
|
|
$tw.wiki.addTiddler({title: $tw.plugins.dropbox.titleIsLoggedIn, text: "yes"},true);
|
2012-10-10 09:47:05 +00:00
|
|
|
// Get user information
|
2012-10-10 20:59:25 +00:00
|
|
|
$tw.plugins.dropbox.getUserInfo(function() {
|
|
|
|
// Invoke any dropbox-startup modules
|
2012-10-13 23:21:44 +00:00
|
|
|
$tw.plugins.dropbox.invokeDropboxStartupModules(true);
|
2012-10-10 09:47:05 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2012-10-13 23:21:44 +00:00
|
|
|
// Invoke any dropbox-startup modules
|
|
|
|
$tw.plugins.dropbox.invokeDropboxStartupModules = function(loggedIn) {
|
|
|
|
var mods = $tw.modules.types["dropbox-startup"];
|
|
|
|
for(var m=0; m<mods.length; m++) {
|
|
|
|
mods[m].startup(loggedIn);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-10-10 09:47:05 +00:00
|
|
|
// Get user information
|
2012-10-10 20:59:25 +00:00
|
|
|
$tw.plugins.dropbox.getUserInfo = function(callback) {
|
2012-10-10 09:47:05 +00:00
|
|
|
$tw.plugins.dropbox.client.getUserInfo(function(error,userInfo) {
|
|
|
|
if(error) {
|
2012-10-10 20:59:25 +00:00
|
|
|
callback(error);
|
2012-10-10 09:47:05 +00:00
|
|
|
return $tw.plugins.dropbox.showError(error);
|
|
|
|
}
|
2012-10-10 20:59:25 +00:00
|
|
|
$tw.plugins.dropbox.userInfo = userInfo;
|
2012-10-10 09:47:05 +00:00
|
|
|
// Save the username
|
2012-10-13 16:31:07 +00:00
|
|
|
$tw.wiki.addTiddler({title: $tw.plugins.dropbox.titleUserName, text: userInfo.name},true);
|
2012-10-10 20:59:25 +00:00
|
|
|
callback();
|
2012-10-10 09:47:05 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// Logout
|
|
|
|
$tw.plugins.dropbox.logout = function() {
|
|
|
|
$tw.plugins.dropbox.client.signOut(function(error) {
|
|
|
|
if(error) {
|
|
|
|
return $tw.plugins.dropbox.showError(error);
|
|
|
|
}
|
|
|
|
// Mark us as logged out
|
2012-10-13 16:31:07 +00:00
|
|
|
$tw.wiki.deleteTiddler($tw.plugins.dropbox.titleUserName);
|
|
|
|
$tw.wiki.addTiddler({title: $tw.plugins.dropbox.titleIsLoggedIn, text: "no"},true);
|
2012-10-11 14:43:34 +00:00
|
|
|
// Remove any marker from the query string
|
|
|
|
document.location.search = "";
|
2012-10-10 09:47:05 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2012-10-10 20:59:25 +00:00
|
|
|
// Load tiddlers representing each wiki in a folder
|
|
|
|
$tw.plugins.dropbox.loadWikiFiles = function(path,callback) {
|
|
|
|
// First get the list of tiddler files
|
|
|
|
$tw.plugins.dropbox.client.stat(path,{readDir: true},function(error,stat,stats) {
|
|
|
|
if(error) {
|
|
|
|
return $tw.plugins.dropbox.showError(error);
|
|
|
|
}
|
|
|
|
// Create a tiddler for each folder
|
|
|
|
for(var s=0; s<stats.length; s++) {
|
|
|
|
var stat = stats[s];
|
|
|
|
if(!stat.isFile && stat.isFolder) {
|
2012-10-11 13:56:30 +00:00
|
|
|
var url = $tw.plugins.dropbox.userInfo.publicAppUrl + stat.path + "/index.html";
|
2012-10-12 07:22:44 +00:00
|
|
|
$tw.wiki.addTiddler({title: "'" + stat.name + "'", text: "wiki", tags: ["wiki"], wikiName: stat.name, urlView: url, urlEdit: url + "?login=true"});
|
2012-10-10 20:59:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2012-10-13 23:21:44 +00:00
|
|
|
// Synchronise the local state with the files in Dropbox
|
|
|
|
$tw.plugins.dropbox.refreshTiddlerFiles = function(path,callback) {
|
2012-10-10 09:47:05 +00:00
|
|
|
// First get the list of tiddler files
|
|
|
|
$tw.plugins.dropbox.client.stat(path,{readDir: true},function(error,stat,stats) {
|
|
|
|
if(error) {
|
|
|
|
return $tw.plugins.dropbox.showError(error);
|
|
|
|
}
|
2012-10-13 23:21:44 +00:00
|
|
|
// Make a hashmap of each of the file names
|
|
|
|
var filenames = {},f,hadDeletions;
|
|
|
|
for(f=0; f<stats.length; f++) {
|
|
|
|
filenames[stats[f].name] = true;
|
|
|
|
}
|
|
|
|
console.log("filenames",filenames);
|
|
|
|
console.log("fileinfo",$tw.plugins.dropbox.fileInfo)
|
|
|
|
// Check to see if any files have been deleted, and remove the associated tiddlers
|
|
|
|
for(f in $tw.plugins.dropbox.fileInfo) {
|
|
|
|
if(!$tw.utils.hop(filenames,f)) {
|
|
|
|
$tw.wiki.deleteTiddler($tw.plugins.dropbox.fileInfo[f].title);
|
|
|
|
hadDeletions = true;
|
|
|
|
}
|
|
|
|
}
|
2012-10-10 09:47:05 +00:00
|
|
|
// Process the files via an asynchronous queue, with concurrency set to 2 at a time
|
|
|
|
var q = async.queue(function(task,callback) {
|
|
|
|
$tw.plugins.dropbox.loadTiddlerFile(task.path,task.type,task.stats,callback);
|
|
|
|
}, 2);
|
|
|
|
// Call the callback when we've processed all the files
|
2012-10-13 18:51:01 +00:00
|
|
|
q.drain = function () {
|
|
|
|
callback(true); // Indicate that there were changes
|
2012-10-13 15:09:19 +00:00
|
|
|
};
|
2012-10-10 09:47:05 +00:00
|
|
|
// Push a task onto the queue for each file to be processed
|
|
|
|
for(var s=0; s<stats.length; s++) {
|
|
|
|
var stat = stats[s],
|
|
|
|
isMetaFile = stat.path.lastIndexOf(".meta") === stat.path.length - 5;
|
|
|
|
if(stat.isFile && !stat.isFolder && !isMetaFile) {
|
2012-10-13 18:51:01 +00:00
|
|
|
// Don't load the file if the version tag shows it hasn't changed
|
2012-10-13 22:31:15 +00:00
|
|
|
var fileInfo = $tw.plugins.dropbox.fileInfo[stat.name] || {},
|
|
|
|
hasChanged = stat.versionTag !== fileInfo.versionTag;
|
2012-10-13 18:51:01 +00:00
|
|
|
if(!hasChanged) {
|
|
|
|
// Check if there is a metafile and whether it has changed
|
|
|
|
var metafileName = stat.name + ".meta";
|
|
|
|
for(var p=0; p<stats.length; p++) {
|
|
|
|
if(stats[p].name === metafileName) {
|
2012-10-13 22:31:15 +00:00
|
|
|
fileInfo = $tw.plugins.dropbox.fileInfo[metafileName] || {};
|
|
|
|
hasChanged = stats[p].versionTag !== fileInfo.versionTag;
|
2012-10-13 18:51:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(hasChanged) {
|
|
|
|
q.push({path: stat.path, type: stat.mimeType, stats: stats});
|
|
|
|
}
|
2012-10-10 09:47:05 +00:00
|
|
|
}
|
|
|
|
}
|
2012-10-13 18:51:01 +00:00
|
|
|
// If we didn't queue anything for loading we'll have to manually trigger our callback
|
|
|
|
if(q.length() === 0) {
|
2012-10-13 23:21:44 +00:00
|
|
|
callback(hadDeletions); // And tell it that there are changes if there were deletions
|
2012-10-13 18:51:01 +00:00
|
|
|
}
|
2012-10-10 09:47:05 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// Load a tiddler file
|
|
|
|
$tw.plugins.dropbox.loadTiddlerFile = function(path,mimeType,stats,callback) {
|
2012-10-13 18:51:01 +00:00
|
|
|
console.log("loading tiddler from",path);
|
2012-10-10 09:47:05 +00:00
|
|
|
// If the mime type is "application/octet-stream" then we'll take the type from the extension
|
|
|
|
var isBinary = false,
|
|
|
|
p = path.lastIndexOf(".");
|
|
|
|
if(mimeType === "application/octet-stream" && p !== -1) {
|
|
|
|
var ext = path.substr(p);
|
|
|
|
if($tw.utils.hop($tw.config.fileExtensionInfo,ext)) {
|
|
|
|
mimeType = $tw.config.fileExtensionInfo[ext].type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($tw.utils.hop($tw.config.contentTypeInfo,mimeType)) {
|
|
|
|
isBinary = $tw.config.contentTypeInfo[mimeType].encoding === "base64";
|
|
|
|
}
|
2012-10-13 18:51:01 +00:00
|
|
|
var xhr = $tw.plugins.dropbox.client.readFile(path,{binary: isBinary},function(error,data,stat) {
|
2012-10-10 09:47:05 +00:00
|
|
|
if(error) {
|
|
|
|
callback(error);
|
|
|
|
return $tw.plugins.dropbox.showError(error);
|
|
|
|
}
|
2012-10-13 12:23:47 +00:00
|
|
|
// Compute the default title
|
|
|
|
var defaultTitle = path,
|
|
|
|
p = path.lastIndexOf("/");
|
|
|
|
if(p !== -1) {
|
|
|
|
defaultTitle = path.substr(p+1);
|
|
|
|
}
|
2012-10-10 09:47:05 +00:00
|
|
|
// Deserialise the tiddler(s) out of the text
|
|
|
|
var tiddlers;
|
|
|
|
if(isBinary) {
|
|
|
|
tiddlers = [{
|
2012-10-13 12:23:47 +00:00
|
|
|
title: defaultTitle,
|
2012-10-10 09:47:05 +00:00
|
|
|
text: $tw.plugins.dropbox.base64EncodeString(data),
|
|
|
|
type: mimeType
|
|
|
|
}];
|
|
|
|
} else {
|
2012-10-13 12:23:47 +00:00
|
|
|
tiddlers = $tw.wiki.deserializeTiddlers(mimeType,data,{title: defaultTitle});
|
2012-10-10 09:47:05 +00:00
|
|
|
}
|
|
|
|
// Check to see if there's a metafile
|
|
|
|
var metafilePath = path + ".meta",
|
|
|
|
metafileIndex = null;
|
|
|
|
for(var t=0; t<stats.length; t++) {
|
|
|
|
if(stats[t].path === metafilePath) {
|
|
|
|
metafileIndex = t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Process the metafile if it's there
|
|
|
|
if(tiddlers.length === 1 && metafileIndex !== null) {
|
2012-10-13 23:21:44 +00:00
|
|
|
var mainStat = stat;
|
2012-10-13 18:51:01 +00:00
|
|
|
$tw.plugins.dropbox.client.readFile(metafilePath,function(error,data,stat) {
|
2012-10-10 09:47:05 +00:00
|
|
|
if(error) {
|
|
|
|
callback(error);
|
|
|
|
return $tw.plugins.dropbox.showError(error);
|
|
|
|
}
|
2012-10-13 18:51:01 +00:00
|
|
|
// Extract the metadata and add the tiddlers
|
2012-10-10 09:47:05 +00:00
|
|
|
tiddlers = [$tw.utils.parseFields(data,tiddlers[0])];
|
|
|
|
$tw.wiki.addTiddlers(tiddlers);
|
2012-10-13 23:21:44 +00:00
|
|
|
// Save the revision of the files so we can detect changes later
|
|
|
|
$tw.plugins.dropbox.fileInfo[mainStat.name] = {versionTag: mainStat.versionTag,title: tiddlers[0].title};
|
|
|
|
$tw.plugins.dropbox.fileInfo[stat.name] = {versionTag: stat.versionTag,title: tiddlers[0].title};
|
2012-10-10 09:47:05 +00:00
|
|
|
callback();
|
|
|
|
});
|
|
|
|
} else {
|
2012-10-13 18:51:01 +00:00
|
|
|
// Add the tiddlers
|
2012-10-10 09:47:05 +00:00
|
|
|
$tw.wiki.addTiddlers(tiddlers);
|
2012-10-13 23:21:44 +00:00
|
|
|
// Save the revision of this file so we can detect changes
|
|
|
|
$tw.plugins.dropbox.fileInfo[stat.name] = {versionTag: stat.versionTag,title: tiddlers[0].title};
|
2012-10-10 09:47:05 +00:00
|
|
|
callback();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2012-10-10 20:59:25 +00:00
|
|
|
|
2012-10-10 09:47:05 +00:00
|
|
|
// Encode a binary file as returned by Dropbox into the base 64 equivalent
|
|
|
|
// Adapted from Jon Leighton, https://gist.github.com/958841
|
|
|
|
$tw.plugins.dropbox.base64EncodeString = function(data) {
|
|
|
|
var base64 = [],
|
|
|
|
charmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
|
|
|
|
byteRemainder = data.length % 3,
|
|
|
|
mainLength = data.length - byteRemainder,
|
|
|
|
a, b, c, d,
|
|
|
|
chunk;
|
|
|
|
// Main loop deals with bytes in chunks of 3
|
|
|
|
for(var i=0; i<mainLength; i=i+3) {
|
|
|
|
// Combine the three bytes into a single integer
|
|
|
|
chunk = (data.charCodeAt(i) << 16) | (data.charCodeAt(i + 1) << 8) | data.charCodeAt(i + 2);
|
|
|
|
// Use bitmasks to extract 6-bit segments from the triplet
|
|
|
|
a = (chunk & 16515072) >> 18; // 16515072 = (2^6 - 1) << 18
|
|
|
|
b = (chunk & 258048) >> 12; // 258048 = (2^6 - 1) << 12
|
|
|
|
c = (chunk & 4032) >> 6; // 4032 = (2^6 - 1) << 6
|
|
|
|
d = chunk & 63; // 63 = 2^6 - 1
|
|
|
|
// Convert the raw binary segments to the appropriate ASCII encoding
|
|
|
|
base64.push(charmap[a],charmap[b],charmap[c],charmap[d]);
|
|
|
|
}
|
|
|
|
// Deal with the remaining bytes and padding
|
|
|
|
if(byteRemainder === 1) {
|
|
|
|
chunk = data[mainLength];
|
|
|
|
a = (chunk & 252) >> 2; // 252 = (2^6 - 1) << 2
|
|
|
|
// Set the 4 least significant bits to zero
|
|
|
|
b = (chunk & 3) << 4; // 3 = 2^2 - 1
|
|
|
|
base64.push(charmap[a],charmap[b],"==");
|
|
|
|
} else if(byteRemainder === 2) {
|
|
|
|
chunk = (data[mainLength] << 8) | data[mainLength + 1];
|
|
|
|
a = (chunk & 64512) >> 10; // 64512 = (2^6 - 1) << 10
|
|
|
|
b = (chunk & 1008) >> 4; // 1008 = (2^6 - 1) << 4
|
|
|
|
// Set the 2 least significant bits to zero
|
|
|
|
c = (chunk & 15) << 2; // 15 = 2^4 - 1
|
|
|
|
base64.push(charmap[a],charmap[b],charmap[c],"=");
|
|
|
|
}
|
|
|
|
return base64.join("");
|
|
|
|
};
|
|
|
|
|
2012-10-11 14:43:34 +00:00
|
|
|
// Rewrite the document location to include a force login marker
|
|
|
|
$tw.plugins.dropbox.forceLogin = function() {
|
|
|
|
if(document.location.search.indexOf(queryLoginMarker) === -1) {
|
|
|
|
document.location.search = queryLoginMarker;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-10-12 07:22:44 +00:00
|
|
|
// Create a new empty TiddlyWiki
|
|
|
|
$tw.plugins.dropbox.createWiki = function(wikiName) {
|
|
|
|
// Remove any dodgy characters from the wiki name
|
2012-10-12 18:01:35 +00:00
|
|
|
wikiName = wikiName.replace(/[\!\@\€\£\%\^\*\+\$\:\?\#\/\\\<\>\|\"\'\`\~\=]/g,"");
|
2012-10-12 07:22:44 +00:00
|
|
|
// Check that the name isn't now empty
|
|
|
|
if(wikiName.length === 0) {
|
|
|
|
return alert("Bad wiki name");
|
|
|
|
}
|
|
|
|
// Create the wiki
|
|
|
|
async.series([
|
|
|
|
function(callback) {
|
|
|
|
// First create the wiki folder
|
|
|
|
$tw.plugins.dropbox.client.mkdir(wikiName,function(error,stat) {
|
|
|
|
callback(error);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
function(callback) {
|
|
|
|
// Second create the tiddlers folder
|
|
|
|
$tw.plugins.dropbox.client.mkdir(wikiName + "/tiddlers",function(error,stat) {
|
|
|
|
callback(error);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
function(callback) {
|
|
|
|
// Third save the template app HTML file
|
2012-10-13 16:31:07 +00:00
|
|
|
var tiddler = $tw.wiki.getTiddler($tw.plugins.dropbox.titleAppTemplateHtml);
|
2012-10-12 07:22:44 +00:00
|
|
|
if(!tiddler) {
|
|
|
|
callback("Cannot find app template tiddler");
|
|
|
|
} else {
|
|
|
|
$tw.plugins.dropbox.client.writeFile(wikiName + "/index.html",tiddler.fields.text,function(error,stat) {
|
|
|
|
callback(error);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
// optional callback
|
2012-10-12 18:01:35 +00:00
|
|
|
function(error,results) {
|
|
|
|
if(error) {
|
|
|
|
$tw.plugins.dropbox.showError(error);
|
|
|
|
} else {
|
|
|
|
alert("Created wiki " + wikiName);
|
|
|
|
}
|
2012-10-12 07:22:44 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2012-10-13 15:09:19 +00:00
|
|
|
// Save the index file
|
2012-10-13 18:51:01 +00:00
|
|
|
$tw.plugins.dropbox.saveTiddlerIndex = function(path,callback) {
|
2012-10-13 15:09:19 +00:00
|
|
|
// Get the tiddler index information
|
2012-10-13 22:31:15 +00:00
|
|
|
var index = {tiddlers: [],shadows: [], fileInfo: $tw.plugins.dropbox.fileInfo};
|
2012-10-13 15:09:19 +00:00
|
|
|
// First all the tiddlers
|
|
|
|
$tw.wiki.forEachTiddler(function(title,tiddler) {
|
|
|
|
if(tiddler.isShadow) {
|
|
|
|
index.shadows.push(tiddler.fields);
|
2012-10-13 16:31:07 +00:00
|
|
|
} else {
|
|
|
|
index.tiddlers.push(tiddler.fields);
|
2012-10-13 15:09:19 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
// Save everything to a tiddler
|
2012-10-13 18:51:01 +00:00
|
|
|
$tw.wiki.addTiddler({title: $tw.plugins.dropbox.titleTiddlerIndex, type: "application/json", text: JSON.stringify(index)},true);
|
2012-10-13 15:09:19 +00:00
|
|
|
// Generate the index file
|
2012-10-13 16:31:07 +00:00
|
|
|
var file = $tw.wiki.renderTiddler("text/plain",$tw.plugins.dropbox.titleAppIndexTemplate);
|
2012-10-13 15:09:19 +00:00
|
|
|
// Save the index to Dropbox
|
|
|
|
$tw.plugins.dropbox.client.writeFile(path,file,function(error,stat) {
|
|
|
|
callback(error);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2012-10-10 09:47:05 +00:00
|
|
|
exports.startup = function() {
|
|
|
|
if(!$tw.browser) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Mark us as not logged in
|
2012-10-13 16:31:07 +00:00
|
|
|
$tw.wiki.addTiddler({title: $tw.plugins.dropbox.titleIsLoggedIn, text: "no"},true);
|
2012-10-10 09:47:05 +00:00
|
|
|
// Initialise Dropbox for sandbox access
|
|
|
|
$tw.plugins.dropbox.client = new Dropbox.Client({key: apiKey, sandbox: true});
|
|
|
|
// Use the basic redirection authentication driver
|
|
|
|
$tw.plugins.dropbox.client.authDriver(new Dropbox.Drivers.Redirect({rememberUser: true}));
|
2012-10-11 14:43:34 +00:00
|
|
|
// Authenticate ourselves if the marker is in the document query string
|
|
|
|
if(document.location.search.indexOf(queryLoginMarker) !== -1) {
|
|
|
|
$tw.plugins.dropbox.login();
|
2012-10-13 23:21:44 +00:00
|
|
|
} else {
|
|
|
|
$tw.plugins.dropbox.invokeDropboxStartupModules(false);
|
2012-10-11 14:43:34 +00:00
|
|
|
}
|
2012-10-10 09:47:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|