chore(styles): clean up unused styles
Signed-off-by: SphericalKat <amolele@gmail.com>
This commit is contained in:
2 files changed
+21
-53
No files matched your search
@@ -11,11 +11,11 @@ defmodule KetbinWeb.PageController do
|
||||
end
|
||||
|
||||
def show(conn, %{"id" => id}) do
|
||||
paste = Pastes.get_paste!(id)
|
||||
paste = Pastes.get_paste!(id) # fetch paste from db
|
||||
|
||||
if paste.is_url do
|
||||
if paste.is_url do # paste is a url, redirect
|
||||
redirect(conn, external: paste.content)
|
||||
else
|
||||
else # regular paste, show content
|
||||
render(conn, "show.html", paste: paste)
|
||||
end
|
||||
end
|
||||
@@ -26,27 +26,31 @@ defmodule KetbinWeb.PageController do
|
||||
end
|
||||
|
||||
def create(conn, %{"paste" => paste_params}) do
|
||||
# generate phonetic key
|
||||
id = Utils.generate_key()
|
||||
|
||||
# check if content is a url
|
||||
is_url =
|
||||
Map.get(paste_params, "content")
|
||||
|> Utils.is_url?()
|
||||
|
||||
# put id and is_url values into changeset
|
||||
paste_params =
|
||||
Map.put(paste_params, "id", id)
|
||||
|> Map.put("is_url", is_url)
|
||||
|
||||
# attempt to create a paste
|
||||
case Pastes.create_paste(paste_params) do
|
||||
{:ok, paste} ->
|
||||
{:ok, paste} -> # all good, redirect
|
||||
unless is_url do
|
||||
conn
|
||||
|> redirect(to: Routes.page_path(conn, :show, paste))
|
||||
|> redirect(to: Routes.page_path(conn, :show, paste)) # is a regular paste, take to regular route
|
||||
else
|
||||
conn
|
||||
|> redirect(to: Routes.page_path(conn, :showlink, paste))
|
||||
|> redirect(to: Routes.page_path(conn, :showlink, paste)) # is a url, take to route with /v/ prefix
|
||||
end
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
{:error, %Ecto.Changeset{} = changeset} -> # something went wrong, bail
|
||||
render(conn, "index.html", changeset: changeset)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user