From c6c54347a70ca1a233fab1d078b724abcbf206b1 Mon Sep 17 00:00:00 2001 From: SphericalKat Date: Fri, 13 Aug 2021 05:47:13 +0530 Subject: [PATCH] feat(pastes): add page to view pastes Signed-off-by: SphericalKat --- assets/css/app.css | 9 ++++++++- assets/tailwind.config.js | 1 + lib/ketbin_web/controllers/page_controller.ex | 8 ++++++++ lib/ketbin_web/router.ex | 1 + lib/ketbin_web/templates/layout/app.html.eex | 2 +- lib/ketbin_web/templates/page/show.html.eex | 4 ++++ 6 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 lib/ketbin_web/templates/page/show.html.eex diff --git a/assets/css/app.css b/assets/css/app.css index ca93e32..b02fd29 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -6,7 +6,6 @@ * { font-family: 'JetBrains Mono', monospace; - background-color: #1a1a1a; color: white; } @@ -14,6 +13,14 @@ a:hover { @apply text-amber; } +html, body { + width: 100%; + height: 100%; +} + +header { + background-color: #1a1a1a +} @import "./phoenix.css"; diff --git a/assets/tailwind.config.js b/assets/tailwind.config.js index 5b0b724..cb0e1dd 100644 --- a/assets/tailwind.config.js +++ b/assets/tailwind.config.js @@ -10,6 +10,7 @@ module.exports = { extend: { colors: { amber: '#ff9800', + 'light-grey': '#212121', }, }, }, diff --git a/lib/ketbin_web/controllers/page_controller.ex b/lib/ketbin_web/controllers/page_controller.ex index 032a5f7..bf07d89 100644 --- a/lib/ketbin_web/controllers/page_controller.ex +++ b/lib/ketbin_web/controllers/page_controller.ex @@ -1,7 +1,15 @@ defmodule KetbinWeb.PageController do use KetbinWeb, :controller + alias Ketbin.Pastes + alias Ketbin.Pastes.Paste + def index(conn, _params) do render(conn, "index.html") end + + def show(conn, %{"id" => id}) do + paste = Pastes.get_paste!(id) + render(conn, "show.html", paste: paste) + end end diff --git a/lib/ketbin_web/router.ex b/lib/ketbin_web/router.ex index fc3d630..42d978a 100644 --- a/lib/ketbin_web/router.ex +++ b/lib/ketbin_web/router.ex @@ -20,6 +20,7 @@ defmodule KetbinWeb.Router do pipe_through :browser get "/", PageController, :index + get "/:id", PageController, :show end # Other scopes may use custom stacks. diff --git a/lib/ketbin_web/templates/layout/app.html.eex b/lib/ketbin_web/templates/layout/app.html.eex index 80d008b..4ab9ab3 100644 --- a/lib/ketbin_web/templates/layout/app.html.eex +++ b/lib/ketbin_web/templates/layout/app.html.eex @@ -31,7 +31,7 @@ -
+
<%= @inner_content %> diff --git a/lib/ketbin_web/templates/page/show.html.eex b/lib/ketbin_web/templates/page/show.html.eex new file mode 100644 index 0000000..e21465c --- /dev/null +++ b/lib/ketbin_web/templates/page/show.html.eex @@ -0,0 +1,4 @@ + +
+	<%= @paste.content %>
+