This commit is contained in:
2024-06-02 13:31:19 +02:00
parent 9d547bcdf2
commit 443081e086
67 changed files with 623 additions and 4282 deletions

View File

@ -1,33 +1,9 @@
defmodule SomethingErlangWeb.PageController do
use SomethingErlangWeb, :controller
def home(conn, params) do
def home(conn, _params) do
# The home page is often custom made,
# so skip the default app layout.
conn = assign(conn, :params, params)
render(conn, :home)
end
def to_forum_path(conn, %{"forum_path" => path} = _params) do
{redirect_good, thread, page} =
case {
Regex.run(~r{threadid=(\d+)}, path),
Regex.run(~r{pagenumber=(\d+)}, path)
} do
{[_, thread], nil} -> {:ok, thread, 1}
{[_, thread], [_, page]} -> {:ok, thread, page}
_ -> {:error, nil, nil}
end
if redirect_good == :ok do
redirect(conn, to: ~p"/thread/#{thread}?page=#{page}")
else
put_flash(conn, :error, "Could not resolve URL")
render(conn, :home)
end
end
def to_forum_path(conn, _params) do
render(conn, :home)
render(conn, :home, layout: false)
end
end