From 1ab6bde1797214f79defa5eedb8ebea391fd84bf Mon Sep 17 00:00:00 2001 From: Sam Cheng Hung Date: Sun, 5 Mar 2017 12:33:39 +0800 Subject: [PATCH 1/2] Adds signatures list --- app/assets/javascripts/navigation.js | 16 +++++++++- app/assets/stylesheets/built.css.scss | 23 +++++++++++++- app/views/arguments/show.html.slim | 33 +++++++++++++++++++++ styleguide/components/_bitcoin_address.scss | 1 + styleguide/components/_card.scss | 2 +- styleguide/components/_helpers.scss | 21 +++++++++++++ styleguide/components/_table.scss | 8 +++++ 7 files changed, 101 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/navigation.js b/app/assets/javascripts/navigation.js index 1ad4d44..c250455 100644 --- a/app/assets/javascripts/navigation.js +++ b/app/assets/javascripts/navigation.js @@ -6,6 +6,20 @@ $(document).ready(function() { }); $('.tooltipster').tooltipster({ - trigger: 'click' + trigger: 'click', + functionInit: function(instance, helper){ + + var $origin = $(helper.origin), + dataOptions = $origin.attr('data-tooltipster'); + + if(dataOptions){ + + dataOptions = JSON.parse(dataOptions); + + $.each(dataOptions, function(name, option){ + instance.option(name, option); + }); + } + } }); }); diff --git a/app/assets/stylesheets/built.css.scss b/app/assets/stylesheets/built.css.scss index 3f4d8b2..2d6e91b 100644 --- a/app/assets/stylesheets/built.css.scss +++ b/app/assets/stylesheets/built.css.scss @@ -1659,7 +1659,7 @@ Styleguide 2.5 */ .card { position: relative; - box-shadow: 0 0 10px #ccc; + box-shadow: 0 0 7px #ccc; /* Types */ } .card.text-center { text-align: center; } @@ -2517,6 +2517,10 @@ table { font-size: 0.8em; } table tbody td p + p { margin-top: 10px; } + table tbody td a { + text-decoration: none; } + table tbody td a:hover { + text-decoration: underline; } table.borderless tbody td { border: none; } @@ -2533,6 +2537,7 @@ markup: Styleguide 2.14 */ .bitcoin-address { + display: inline-block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; @@ -4639,6 +4644,22 @@ Styleguide 3.4 .tooltip_templates { display: none; } +.actions-on-hover .bitcoin-address { + vertical-align: middle; } + +.actions-on-hover .actions { + display: inline-block; + margin-left: 5px; + vertical-align: middle; + opacity: 0; + -webkit-transition: opacity 0.2s cubic-bezier(0.55, 0, 0.1, 1); + -moz-transition: opacity 0.2s cubic-bezier(0.55, 0, 0.1, 1); + transition: opacity 0.2s cubic-bezier(0.55, 0, 0.1, 1); + color: #AAA; } + +.actions-on-hover:hover .actions { + opacity: 1; } + /* Basic Components diff --git a/app/views/arguments/show.html.slim b/app/views/arguments/show.html.slim index 8f9e792..2065cc2 100644 --- a/app/views/arguments/show.html.slim +++ b/app/views/arguments/show.html.slim @@ -108,6 +108,39 @@ p= btc_human address.balance div#signature_status style='display:none' + + .section + .card-group.horizontal + .card.text-center + h3 Signatures (Believe) + .content + .section + .table-container + - [@argument.pro_signatures.order('signature')].each_with_index do |signatures| + table class="table borderless" + - signatures.each do |signature| + tr + td + p.bitcoin-address= link_to signature.bitcoin_address.try(:bitcoin_address), address_path(signature.bitcoin_address.try(:bitcoin_address)) + td.actions-on-hover + p.bitcoin-address= signature.signature + span.actions + span.icon.icon-info-circled.tooltipster title="#{signature.signature}" data-tooltipster='{"interactive":true}' + .card.text-center + h3 Signatures (Doubt) + .content + .section + .table-container + - [@argument.con_signatures.order('signature')].each_with_index do |signatures| + table class="table borderless" + - signatures.each do |signature| + tr + td + p.bitcoin-address= link_to signature.bitcoin_address.try(:bitcoin_address), address_path(signature.bitcoin_address.try(:bitcoin_address)) + td.actions-on-hover + p.bitcoin-address= signature.signature + span.actions + span.icon.icon-info-circled.tooltipster title="#{signature.signature}" data-tooltipster='{"interactive":true}' input type='hidden' name='pro_statement' id='pro_statement' value=@argument.pro_statement input type='hidden' name='con_statement' id='con_statement' value=@argument.con_statement diff --git a/styleguide/components/_bitcoin_address.scss b/styleguide/components/_bitcoin_address.scss index d6140f0..ddc04cf 100644 --- a/styleguide/components/_bitcoin_address.scss +++ b/styleguide/components/_bitcoin_address.scss @@ -8,6 +8,7 @@ Styleguide 2.14 */ .bitcoin-address { + display: inline-block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; diff --git a/styleguide/components/_card.scss b/styleguide/components/_card.scss index c054d54..8925d27 100644 --- a/styleguide/components/_card.scss +++ b/styleguide/components/_card.scss @@ -21,7 +21,7 @@ Styleguide 2.5 */ .card { position: relative; - box-shadow: 0 0 10px #ccc; + box-shadow: 0 0 7px #ccc; &.text-center { text-align: center; diff --git a/styleguide/components/_helpers.scss b/styleguide/components/_helpers.scss index d447811..87c3947 100644 --- a/styleguide/components/_helpers.scss +++ b/styleguide/components/_helpers.scss @@ -5,3 +5,24 @@ .tooltip_templates { display: none; } + +.actions-on-hover { + .bitcoin-address { + vertical-align: middle; + } + + .actions { + display: inline-block; + margin-left: 5px; + vertical-align: middle; + opacity: 0; + transition: opacity 0.2s $easing; + color: #AAA; + } + + &:hover { + .actions { + opacity: 1; + } + } +} diff --git a/styleguide/components/_table.scss b/styleguide/components/_table.scss index b25bf84..ff55d98 100644 --- a/styleguide/components/_table.scss +++ b/styleguide/components/_table.scss @@ -56,6 +56,14 @@ table { margin-top: 10px; } } + + a { + text-decoration: none; + + &:hover { + text-decoration: underline; + } + } } } From 22d4347396fbd90983d55f98bdd610d221971c4f Mon Sep 17 00:00:00 2001 From: Arsen Gasparyan Date: Mon, 6 Mar 2017 03:16:48 +0500 Subject: [PATCH 2/2] vote-35: display signatures upon click; and provide link to the JSON with all the signatures --- app/models/bitcoin_address.rb | 4 ++ app/models/signature.rb | 6 +- app/views/arguments/_signatures.html.slim | 15 +++++ app/views/arguments/show.html.slim | 82 +++++------------------ 4 files changed, 42 insertions(+), 65 deletions(-) create mode 100644 app/views/arguments/_signatures.html.slim diff --git a/app/models/bitcoin_address.rb b/app/models/bitcoin_address.rb index 0ba058d..9569509 100644 --- a/app/models/bitcoin_address.rb +++ b/app/models/bitcoin_address.rb @@ -26,4 +26,8 @@ def update_balance end end + def to_s + bitcoin_address + end + end diff --git a/app/models/signature.rb b/app/models/signature.rb index 9d5e26c..958ec85 100644 --- a/app/models/signature.rb +++ b/app/models/signature.rb @@ -33,7 +33,11 @@ def create_bitcoin_address_if_needed self.bitcoin_address_id = btc_addr.id end end - end + end + end + + def to_s + signature end end diff --git a/app/views/arguments/_signatures.html.slim b/app/views/arguments/_signatures.html.slim new file mode 100644 index 0000000..3712b56 --- /dev/null +++ b/app/views/arguments/_signatures.html.slim @@ -0,0 +1,15 @@ +.card.text-center + h3 #{btc_human(bitcoin_value)} #{percent_human(percentage)} #{word} + .content + .section + .table-container + table class="table borderless" + - signatures.each do |s| + tr.actions-on-hover + td + p.bitcoin-address= link_to s.bitcoin_address, address_path(s.bitcoin_address) + td + p= btc_human(s.bitcoin_address.balance) + td + span.actions + span.icon.icon-info-circled.tooltipster title="Signature: #{s}" data-tooltipster='{"interactive":true}' diff --git a/app/views/arguments/show.html.slim b/app/views/arguments/show.html.slim index 2065cc2..a04838a 100644 --- a/app/views/arguments/show.html.slim +++ b/app/views/arguments/show.html.slim @@ -29,11 +29,11 @@ =button_tag "Submit", class:"button" .section .alert.transparent - | Warning: + | Warning: a href="https://www.reddit.com/r/btc/comments/4mhjh3/psa_bitcoinocracycom_signatures_expose_your/" rel="nofollow" target="_blank" Bitcoin signatures expose your public keys - | (that shouldn't be a problem until + | (that shouldn't be a problem until a href="https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm" rel="nofollow" target="_blank" ECDSA - | is broken). Moreover address reuse with a faulty random number generator + | is broken). Moreover address reuse with a faulty random number generator a href="http://www.nilsschneider.net/2013/01/28/recovering-bitcoin-private-keys.html" rel="nofollow" target="_blank" may leak your private keys |. =hidden_field("signature", "negation", {value: @is_doubt, autocomplete: false}) @@ -60,7 +60,7 @@ - if @argument.pros_sum > 0 && @argument.cons_sum > 0 && @argument.pros_sum == @argument.cons_sum h3 This proposition is currently tied. p Vote now by signing with your bitcoin signature above. - + .button-group.center a.button href="https://forum.bitcoin.com/bitcoin-discussion/" Discuss this proposition .section @@ -76,71 +76,25 @@ / .argument-score / .bar.positive style="flex-basis: #{percent_human(@argument.pros_share)};"= percent_human(@argument.pros_share) / .bar.negative style="flex-basis: #{percent_human(@argument.cons_share)};"= percent_human(@argument.cons_share) - + - if @argument.pros_sum > 0 && @argument.cons_sum > 0 .section .card-group.horizontal - .card.text-center - h3 #{btc_human(@argument.pros_sum)} #{percent_human(@argument.pros_share)} Believe - .content - .section - .table-container - - [@argument.pros].each_with_index do |addresses, i| - table class="table borderless #{i==0 ? 'bg-success' : 'bg-danger'}" - - addresses.each do |address| - tr - td - p.bitcoin-address= link_to address.bitcoin_address, address_path(address.bitcoin_address) - td - p= btc_human address.balance - .card.text-center - h3 #{btc_human(@argument.cons_sum)} #{percent_human(@argument.cons_share)} Doubt - .content - .section - .table-container - - [@argument.cons].each_with_index do |addresses, i| - table class="table borderless #{i==0 ? 'bg-success' : 'bg-danger'}" - - addresses.each do |address| - tr - td - p.bitcoin-address= link_to address.bitcoin_address, address_path(address.bitcoin_address) - td - p= btc_human address.balance + = render partial: 'signatures', locals: { \ + signatures: @argument.pro_signatures, \ + bitcoin_value: @argument.pros_sum, \ + percentage: @argument.pros_share, \ + word: "Believe" } + + = render partial: 'signatures', locals: { \ + signatures: @argument.con_signatures, \ + bitcoin_value: @argument.cons_sum, \ + percentage: @argument.cons_share, \ + word: "Doubt" } div#signature_status style='display:none' - - .section - .card-group.horizontal - .card.text-center - h3 Signatures (Believe) - .content - .section - .table-container - - [@argument.pro_signatures.order('signature')].each_with_index do |signatures| - table class="table borderless" - - signatures.each do |signature| - tr - td - p.bitcoin-address= link_to signature.bitcoin_address.try(:bitcoin_address), address_path(signature.bitcoin_address.try(:bitcoin_address)) - td.actions-on-hover - p.bitcoin-address= signature.signature - span.actions - span.icon.icon-info-circled.tooltipster title="#{signature.signature}" data-tooltipster='{"interactive":true}' - .card.text-center - h3 Signatures (Doubt) - .content - .section - .table-container - - [@argument.con_signatures.order('signature')].each_with_index do |signatures| - table class="table borderless" - - signatures.each do |signature| - tr - td - p.bitcoin-address= link_to signature.bitcoin_address.try(:bitcoin_address), address_path(signature.bitcoin_address.try(:bitcoin_address)) - td.actions-on-hover - p.bitcoin-address= signature.signature - span.actions - span.icon.icon-info-circled.tooltipster title="#{signature.signature}" data-tooltipster='{"interactive":true}' + + small =link_to "All signatures as JSON", argument_path(@argument, :json) input type='hidden' name='pro_statement' id='pro_statement' value=@argument.pro_statement input type='hidden' name='con_statement' id='con_statement' value=@argument.con_statement