Skip to content

Commit

Permalink
search by bitcoin address
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenische committed Feb 14, 2016
1 parent 3982de6 commit 34a7a89
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 2 deletions.
16 changes: 16 additions & 0 deletions app/controllers/addresses_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class AddressesController < ApplicationController

def index
@addresses = BitcoinAddress.all.page params[:page]

redirect_to address_path(params[:bitcoin_address]) if params[:bitcoin_address].present?
end

def show
@address = BitcoinAddress.find_by_bitcoin_address(params[:id])

if @address.blank?
redirect_to addresses_path, alert: "Sorry, bitcoin address '#{params[:id]}' is not found in the database"
end
end
end
19 changes: 19 additions & 0 deletions app/views/addresses/index.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- model_class = BitcoinAddress
- title "Bitcoin addresses"

h1 =t '.title', :default => model_class.model_name.human.pluralize.titleize

form.navbar-form role="search" action="#{addresses_path}" method="get"
.input-group
input.form-control type="text" placeholder="Go to bitcoin address..." name="bitcoin_address"
span.input-group-btn
button.btn.btn-default type="submit"
span.fa.fa-search aria-hidden="true"

div
- @addresses.each do |address|
div
| #{btc_human address.balance}:
= link_to address.bitcoin_address, address_path(address.bitcoin_address)

= paginate @addresses, :theme => 'twitter-bootstrap-3'
9 changes: 9 additions & 0 deletions app/views/addresses/show.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- title "Signed by #{@address.bitcoin_address}"
h1 #{@address.bitcoin_address}
.lead Balance: #{btc_human @address.balance}
.lead Statements signed:

ul
- @address.signatures.shuffle.each do |signature|
li.lead
= link_to signature.message, argument_path(signature.argument), class: (signature.negation? ? 'text-danger' : 'text-success')
2 changes: 1 addition & 1 deletion app/views/arguments/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
- addresses.each do |address|
tr
td
=address.bitcoin_address
=link_to address.bitcoin_address, address_path(address.bitcoin_address)
td
=btc_human address.balance

Expand Down
4 changes: 3 additions & 1 deletion app/views/layouts/application.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ html
= menu_group
= menu_item "Home", root_path
= menu_item t("arguments.index.new"), new_argument_path
/ = menu_item "Arguments", arguments_path
= menu_item t("addresses.index"), addresses_path

.container
- if flash[:error]
.error.bg-danger =h flash[:error]
- if flash[:alert]
.error.bg-danger =h flash[:alert]
- if flash[:notice]
.notice.bg-success =h flash[:notice]

Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ en:
index:
new: "Submit your Argument"
title: "Bitcoinocracy - vote with your Bitcoin signature"
addresses:
index: 'Bitcoin Addresses'
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
resources :signatures, except: [:edit, :update, :destroy]
end

resources :addresses


# Example resource route with options:
# resources :products do
Expand Down

0 comments on commit 34a7a89

Please sign in to comment.