asciinema.org/web/controllers/doc_controller.ex
Marcin Kulik ace1d58167 Port docs
2017-06-02 15:40:24 +02:00

28 lines
675 B
Elixir

defmodule Asciinema.DocController do
use Asciinema.Web, :controller
alias Asciinema.{DocView, ErrorView}
@topics ["how-it-works", "getting-started", "installation", "usage", "config", "embedding", "faq"]
def index(conn, _params) do
redirect conn, to: doc_path(conn, :show, :"getting-started")
end
def show(conn, %{"topic" => topic}) when topic in @topics do
topic = String.to_atom(topic)
conn
|> assign(:topic, topic)
|> assign(:page_title, DocView.title_for(topic))
|> put_layout(:docs)
|> render("#{topic}.html")
end
def show(conn, _params) do
conn
|> put_status(404)
|> render(ErrorView, "404.html")
end
end