create gists
This commit is contained in:
parent
79a17290d5
commit
43a8412f06
90 changed files with 1777 additions and 2107 deletions
|
|
@ -1,6 +1,5 @@
|
|||
defmodule ZoeyscomputerWeb.Router do
|
||||
require Logger
|
||||
alias ExAws.S3
|
||||
use ZoeyscomputerWeb, :router
|
||||
|
||||
import ZoeyscomputerWeb.UserAuth
|
||||
|
|
@ -29,9 +28,11 @@ defmodule ZoeyscomputerWeb.Router do
|
|||
pipe_through :api
|
||||
|
||||
resources "/images", ImageController, except: [:create, :edit]
|
||||
resources "/gists", GistController, except: [:new, :edit]
|
||||
|
||||
pipe_through [:api_authentication]
|
||||
post "/images/create", ImageController, :create
|
||||
post "/gists/create", GistController, :create
|
||||
end
|
||||
|
||||
# Enable LiveDashboard and Swoosh mailbox preview in development
|
||||
|
|
@ -77,15 +78,17 @@ defmodule ZoeyscomputerWeb.Router do
|
|||
on_mount: [{ZoeyscomputerWeb.UserAuth, :ensure_authenticated}] do
|
||||
live "/users/settings", UserSettingsLive, :edit
|
||||
live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email
|
||||
live "/links", LinkLive.Index
|
||||
live "/links/new", LinkLive.New
|
||||
|
||||
live "/images/new", ImageLive.Index, :new
|
||||
live "/gists/new", GistLive.Index, :new
|
||||
live "/images/:id/edit", ImageLive.Index, :edit
|
||||
live "/gists/:id/edit", GistLive.Index, :edit
|
||||
|
||||
live "/images", ImageLive.Index, :index
|
||||
live "/gists", GistLive.Index
|
||||
|
||||
live "/images/:id/show/edit", ImageLive.Show, :edit
|
||||
live "/gists/:id/show/edit", GistLive.Show, :edit
|
||||
|
||||
live "/api-keys", ApiKeyLive.Index, :index
|
||||
live "/api-keys/new", ApiKeyLive.Index, :new
|
||||
|
|
@ -108,27 +111,7 @@ defmodule ZoeyscomputerWeb.Router do
|
|||
live "/", HomeLive, :index
|
||||
|
||||
live "/images/:id", ImageLive.Show, :show
|
||||
end
|
||||
end
|
||||
|
||||
scope "/", ZoeyscomputerWeb do
|
||||
pipe_through [:browser, :require_authenticated_user]
|
||||
end
|
||||
|
||||
defp download_from_s3(bucket, key) do
|
||||
case S3.get_object(bucket, key) |> ExAws.request() do
|
||||
{:ok, %{body: image_binary, headers: headers}} ->
|
||||
content_type =
|
||||
Enum.find_value(headers, fn
|
||||
{"Content-Type", value} -> value
|
||||
{"content-type", value} -> value
|
||||
_ -> nil
|
||||
end)
|
||||
|
||||
{:ok, image_binary, content_type || "application/octet-stream"}
|
||||
|
||||
error ->
|
||||
error
|
||||
live "/gists/:id", GistLive.Show, :show
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue