Add WEBAPP_URL var

pull/2376/head
saneery 5 years ago
parent c09766e792
commit 60be9a8a5f
  1. 3
      apps/block_scout_web/config/config.exs
  2. 2
      apps/block_scout_web/lib/block_scout_web/templates/layout/_footer.html.eex
  3. 2
      apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex
  4. 19
      apps/block_scout_web/lib/block_scout_web/views/layout_view.ex

@ -28,7 +28,8 @@ config :block_scout_web,
"EtherChain" => "https://www.etherchain.org/", "EtherChain" => "https://www.etherchain.org/",
"Bloxy" => "https://bloxy.info/" "Bloxy" => "https://bloxy.info/"
}, },
other_networks: System.get_env("SUPPORTED_CHAINS") other_networks: System.get_env("SUPPORTED_CHAINS"),
webapp_url: System.get_env("WEBAPP_URL")
config :block_scout_web, BlockScoutWeb.Counters.BlocksIndexedCounter, enabled: true config :block_scout_web, BlockScoutWeb.Counters.BlocksIndexedCounter, enabled: true

@ -3,7 +3,7 @@
<!-- Logo --> <!-- Logo -->
<div class="row footer-logo-row"> <div class="row footer-logo-row">
<div class="col-md-12"> <div class="col-md-12">
<%= link to: chain_path(@conn, :show), class: "footer-brand" do %> <%= link to: webapp_url(@conn), class: "footer-brand" do %>
<img class="footer-logo" src="<%= logo_footer() %>" alt="<%= subnetwork_title() %>" /> <img class="footer-logo" src="<%= logo_footer() %>" alt="<%= subnetwork_title() %>" />
<% end %> <% end %>
</div> </div>

@ -5,7 +5,7 @@
} }
</script> </script>
<div class="container-fluid navbar-container"> <div class="container-fluid navbar-container">
<%= link to: chain_path(@conn, :show), class: "navbar-brand", "data-test": "header_logo" do %> <%= link to: webapp_url(@conn), class: "navbar-brand", "data-test": "header_logo" do %>
<img class="navbar-logo" id="navbar-logo" src="<%= logo() %>" alt="<%= subnetwork_title() %>" /> <img class="navbar-logo" id="navbar-logo" src="<%= logo() %>" alt="<%= subnetwork_title() %>" />
<% end %> <% end %>
<script> <script>

@ -228,4 +228,23 @@ defmodule BlockScoutWeb.LayoutView do
[] []
end end
end end
defp webapp_url(conn) do
:block_scout_web
|> Application.get_env(:webapp_url)
|> validate_url()
|> case do
:error -> chain_path(conn, :show)
url -> url
end
end
defp validate_url(url) when is_binary(url) do
case URI.parse(url) do
%URI{host: nil} -> :error
_ -> {:ok, url}
end
end
defp validate_url(_), do: :error
end end

Loading…
Cancel
Save