parent
49eee16ee1
commit
cd201e83dc
@ -0,0 +1,13 @@ |
||||
defmodule BlockScoutWeb.RobotsController do |
||||
use BlockScoutWeb, :controller |
||||
|
||||
def robots(conn, _params) do |
||||
conn |
||||
|> render("robots.txt") |
||||
end |
||||
|
||||
def sitemap(conn, _params) do |
||||
conn |
||||
|> render("sitemap.xml") |
||||
end |
||||
end |
@ -0,0 +1,53 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<% host = APIDocsView.blockscout_url(true) %> |
||||
<% date = to_string(Date.utc_today()) %> |
||||
<% non_parameterized_urls = ["/", "/txs", "/blocks", "/accounts", "/verified-contracts", "/tokens", "/apps", "/stats", "/api-docs", "/graphiql", "/search-results", "/withdrawals", "/l2-deposits", "/l2-output-roots", "/l2-txn-batches", "/l2-withdrawals"] %> |
||||
<% params = [paging_options: %PagingOptions{page_size: limit()}] %> |
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> |
||||
<%= for url <- non_parameterized_urls do %> |
||||
<url> |
||||
<loc><%= host %><%= url %></loc> |
||||
<lastmod><%= date %></lastmod> |
||||
</url> |
||||
<% end %> |
||||
|
||||
<% addresses = Chain.list_top_addresses(params) %> |
||||
<%= for {address, _} <- addresses do %> |
||||
<url> |
||||
<loc><%= host %>/address/<%= to_string(address) %></loc> |
||||
<lastmod><%= date %></lastmod> |
||||
</url> |
||||
<% end %> |
||||
|
||||
<% txs = Chain.recent_transactions(params, [:validated]) %> |
||||
<%= for tx <- txs do %> |
||||
<url> |
||||
<loc><%= host %>/tx/<%= to_string(tx.hash) %></loc> |
||||
<lastmod><%= date %></lastmod> |
||||
</url> |
||||
<% end %> |
||||
|
||||
<% blocks = Chain.list_blocks(params) %> |
||||
<%= for block <- blocks do %> |
||||
<url> |
||||
<loc><%= host %>/block/<%= to_string(block.number) %></loc> |
||||
<lastmod><%= date %></lastmod> |
||||
</url> |
||||
<% end %> |
||||
|
||||
<% tokens = Chain.list_top_tokens(nil, params) %> |
||||
<%= for token <- tokens do %> |
||||
<url> |
||||
<loc><%= host %>/token/<%= to_string(token.contract_address_hash) %></loc> |
||||
<lastmod><%= date %></lastmod> |
||||
</url> |
||||
<% end %> |
||||
|
||||
<% smart_contracts_hashes = Chain.verified_contracts_top(limit()) %> |
||||
<%= for hash <- smart_contracts_hashes do %> |
||||
<url> |
||||
<loc><%= host %>/address/<%= Address.checksum(hash) %>?tab=contract</loc> |
||||
<lastmod><%= date %></lastmod> |
||||
</url> |
||||
<% end %> |
||||
</urlset> |
@ -0,0 +1,10 @@ |
||||
defmodule BlockScoutWeb.RobotsView do |
||||
use BlockScoutWeb, :view |
||||
|
||||
alias BlockScoutWeb.APIDocsView |
||||
alias Explorer.{Chain, PagingOptions} |
||||
alias Explorer.Chain.Address |
||||
|
||||
@limit 200 |
||||
defp limit, do: @limit |
||||
end |
Loading…
Reference in new issue