Create metatags to the Root page

pull/858/head
Felipe Renan 6 years ago
parent 101d49f547
commit 3085edf6bd
  1. 5
      apps/block_scout_web/lib/block_scout_web/templates/chain/_metatags.html.eex
  2. 3
      apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex
  3. 2
      apps/block_scout_web/lib/block_scout_web/views/chain_view.ex
  4. 6
      apps/block_scout_web/lib/block_scout_web/views/layout_view.ex
  5. 16
      apps/block_scout_web/test/block_scout_web/views/layout_view_test.exs

@ -0,0 +1,5 @@
<title>
<%= gettext("%{subnetwork} %{network} Explorer", subnetwork: LayoutView.subnetwork_title(), network: LayoutView.network_title()) %>
</title>
<meta name="description" content="<%= gettext "BlockScout provides analytics data, API, and Smart Contract tools for the %{subnetwork}", subnetwork: LayoutView.subnetwork_title() %>">
<meta name="keywords" content="BlockScout, blockchain, api, analytics, address, smart contract">

@ -4,7 +4,6 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><%= app_title() %></title>
<link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
<link rel="apple-touch-icon" sizes="180x180" href="<%= static_path(@conn, "/apple-touch-icon.png") %>">
@ -16,6 +15,8 @@
<meta name="msapplication-TileColor" content="#7dd79f">
<meta name="msapplication-config" content="<%= static_path(@conn, "/browserconfig.xml") %>">
<meta name="theme-color" content="#ffffff">
<%= render_existing(@view_module, "_metatags.html") %>
</head>
<body>

@ -1,6 +1,8 @@
defmodule BlockScoutWeb.ChainView do
use BlockScoutWeb, :view
alias BlockScoutWeb.LayoutView
def encode_market_history_data(market_history_data) do
market_history_data
|> Enum.map(fn day -> Map.take(day, [:closing_price, :date]) end)

@ -15,10 +15,8 @@ defmodule BlockScoutWeb.LayoutView do
Keyword.get(application_config(), :subnetwork) || "Sokol Testnet"
end
def app_title do
network_title = Keyword.get(application_config(), :network) || "POA"
gettext("%{subnetwork} %{network} Explorer", subnetwork: subnetwork_title(), network: network_title)
def network_title do
Keyword.get(application_config(), :network) || "POA"
end
defp application_config do

@ -49,21 +49,15 @@ defmodule BlockScoutWeb.LayoutViewTest do
end
end
describe "app_title/0" do
test "use the enviroment subnetwork title when it's configured" do
Application.put_env(:block_scout_web, BlockScoutWeb.Chain, subnetwork: "Subnetwork Test")
assert LayoutView.app_title() == "Subnetwork Test POA Explorer"
end
describe "network_title/0" do
test "use the enviroment network title when it's configured" do
Application.put_env(:block_scout_web, BlockScoutWeb.Chain, network: "Custom")
Application.put_env(:block_scout_web, BlockScoutWeb.Chain, network: "Custom Network")
assert LayoutView.app_title() == "Sokol Testnet Custom Explorer"
assert LayoutView.network_title() == "Custom Network"
end
test "use the default subnetwork title when there is no env configured for it" do
assert LayoutView.app_title() == "Sokol Testnet POA Explorer"
test "use the default network title when there is no env configured for it" do
assert LayoutView.network_title() == "POA"
end
end
end

Loading…
Cancel
Save