new base
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user