Simple realisation

This commit is contained in:
Ivanq 2017-12-30 17:43:56 +03:00
parent 92e353be40
commit 7121a96ebd
5 changed files with 117 additions and 6 deletions

View file

@ -428,9 +428,15 @@ class UiWebsocketPlugin(object):
body.append(_(u""" body.append(_(u"""
<div class='flex'> <div class='flex'>
<input type='text' class='text' value="content.json" id='input-contents'/> <input type='text' class='text' value="content.json" id='input-contents'/>
<a href='#Sign' class='button' id='button-sign'>{_[Sign]}</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> <a href='#Publish' class='button' id='button-publish'>{_[Publish]}</a>
</div> </div>
</span>
</div>
</li> </li>
""")) """))

View file

@ -354,6 +354,33 @@ class Sidebar extends Class
@updateHtmlTag() @updateHtmlTag()
return false 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 # Sign content.json
@tag.find("#button-sign").off("click touchend").on "click touchend", => @tag.find("#button-sign").off("click touchend").on "click touchend", =>
inner_path = @tag.find("#input-contents").val() inner_path = @tag.find("#input-contents").val()
@ -372,6 +399,7 @@ class Sidebar extends Class
if res == "ok" if res == "ok"
wrapper.notifications.add "sign", "done", "#{inner_path} Signed!", 5000 wrapper.notifications.add "sign", "done", "#{inner_path} Signed!", 5000
@tag.find("#button-sign-publish-menu").removeClass("visible")
return false return false
# Publish content.json # Publish content.json

View file

@ -112,7 +112,7 @@
#checkbox-owned { margin-bottom: 25px; margin-top: 26px; margin-left: 11px; } #checkbox-owned { margin-bottom: 25px; margin-top: 26px; margin-left: 11px; }
.settings-owned { clear: both } .settings-owned { clear: both }
#checkbox-owned ~ .settings-owned { opacity: 0; max-height: 0px; transition: all 0.3s linear; overflow: hidden } #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 */
.globe { width: 360px; height: 360px } .globe { width: 360px; height: 360px }
@ -124,6 +124,39 @@
.contents a { color: white } .contents a { color: white }
.contents a:active { background-color: #6B6B6B } .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 */ /* Small screen */
@media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
.sidebar .close { display: block } .sidebar .close { display: block }

View file

@ -166,7 +166,7 @@
#checkbox-owned { margin-bottom: 25px; margin-top: 26px; margin-left: 11px; } #checkbox-owned { margin-bottom: 25px; margin-top: 26px; margin-left: 11px; }
.settings-owned { clear: both } .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 ~ .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 */
.globe { width: 360px; height: 360px } .globe { width: 360px; height: 360px }
@ -178,6 +178,39 @@
.contents a { color: white } .contents a { color: white }
.contents a:active { background-color: #6B6B6B } .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 */ /* Small screen */
@media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
.sidebar .close { display: block } .sidebar .close { display: block }

View file

@ -234,8 +234,7 @@ window.initScrollable = function () {
@logStart("Preloading") @logStart("Preloading")
wrapper.ws.cmd "sidebarGetHtmlTag", {}, (res) => wrapper.ws.cmd "sidebarGetHtmlTag", {}, (res) =>
@logEnd("Preloading") @logEnd("Preloading")
@preload_html = res @preload_html = res */
*/
this.fixbutton.on("mousedown touchstart", (function(_this) { this.fixbutton.on("mousedown touchstart", (function(_this) {
return function(e) { return function(e) {
if (e.button > 0) { if (e.button > 0) {
@ -607,6 +606,17 @@ window.initScrollable = function () {
return false; return false;
}; };
})(this)); })(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) { this.tag.find("#button-sign").off("click touchend").on("click touchend", (function(_this) {
return function() { return function() {
var inner_path; var inner_path;
@ -639,6 +649,7 @@ window.initScrollable = function () {
}); });
} }
}); });
_this.tag.find("#button-sign-publish-menu").removeClass("visible");
return false; return false;
}; };
})(this)); })(this));