2013-05-27 19:45:33 +00:00
|
|
|
define([
|
|
|
|
"utils",
|
|
|
|
"github-helper"
|
|
|
|
], function(utils, githubHelper) {
|
2013-04-29 23:19:54 +00:00
|
|
|
|
2013-05-04 00:05:58 +00:00
|
|
|
var PROVIDER_GIST = "gist";
|
|
|
|
|
2013-04-29 23:19:54 +00:00
|
|
|
var gistProvider = {
|
|
|
|
providerId: PROVIDER_GIST,
|
2013-05-04 00:05:58 +00:00
|
|
|
providerName: "Gist",
|
|
|
|
sharingAttributes: ["gistId", "filename"]
|
2013-04-29 23:19:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
gistProvider.publish = function(publishAttributes, title, content, callback) {
|
2013-05-04 00:05:58 +00:00
|
|
|
githubHelper.uploadGist(publishAttributes.gistId, publishAttributes.filename, publishAttributes.isPublic,
|
2013-04-29 23:19:54 +00:00
|
|
|
title, content, function(error, gistId) {
|
|
|
|
if(error) {
|
|
|
|
callback(error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
publishAttributes.gistId = gistId;
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
gistProvider.newPublishAttributes = function(event) {
|
|
|
|
var publishAttributes = {};
|
2013-05-25 18:13:59 +00:00
|
|
|
publishAttributes.gistId = utils.getInputTextValue("#input-publish-gist-id");
|
|
|
|
publishAttributes.filename = utils.getInputTextValue("#input-publish-filename", event);
|
|
|
|
publishAttributes.isPublic = utils.getInputChecked("#input-publish-gist-public");
|
2013-04-29 23:19:54 +00:00
|
|
|
if(event.isPropagationStopped()) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
return publishAttributes;
|
|
|
|
};
|
2013-05-04 00:05:58 +00:00
|
|
|
|
|
|
|
gistProvider.importPublic = function(importParameters, callback) {
|
|
|
|
githubHelper.downloadGist(importParameters.gistId, importParameters.filename, callback);
|
|
|
|
};
|
2013-04-29 23:19:54 +00:00
|
|
|
|
|
|
|
return gistProvider;
|
|
|
|
});
|