Add QR code library and address QR code controller

pull/232/head
Tim Mecklem 7 years ago
parent fec4f5cedb
commit 14fa5a3911
  1. 7
      apps/explorer_web/lib/explorer_web/controllers/address_qr_code_controller.ex
  2. 2
      apps/explorer_web/lib/explorer_web/router.ex
  3. 2
      apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex
  4. 3
      apps/explorer_web/mix.exs
  5. 1
      mix.lock

@ -0,0 +1,7 @@
defmodule ExplorerWeb.AddressQRCodeController do
use ExplorerWeb, :controller
def index(conn, %{"address_id" => id}) do
send_download(conn, {:binary, QRCode.to_png(id)}, "content-type": "image/png", filename: "#{id}.png")
end
end

@ -80,6 +80,8 @@ defmodule ExplorerWeb.Router do
only: [:index],
as: :contract
)
resources("/qrcode", AddressQRCodeController, only: [:index], as: :qr_code)
end
get("/search", ChainController, :search)

@ -69,7 +69,7 @@
<button class="btn btn-primary" data-clipboard-text="<%= @address %>">Copy</button>
</div>
</div>
<img src="http://via.placeholder.com/300x300" alt="qr_code">
<%= img_tag(address_qr_code_path(@conn, :index, @conn.assigns.locale, @address), alt: "qr_code") %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>

@ -94,7 +94,8 @@ defmodule ExplorerWeb.Mixfile do
{:sobelow, ">= 0.0.0", only: [:dev, :test], runtime: false},
{:timex, "~> 3.1.24"},
{:timex_ecto, "~> 3.2.1"},
{:wallaby, "~> 0.20", only: [:test], runtime: false}
{:wallaby, "~> 0.20", only: [:test], runtime: false},
{:qrcode, "~> 0.1.0"}
]
end

@ -58,6 +58,7 @@
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], [], "hexpm"},
"postgrex": {:hex, :postgrex, "0.13.5", "3d931aba29363e1443da167a4b12f06dcd171103c424de15e5f3fc2ba3e6d9c5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm"},
"qrcode": {:hex, :qrcode, "0.1.1", "9ca0d512a3c69a07d28e7660b046f8f3d835ef5462063814a7639a27302f7213", [:mix], [], "hexpm"},
"ranch": {:hex, :ranch, "1.3.2", "e4965a144dc9fbe70e5c077c65e73c57165416a901bd02ea899cfd95aa890986", [:rebar3], [], "hexpm"},
"redix": {:hex, :redix, "0.6.1", "20986b0e02f02b13e6f53c79a1ae70aa83147488c408f40275ec261f5bb0a6d0", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"},
"redix_pubsub": {:hex, :redix_pubsub, "0.4.1", "26e6a69129072ac2226be49139019bdf951bb1e9e210a773c1372acf88100936", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:redix, "~> 0.6.0", [hex: :redix, repo: "hexpm", optional: false]}], "hexpm"},

Loading…
Cancel
Save