Stackedit/js/wordpress-provider.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2013-05-27 19:45:33 +00:00
define([
"utils",
"wordpress-helper"
], function(utils, wordpressHelper) {
2013-05-16 00:19:58 +00:00
var PROVIDER_WORDPRESS = "wordpress";
var wordpressProvider = {
providerId: PROVIDER_WORDPRESS,
providerName: "WordPress",
defaultPublishFormat: "html",
publishPreferencesInputIds: ["wordpress-site"]
2013-05-16 00:19:58 +00:00
};
wordpressProvider.publish = function(publishAttributes, title, content, callback) {
wordpressHelper.upload(
publishAttributes.site,
publishAttributes.postId,
publishAttributes.tags,
title,
content,
function(error, postId) {
if(error) {
callback(error);
return;
}
publishAttributes.postId = postId;
callback();
}
);
};
wordpressProvider.newPublishAttributes = function(event) {
var publishAttributes = {};
2013-05-25 18:13:59 +00:00
publishAttributes.site = utils
.getInputTextValue(
"#input-publish-wordpress-site",
2013-05-16 00:19:58 +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-05-16 00:19:58 +00:00
if(event.isPropagationStopped()) {
return undefined;
}
return publishAttributes;
};
return wordpressProvider;
});