Stackedit/js/ssh-provider.js

48 lines
1.3 KiB
JavaScript
Raw Normal View History

2013-05-27 19:45:33 +00:00
define([
"utils",
"ssh-helper"
], function(utils, sshHelper) {
2013-05-19 18:56:15 +00:00
var PROVIDER_SSH = "ssh";
var sshProvider = {
providerId : PROVIDER_SSH,
providerName : "SSH server",
publishPreferencesInputIds: ["ssh-host", "ssh-port", "ssh-username", "ssh-password"]
2013-05-19 18:56:15 +00:00
};
sshProvider.publish = function(publishAttributes, title, content, callback) {
sshHelper.upload(
publishAttributes.host,
publishAttributes.port,
publishAttributes.username,
publishAttributes.password,
publishAttributes.path,
title,
content,
callback);
};
sshProvider.newPublishAttributes = function(event) {
var publishAttributes = {};
2013-05-25 18:13:59 +00:00
publishAttributes.host = utils
.getInputTextValue(
"#input-publish-ssh-host",
2013-05-19 18:56:15 +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.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);
2013-05-19 18:56:15 +00:00
if (event.isPropagationStopped()) {
return undefined;
}
return publishAttributes;
};
return sshProvider;
});