Stackedit/res/providers/gistProvider.js

43 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2013-05-27 19:45:33 +00:00
define([
"utils",
2013-06-22 23:48:57 +00:00
"classes/Provider",
2013-06-10 21:22:32 +00:00
"helpers/githubHelper"
2013-06-22 23:48:57 +00:00
], function(utils, Provider, githubHelper) {
2013-04-29 23:19:54 +00:00
2013-06-22 23:48:57 +00:00
var gistProvider = new Provider("gist", "Gist");
2013-08-23 23:50:14 +00:00
gistProvider.publishPreferencesInputIds = [
"gist-public"
];
2013-06-22 23:48:57 +00:00
gistProvider.sharingAttributes = [
"gistId",
"filename"
];
2013-05-29 19:55:23 +00:00
gistProvider.publish = function(publishAttributes, title, content, callback) {
githubHelper.uploadGist(publishAttributes.gistId, publishAttributes.filename, publishAttributes.isPublic, title, content, function(error, gistId) {
if(error) {
callback(error);
return;
}
publishAttributes.gistId = gistId;
callback();
});
};
gistProvider.newPublishAttributes = function(event) {
var publishAttributes = {};
publishAttributes.gistId = utils.getInputTextValue("#input-publish-gist-id");
publishAttributes.filename = utils.getInputTextValue("#input-publish-filename", event);
publishAttributes.isPublic = utils.getInputChecked("#input-publish-gist-public");
if(event.isPropagationStopped()) {
return undefined;
}
return publishAttributes;
};
gistProvider.importPublic = function(importParameters, callback) {
githubHelper.downloadGist(importParameters.gistId, importParameters.filename, callback);
};
return gistProvider;
2013-04-29 23:19:54 +00:00
});