2013-05-27 19:45:33 +00:00
|
|
|
define([
|
|
|
|
"utils",
|
|
|
|
"tumblr-helper"
|
|
|
|
], function(utils, tumblrHelper) {
|
2013-04-28 22:33:17 +00:00
|
|
|
|
2013-05-04 00:05:58 +00:00
|
|
|
var PROVIDER_TUMBLR = "tumblr";
|
|
|
|
|
2013-04-28 22:33:17 +00:00
|
|
|
var tumblrProvider = {
|
|
|
|
providerId: PROVIDER_TUMBLR,
|
2013-05-22 21:54:14 +00:00
|
|
|
providerName: "Tumblr",
|
|
|
|
publishPreferencesInputIds: ["tumblr-hostname"]
|
2013-04-28 22:33:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
tumblrProvider.publish = function(publishAttributes, title, content, callback) {
|
|
|
|
tumblrHelper.upload(
|
|
|
|
publishAttributes.blogHostname,
|
|
|
|
publishAttributes.postId,
|
|
|
|
publishAttributes.tags,
|
|
|
|
publishAttributes.format == "markdown" ? "markdown" : "html",
|
|
|
|
title,
|
|
|
|
content,
|
|
|
|
function(error, postId) {
|
|
|
|
if(error) {
|
|
|
|
callback(error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
publishAttributes.postId = postId;
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
tumblrProvider.newPublishAttributes = function(event) {
|
|
|
|
var publishAttributes = {};
|
2013-05-25 18:13:59 +00:00
|
|
|
publishAttributes.blogHostname = utils
|
|
|
|
.getInputTextValue(
|
|
|
|
"#input-publish-tumblr-hostname",
|
2013-04-28 22:33:17 +00:00
|
|
|
event,
|
|
|
|
/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/);
|
2013-05-25 18:13:59 +00:00
|
|
|
publishAttributes.postId = utils.getInputTextValue("#input-publish-postid");
|
|
|
|
publishAttributes.tags = utils.getInputTextValue("#input-publish-tags");
|
2013-04-28 22:33:17 +00:00
|
|
|
if(event.isPropagationStopped()) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
return publishAttributes;
|
|
|
|
};
|
|
|
|
|
|
|
|
return tumblrProvider;
|
|
|
|
});
|