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-22 23:48:57 +00:00
|
|
|
"classes/Provider",
|
2013-06-10 21:22:32 +00:00
|
|
|
"helpers/googleHelper"
|
2013-06-22 23:48:57 +00:00
|
|
|
], function(_, utils, Provider, googleHelper) {
|
2013-05-04 00:05:58 +00:00
|
|
|
|
2013-06-22 23:48:57 +00:00
|
|
|
var bloggerProvider = new Provider("blogger", "Blogger");
|
|
|
|
bloggerProvider.defaultPublishFormat = "html";
|
|
|
|
bloggerProvider.publishPreferencesInputIds = [
|
|
|
|
"blogger-url"
|
|
|
|
];
|
2013-05-29 19:55:23 +00:00
|
|
|
|
|
|
|
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
|
|
|
});
|