feat(pastes): add raw paste handler
Signed-off-by: SphericalKat <amolele@gmail.com>
This commit is contained in:
parent
40b55e47de
commit
75ac6be3a6
@ -20,7 +20,7 @@ defmodule Ketbin.Pastes.Utils do
|
||||
def is_url?(url) do
|
||||
try do
|
||||
uri = URI.parse(url)
|
||||
uri.scheme != nil && uri.host =~ "." && Enum.member?(["https", "http"], uri.scheme)
|
||||
uri.scheme != nil && uri.host =~ "." && Enum.member?(["https", "http", "mailto"], uri.scheme) && !(uri.host =~ "katb.in")
|
||||
rescue
|
||||
FunctionClauseError -> false
|
||||
end
|
||||
|
@ -25,6 +25,11 @@ defmodule KetbinWeb.PageController do
|
||||
render(conn, "show.html", paste: paste)
|
||||
end
|
||||
|
||||
def raw(conn, %{"id" => id}) do
|
||||
paste = Pastes.get_paste!(id)
|
||||
text(conn, paste.content)
|
||||
end
|
||||
|
||||
def create(conn, %{"paste" => paste_params}) do
|
||||
# generate phonetic key
|
||||
id = Utils.generate_key()
|
||||
|
@ -17,10 +17,11 @@ defmodule KetbinWeb.Router do
|
||||
end
|
||||
|
||||
scope "/", KetbinWeb do
|
||||
pipe_through :browser
|
||||
pipe_through [:browser, :fetch_current_user]
|
||||
|
||||
get "/", PageController, :index
|
||||
get "/:id", PageController, :show
|
||||
get "/:id/raw", PageController, :raw
|
||||
get "/v/:id", PageController, :showlink
|
||||
post "/", PageController, :create
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user