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
|
|
|
|
2013-10-06 14:34:40 +00:00
|
|
|
bloggerProvider.publish = function(publishAttributes, frontMatter, title, content, callback) {
|
|
|
|
var labelList = publishAttributes.labelList || [];
|
|
|
|
if(frontMatter) {
|
|
|
|
frontMatter.categories !== undefined && (labelList = frontMatter.categories);
|
|
|
|
frontMatter.tags !== undefined && (labelList = frontMatter.tags);
|
|
|
|
}
|
|
|
|
_.isString(labelList) && (labelList = _.compact(labelList.split(/[\s,]/)));
|
|
|
|
googleHelper.uploadBlogger(publishAttributes.blogUrl, publishAttributes.blogId, publishAttributes.postId, labelList, title, content, function(error, blogId, postId) {
|
2013-05-29 19:55:23 +00:00
|
|
|
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");
|
|
|
|
if(event.isPropagationStopped()) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
return publishAttributes;
|
|
|
|
};
|
|
|
|
|
|
|
|
return bloggerProvider;
|
2013-04-15 21:15:15 +00:00
|
|
|
});
|