From 5820652ac1c34bd33b290655cce9313f58063936 Mon Sep 17 00:00:00 2001 From: Akshit Garg Date: Wed, 16 Feb 2022 16:30:30 +0530 Subject: [PATCH 1/2] feat: add support for custom page titles Also put the paste ID in the title for the show page --- lib/ketbin_web/controllers/page_controller.ex | 3 ++- lib/ketbin_web/templates/layout/app.html.heex | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ketbin_web/controllers/page_controller.ex b/lib/ketbin_web/controllers/page_controller.ex index 08c8485..d3d6d76 100644 --- a/lib/ketbin_web/controllers/page_controller.ex +++ b/lib/ketbin_web/controllers/page_controller.ex @@ -28,7 +28,8 @@ defmodule KetbinWeb.PageController do render(conn, "show.html", paste: paste, show_edit: show_edit, - extension: List.first(tail) || "" + extension: List.first(tail) || "", + page_title: paste.id ) end end diff --git a/lib/ketbin_web/templates/layout/app.html.heex b/lib/ketbin_web/templates/layout/app.html.heex index f9aacb8..3efa2b5 100644 --- a/lib/ketbin_web/templates/layout/app.html.heex +++ b/lib/ketbin_web/templates/layout/app.html.heex @@ -4,7 +4,11 @@ - Katbin + <%= if Map.has_key?(assigns, :page_title) do %> + Katbin - <%= @page_title %> + <% else %> + Katbin + <% end %> From bec57794fa4b5d04168991210e370aa452b8cf5e Mon Sep 17 00:00:00 2001 From: Akshit Garg Date: Wed, 16 Feb 2022 16:37:05 +0530 Subject: [PATCH 2/2] feat: add paste id for showlink --- lib/ketbin_web/controllers/page_controller.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ketbin_web/controllers/page_controller.ex b/lib/ketbin_web/controllers/page_controller.ex index d3d6d76..7ada750 100644 --- a/lib/ketbin_web/controllers/page_controller.ex +++ b/lib/ketbin_web/controllers/page_controller.ex @@ -41,7 +41,8 @@ defmodule KetbinWeb.PageController do render(conn, "show.html", paste: paste, show_edit: show_edit, - extension: if(tail == [], do: "", else: tail) + extension: if(tail == [], do: "", else: tail), + page_title: paste.id ) end