Simple realisation
This commit is contained in:
parent
92e353be40
commit
7121a96ebd
5 changed files with 117 additions and 6 deletions
|
@ -428,8 +428,14 @@ class UiWebsocketPlugin(object):
|
|||
body.append(_(u"""
|
||||
<div class='flex'>
|
||||
<input type='text' class='text' value="content.json" id='input-contents'/>
|
||||
<a href='#Sign' class='button' id='button-sign'>{_[Sign]}</a>
|
||||
<a href='#Publish' class='button' id='button-publish'>{_[Publish]}</a>
|
||||
<span href='#Sign-and-Publish' class='button' id='button-sign-publish'>
|
||||
{_[Sign and Publish]}
|
||||
<span id='button-sign-publish-arrow'>v</span>
|
||||
<div id='button-sign-publish-menu'>
|
||||
<a href='#Sign' class='button' id='button-sign'>{_[Sign]}</a><br>
|
||||
<a href='#Publish' class='button' id='button-publish'>{_[Publish]}</a>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
"""))
|
||||
|
|
|
@ -354,6 +354,33 @@ class Sidebar extends Class
|
|||
@updateHtmlTag()
|
||||
return false
|
||||
|
||||
# Sign and publish content.json
|
||||
$(document).on "click touchend", =>
|
||||
@tag.find("#button-sign-publish-menu").removeClass("visible")
|
||||
@tag.find("#button-sign-publish-arrow").off("click touchend").on "click touchend", =>
|
||||
@tag.find("#button-sign-publish-menu").toggleClass("visible")
|
||||
return false
|
||||
|
||||
@tag.find("#button-sign-publish").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 "sitePublish", {privatekey: "stored", inner_path: inner_path, sign: true}, (res) =>
|
||||
if res == "ok"
|
||||
wrapper.notifications.add "sign", "done", "#{inner_path} Signed and published!", 5000
|
||||
|
||||
else
|
||||
# Ask the user for privatekey
|
||||
wrapper.displayPrompt "Enter your private key:", "password", "Sign", "", (privatekey) => # Prompt the private key
|
||||
wrapper.ws.cmd "sitePublish", {privatekey: privatekey, inner_path: inner_path, sign: true}, (res) =>
|
||||
if res == "ok"
|
||||
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()
|
||||
|
@ -372,6 +399,7 @@ class Sidebar extends Class
|
|||
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
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
#checkbox-owned { margin-bottom: 25px; margin-top: 26px; margin-left: 11px; }
|
||||
.settings-owned { clear: both }
|
||||
#checkbox-owned ~ .settings-owned { opacity: 0; max-height: 0px; transition: all 0.3s linear; overflow: hidden }
|
||||
#checkbox-owned:checked ~ .settings-owned { opacity: 1; max-height: 400px }
|
||||
#checkbox-owned:checked ~ .settings-owned { opacity: 1; max-height: 408px }
|
||||
|
||||
/* Globe */
|
||||
.globe { width: 360px; height: 360px }
|
||||
|
@ -124,6 +124,39 @@
|
|||
.contents a { color: white }
|
||||
.contents a:active { background-color: #6B6B6B }
|
||||
|
||||
.contents + .flex {
|
||||
padding-bottom: 65px;
|
||||
}
|
||||
#button-sign-publish {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
padding-left: 10px;
|
||||
color: #000;
|
||||
cursor: pointer;
|
||||
}
|
||||
#button-sign-publish-arrow {
|
||||
display: inline-block;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
||||
#button-sign-publish-menu {
|
||||
display: none;
|
||||
width: 100%;
|
||||
margin-top: 2px;
|
||||
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 100%;
|
||||
}
|
||||
#button-sign-publish-menu.visible {
|
||||
display: inline-block;
|
||||
}
|
||||
#button-sign-publish-menu a {
|
||||
width: 100%;
|
||||
margin-left: 0;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
/* Small screen */
|
||||
@media screen and (max-width: 600px) {
|
||||
.sidebar .close { display: block }
|
||||
|
|
|
@ -166,7 +166,7 @@
|
|||
#checkbox-owned { margin-bottom: 25px; margin-top: 26px; margin-left: 11px; }
|
||||
.settings-owned { clear: both }
|
||||
#checkbox-owned ~ .settings-owned { opacity: 0; max-height: 0px; -webkit-transition: all 0.3s linear; -moz-transition: all 0.3s linear; -o-transition: all 0.3s linear; -ms-transition: all 0.3s linear; transition: all 0.3s linear ; overflow: hidden }
|
||||
#checkbox-owned:checked ~ .settings-owned { opacity: 1; max-height: 400px }
|
||||
#checkbox-owned:checked ~ .settings-owned { opacity: 1; max-height: 408px }
|
||||
|
||||
/* Globe */
|
||||
.globe { width: 360px; height: 360px }
|
||||
|
@ -178,6 +178,39 @@
|
|||
.contents a { color: white }
|
||||
.contents a:active { background-color: #6B6B6B }
|
||||
|
||||
.contents + .flex {
|
||||
padding-bottom: 65px;
|
||||
}
|
||||
#button-sign-publish {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
padding-left: 10px;
|
||||
color: #000;
|
||||
cursor: pointer;
|
||||
}
|
||||
#button-sign-publish-arrow {
|
||||
display: inline-block;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
||||
#button-sign-publish-menu {
|
||||
display: none;
|
||||
width: 100%;
|
||||
margin-top: 2px;
|
||||
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 100%;
|
||||
}
|
||||
#button-sign-publish-menu.visible {
|
||||
display: inline-block;
|
||||
}
|
||||
#button-sign-publish-menu a {
|
||||
width: 100%;
|
||||
margin-left: 0;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
/* Small screen */
|
||||
@media screen and (max-width: 600px) {
|
||||
.sidebar .close { display: block }
|
||||
|
|
|
@ -234,8 +234,7 @@ window.initScrollable = function () {
|
|||
@logStart("Preloading")
|
||||
wrapper.ws.cmd "sidebarGetHtmlTag", {}, (res) =>
|
||||
@logEnd("Preloading")
|
||||
@preload_html = res
|
||||
*/
|
||||
@preload_html = res */
|
||||
this.fixbutton.on("mousedown touchstart", (function(_this) {
|
||||
return function(e) {
|
||||
if (e.button > 0) {
|
||||
|
@ -607,6 +606,17 @@ window.initScrollable = function () {
|
|||
return false;
|
||||
};
|
||||
})(this));
|
||||
$(document).on("click touchend", (function(_this) {
|
||||
return function() {
|
||||
return _this.tag.find("#button-sign-publish-menu").removeClass("visible");
|
||||
};
|
||||
})(this));
|
||||
this.tag.find("#button-sign-publish-arrow").off("click touchend").on("click touchend", (function(_this) {
|
||||
return function() {
|
||||
_this.tag.find("#button-sign-publish-menu").toggleClass("visible");
|
||||
return false;
|
||||
};
|
||||
})(this));
|
||||
this.tag.find("#button-sign").off("click touchend").on("click touchend", (function(_this) {
|
||||
return function() {
|
||||
var inner_path;
|
||||
|
@ -639,6 +649,7 @@ window.initScrollable = function () {
|
|||
});
|
||||
}
|
||||
});
|
||||
_this.tag.find("#button-sign-publish-menu").removeClass("visible");
|
||||
return false;
|
||||
};
|
||||
})(this));
|
||||
|
|
Loading…
Reference in a new issue