2013-05-27 19:45:33 +00:00
|
|
|
define([
|
2013-05-29 19:55:23 +00:00
|
|
|
"underscore",
|
2013-05-27 19:45:33 +00:00
|
|
|
"utils",
|
2013-06-10 21:22:32 +00:00
|
|
|
"helpers/googleHelper"
|
2013-05-27 19:45:33 +00:00
|
|
|
], function(_, utils, googleHelper) {
|
2013-05-04 00:05:58 +00:00
|
|
|
|
2013-05-29 19:55:23 +00:00
|
|
|
var PROVIDER_BLOGGER = "blogger";
|
2013-04-15 21:15:15 +00:00
|
|
|
|
2013-05-29 19:55:23 +00:00
|
|
|
var bloggerProvider = {
|
|
|
|
providerId: PROVIDER_BLOGGER,
|
|
|
|
providerName: "Blogger",
|
|
|
|
defaultPublishFormat: "html",
|
|
|
|
publishPreferencesInputIds: [
|
|
|
|
"blogger-url"
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
bloggerProvider.publish = function(publishAttributes, title, content, callback) {
|
|
|
|
googleHelper.uploadBlogger(publishAttributes.blogUrl, publishAttributes.blogId, publishAttributes.postId, publishAttributes.labelList, title, content, function(error, blogId, postId) {
|
|
|
|
if(error) {
|
|
|
|
callback(error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
publishAttributes.blogId = blogId;
|
|
|
|
publishAttributes.postId = postId;
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
bloggerProvider.newPublishAttributes = function(event) {
|
|
|
|
var publishAttributes = {};
|
|
|
|
var blogUrl = utils.getInputTextValue("#input-publish-blogger-url", event);
|
|
|
|
if(blogUrl !== undefined) {
|
|
|
|
publishAttributes.blogUrl = utils.checkUrl(blogUrl);
|
|
|
|
}
|
|
|
|
publishAttributes.postId = utils.getInputTextValue("#input-publish-postid");
|
|
|
|
publishAttributes.labelList = [];
|
|
|
|
var labels = utils.getInputTextValue("#input-publish-labels");
|
|
|
|
if(labels !== undefined) {
|
|
|
|
publishAttributes.labelList = _.chain(labels.split(",")).map(function(label) {
|
|
|
|
return utils.trim(label);
|
|
|
|
}).compact().value();
|
|
|
|
}
|
|
|
|
if(event.isPropagationStopped()) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
return publishAttributes;
|
|
|
|
};
|
|
|
|
|
|
|
|
return bloggerProvider;
|
2013-04-15 21:15:15 +00:00
|
|
|
});
|