Stackedit/js/providers/sshProvider.js

33 lines
1.4 KiB
JavaScript
Raw 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/sshHelper"
2013-06-22 23:48:57 +00:00
], function(utils, Provider, sshHelper) {
2013-05-19 18:56:15 +00:00
2013-06-22 23:48:57 +00:00
var sshProvider = new Provider("ssh", "SSH server");
sshProvider.publishPreferencesInputIds = [
"ssh-host",
"ssh-port",
"ssh-username",
"ssh-password"
];
2013-05-19 18:56:15 +00:00
2013-05-29 19:55:23 +00:00
sshProvider.publish = function(publishAttributes, title, content, callback) {
sshHelper.upload(publishAttributes.host, publishAttributes.port, publishAttributes.username, publishAttributes.password, publishAttributes.path, title, content, callback);
};
2013-05-19 18:56:15 +00:00
2013-05-29 19:55:23 +00:00
sshProvider.newPublishAttributes = function(event) {
var publishAttributes = {};
publishAttributes.host = utils.getInputTextValue("#input-publish-ssh-host", 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])$/);
publishAttributes.port = utils.getInputIntValue("#input-publish-ssh-port", undefined, 0);
publishAttributes.username = utils.getInputTextValue("#input-publish-ssh-username", event);
publishAttributes.password = utils.getInputTextValue("#input-publish-ssh-password", event);
publishAttributes.path = utils.getInputTextValue("#input-publish-file-path", event);
if(event.isPropagationStopped()) {
return undefined;
}
return publishAttributes;
};
2013-05-19 18:56:15 +00:00
2013-05-29 19:55:23 +00:00
return sshProvider;
2013-05-19 18:56:15 +00:00
});