Add sign/publish code
This commit is contained in:
parent
5ff8d6be38
commit
bcc3b4d3ac
2 changed files with 74 additions and 85 deletions
|
@ -360,8 +360,32 @@ class Sidebar extends Class
|
||||||
@tag.find(".contents + .flex").removeClass("sign-publish-flex")
|
@tag.find(".contents + .flex").removeClass("sign-publish-flex")
|
||||||
|
|
||||||
menu = new Menu(@tag.find("#wrapper-sign-publish"))
|
menu = new Menu(@tag.find("#wrapper-sign-publish"))
|
||||||
menu.addItem "Sign"
|
menu.addItem "Sign", =>
|
||||||
menu.addItem "Publush"
|
inner_path = @tag.find("#input-contents").val()
|
||||||
|
|
||||||
|
wrapper.ws.cmd "fileRules", {inner_path: inner_path}, (res) =>
|
||||||
|
if wrapper.site_info.privatekey or wrapper.site_info.auth_address in res.signers
|
||||||
|
# Privatekey stored in users.json
|
||||||
|
wrapper.ws.cmd "siteSign", {privatekey: "stored", inner_path: inner_path, update_changed_files: true}, (res) =>
|
||||||
|
if res == "ok"
|
||||||
|
wrapper.notifications.add "sign", "done", "#{inner_path} Signed!", 5000
|
||||||
|
|
||||||
|
else
|
||||||
|
# Ask the user for privatekey
|
||||||
|
wrapper.displayPrompt "Enter your private key:", "password", "Sign", "", (privatekey) => # Prompt the private key
|
||||||
|
wrapper.ws.cmd "siteSign", {privatekey: privatekey, inner_path: inner_path, update_changed_files: true}, (res) =>
|
||||||
|
if res == "ok"
|
||||||
|
wrapper.notifications.add "sign", "done", "#{inner_path} Signed!", 5000
|
||||||
|
|
||||||
|
@tag.find(".contents + .flex").removeClass "active"
|
||||||
|
menu.hide()
|
||||||
|
|
||||||
|
menu.addItem "Publish", =>
|
||||||
|
inner_path = @tag.find("#input-contents").val()
|
||||||
|
wrapper.ws.cmd "sitePublish", {"inner_path": inner_path, "sign": false}
|
||||||
|
|
||||||
|
@tag.find(".contents + .flex").removeClass "active"
|
||||||
|
menu.hide()
|
||||||
|
|
||||||
@tag.find("#menu-sign-publish").off("click touchend").on "click touchend", =>
|
@tag.find("#menu-sign-publish").off("click touchend").on "click touchend", =>
|
||||||
if window.visible_menu == menu
|
if window.visible_menu == menu
|
||||||
|
@ -393,36 +417,6 @@ class Sidebar extends Class
|
||||||
if res == "ok"
|
if res == "ok"
|
||||||
wrapper.notifications.add "sign", "done", "#{inner_path} Signed and published!", 5000
|
wrapper.notifications.add "sign", "done", "#{inner_path} Signed and published!", 5000
|
||||||
|
|
||||||
@tag.find("#button-sign-publish-menu").removeClass("visible")
|
|
||||||
return false
|
|
||||||
|
|
||||||
# Sign content.json
|
|
||||||
@tag.find("#button-sign").off("click touchend").on "click touchend", =>
|
|
||||||
inner_path = @tag.find("#input-contents").val()
|
|
||||||
|
|
||||||
wrapper.ws.cmd "fileRules", {inner_path: inner_path}, (res) =>
|
|
||||||
if wrapper.site_info.privatekey or wrapper.site_info.auth_address in res.signers
|
|
||||||
# Privatekey stored in users.json
|
|
||||||
wrapper.ws.cmd "siteSign", {privatekey: "stored", inner_path: inner_path, update_changed_files: true}, (res) =>
|
|
||||||
if res == "ok"
|
|
||||||
wrapper.notifications.add "sign", "done", "#{inner_path} Signed!", 5000
|
|
||||||
|
|
||||||
else
|
|
||||||
# Ask the user for privatekey
|
|
||||||
wrapper.displayPrompt "Enter your private key:", "password", "Sign", "", (privatekey) => # Prompt the private key
|
|
||||||
wrapper.ws.cmd "siteSign", {privatekey: privatekey, inner_path: inner_path, update_changed_files: true}, (res) =>
|
|
||||||
if res == "ok"
|
|
||||||
wrapper.notifications.add "sign", "done", "#{inner_path} Signed!", 5000
|
|
||||||
|
|
||||||
@tag.find("#button-sign-publish-menu").removeClass("visible")
|
|
||||||
return false
|
|
||||||
|
|
||||||
# Publish content.json
|
|
||||||
@tag.find("#button-publish").off("click touchend").on "click touchend", =>
|
|
||||||
inner_path = @tag.find("#input-contents").val()
|
|
||||||
@tag.find("#button-publish").addClass "loading"
|
|
||||||
wrapper.ws.cmd "sitePublish", {"inner_path": inner_path, "sign": false}, =>
|
|
||||||
@tag.find("#button-publish").removeClass "loading"
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
# Close
|
# Close
|
||||||
|
|
|
@ -693,8 +693,54 @@ window.initScrollable = function () {
|
||||||
};
|
};
|
||||||
})(this));
|
})(this));
|
||||||
menu = new Menu(this.tag.find("#wrapper-sign-publish"));
|
menu = new Menu(this.tag.find("#wrapper-sign-publish"));
|
||||||
menu.addItem("Sign");
|
menu.addItem("Sign", (function(_this) {
|
||||||
menu.addItem("Publush");
|
return function() {
|
||||||
|
var inner_path;
|
||||||
|
inner_path = _this.tag.find("#input-contents").val();
|
||||||
|
wrapper.ws.cmd("fileRules", {
|
||||||
|
inner_path: inner_path
|
||||||
|
}, function(res) {
|
||||||
|
var ref;
|
||||||
|
if (wrapper.site_info.privatekey || (ref = wrapper.site_info.auth_address, indexOf.call(res.signers, ref) >= 0)) {
|
||||||
|
return wrapper.ws.cmd("siteSign", {
|
||||||
|
privatekey: "stored",
|
||||||
|
inner_path: inner_path,
|
||||||
|
update_changed_files: true
|
||||||
|
}, function(res) {
|
||||||
|
if (res === "ok") {
|
||||||
|
return wrapper.notifications.add("sign", "done", inner_path + " Signed!", 5000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return wrapper.displayPrompt("Enter your private key:", "password", "Sign", "", function(privatekey) {
|
||||||
|
return wrapper.ws.cmd("siteSign", {
|
||||||
|
privatekey: privatekey,
|
||||||
|
inner_path: inner_path,
|
||||||
|
update_changed_files: true
|
||||||
|
}, function(res) {
|
||||||
|
if (res === "ok") {
|
||||||
|
return wrapper.notifications.add("sign", "done", inner_path + " Signed!", 5000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
_this.tag.find(".contents + .flex").removeClass("active");
|
||||||
|
return menu.hide();
|
||||||
|
};
|
||||||
|
})(this));
|
||||||
|
menu.addItem("Publish", (function(_this) {
|
||||||
|
return function() {
|
||||||
|
var inner_path;
|
||||||
|
inner_path = _this.tag.find("#input-contents").val();
|
||||||
|
wrapper.ws.cmd("sitePublish", {
|
||||||
|
"inner_path": inner_path,
|
||||||
|
"sign": false
|
||||||
|
});
|
||||||
|
_this.tag.find(".contents + .flex").removeClass("active");
|
||||||
|
return menu.hide();
|
||||||
|
};
|
||||||
|
})(this));
|
||||||
this.tag.find("#menu-sign-publish").off("click touchend").on("click touchend", (function(_this) {
|
this.tag.find("#menu-sign-publish").off("click touchend").on("click touchend", (function(_this) {
|
||||||
return function() {
|
return function() {
|
||||||
if (window.visible_menu === menu) {
|
if (window.visible_menu === menu) {
|
||||||
|
@ -745,57 +791,6 @@ window.initScrollable = function () {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_this.tag.find("#button-sign-publish-menu").removeClass("visible");
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
})(this));
|
|
||||||
this.tag.find("#button-sign").off("click touchend").on("click touchend", (function(_this) {
|
|
||||||
return function() {
|
|
||||||
var inner_path;
|
|
||||||
inner_path = _this.tag.find("#input-contents").val();
|
|
||||||
wrapper.ws.cmd("fileRules", {
|
|
||||||
inner_path: inner_path
|
|
||||||
}, function(res) {
|
|
||||||
var ref;
|
|
||||||
if (wrapper.site_info.privatekey || (ref = wrapper.site_info.auth_address, indexOf.call(res.signers, ref) >= 0)) {
|
|
||||||
return wrapper.ws.cmd("siteSign", {
|
|
||||||
privatekey: "stored",
|
|
||||||
inner_path: inner_path,
|
|
||||||
update_changed_files: true
|
|
||||||
}, function(res) {
|
|
||||||
if (res === "ok") {
|
|
||||||
return wrapper.notifications.add("sign", "done", inner_path + " Signed!", 5000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return wrapper.displayPrompt("Enter your private key:", "password", "Sign", "", function(privatekey) {
|
|
||||||
return wrapper.ws.cmd("siteSign", {
|
|
||||||
privatekey: privatekey,
|
|
||||||
inner_path: inner_path,
|
|
||||||
update_changed_files: true
|
|
||||||
}, function(res) {
|
|
||||||
if (res === "ok") {
|
|
||||||
return wrapper.notifications.add("sign", "done", inner_path + " Signed!", 5000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
_this.tag.find("#button-sign-publish-menu").removeClass("visible");
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
})(this));
|
|
||||||
this.tag.find("#button-publish").off("click touchend").on("click touchend", (function(_this) {
|
|
||||||
return function() {
|
|
||||||
var inner_path;
|
|
||||||
inner_path = _this.tag.find("#input-contents").val();
|
|
||||||
_this.tag.find("#button-publish").addClass("loading");
|
|
||||||
wrapper.ws.cmd("sitePublish", {
|
|
||||||
"inner_path": inner_path,
|
|
||||||
"sign": false
|
|
||||||
}, function() {
|
|
||||||
return _this.tag.find("#button-publish").removeClass("loading");
|
|
||||||
});
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
})(this));
|
})(this));
|
||||||
|
|
Loading…
Reference in a new issue