From 7121a96ebde66a6d589333a14d571878333ced66 Mon Sep 17 00:00:00 2001 From: Ivanq Date: Sat, 30 Dec 2017 17:43:56 +0300 Subject: [PATCH] Simple realisation --- plugins/Sidebar/SidebarPlugin.py | 10 ++++++-- plugins/Sidebar/media/Sidebar.coffee | 28 ++++++++++++++++++++++ plugins/Sidebar/media/Sidebar.css | 35 +++++++++++++++++++++++++++- plugins/Sidebar/media/all.css | 35 +++++++++++++++++++++++++++- plugins/Sidebar/media/all.js | 15 ++++++++++-- 5 files changed, 117 insertions(+), 6 deletions(-) diff --git a/plugins/Sidebar/SidebarPlugin.py b/plugins/Sidebar/SidebarPlugin.py index bc0f22e2..888517a2 100644 --- a/plugins/Sidebar/SidebarPlugin.py +++ b/plugins/Sidebar/SidebarPlugin.py @@ -428,8 +428,14 @@ class UiWebsocketPlugin(object): body.append(_(u"""
- {_[Sign]} - {_[Publish]} + + {_[Sign and Publish]} + v + +
""")) diff --git a/plugins/Sidebar/media/Sidebar.coffee b/plugins/Sidebar/media/Sidebar.coffee index 9f891260..7fd1c7c0 100644 --- a/plugins/Sidebar/media/Sidebar.coffee +++ b/plugins/Sidebar/media/Sidebar.coffee @@ -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 diff --git a/plugins/Sidebar/media/Sidebar.css b/plugins/Sidebar/media/Sidebar.css index c76bde0c..a3eb9b67 100644 --- a/plugins/Sidebar/media/Sidebar.css +++ b/plugins/Sidebar/media/Sidebar.css @@ -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 } diff --git a/plugins/Sidebar/media/all.css b/plugins/Sidebar/media/all.css index baf9b94c..fa85d369 100644 --- a/plugins/Sidebar/media/all.css +++ b/plugins/Sidebar/media/all.css @@ -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 } diff --git a/plugins/Sidebar/media/all.js b/plugins/Sidebar/media/all.js index 0a54d46f..c7f408e6 100644 --- a/plugins/Sidebar/media/all.js +++ b/plugins/Sidebar/media/all.js @@ -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));