defmodule OpenpodWeb.PageController do
  use OpenpodWeb, :controller

  Application.ensure_all_started(:hackney)

  @base_url Application.get_env(:openpod, :base_url)

  @podders Application.get_env(:openpod, :podders)
           |> Enum.map(fn podcast ->
             Openpod.Provider.Archive.Parser.by_identifier(podcast)
             |> Map.get(:podcast)
             |> Map.put(:podcast_url, "#{@base_url}/podcast/#{podcast}")
           end)

  def index(conn, _params) do
    render(conn, "index.html")
  end

  def howto(conn, _params) do
    render(conn, "howto.html")
  end

  def chi(conn, _params) do
    render(conn, "chi.html", podders: @podders)
  end
end
