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"
|
|
|
|
];
|
2014-09-28 18:34:30 +00:00
|
|
|
gistProvider.viewerSharingAttributes = [
|
2013-06-22 23:48:57 +00:00
|
|
|
"gistId",
|
|
|
|
"filename"
|
|
|
|
];
|
2013-05-29 19:55:23 +00:00
|
|
|
|
2014-10-12 11:14:03 +00:00
|
|
|
gistProvider.getPublishLocationLink = function(attributes) {
|
|
|
|
return [
|
|
|
|
'https://gist.github.com/',
|
|
|
|
attributes.gistId
|
|
|
|
].join('');
|
|
|
|
};
|
|
|
|
|
2013-10-06 14:34:40 +00:00
|
|
|
gistProvider.publish = function(publishAttributes, frontMatter, title, content, callback) {
|
2013-05-29 19:55:23 +00:00
|
|
|
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
|
|
|
});
|