From da16bd48d8b2ab4455c4fafc76114870293a93a9 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Fri, 6 Dec 2019 13:06:54 -0500 Subject: [PATCH] misc fixes --- lib/philomena_web/controllers/page/history_controller.ex | 6 +++--- lib/philomena_web/router.ex | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/philomena_web/controllers/page/history_controller.ex b/lib/philomena_web/controllers/page/history_controller.ex index 822b8873..975dce17 100644 --- a/lib/philomena_web/controllers/page/history_controller.ex +++ b/lib/philomena_web/controllers/page/history_controller.ex @@ -6,12 +6,12 @@ defmodule PhilomenaWeb.Page.HistoryController do alias Philomena.Repo import Ecto.Query - plug :load_resource, model: StaticPage, id_field: "slug", persisted: true + plug :load_resource, model: StaticPage, id_name: "page_id", nid_field: "slug", persisted: true def index(conn, _params) do page = conn.assigns.static_page - versions = + {versions, _last_body} = Version |> where(static_page_id: ^page.id) |> preload(:user) @@ -26,7 +26,7 @@ defmodule PhilomenaWeb.Page.HistoryController do Enum.map_reduce(pages, current_body, fn page, previous_body -> difference = List.myers_difference(split(previous_body), split(page.body)) - %{page | difference: difference} + {%{page | difference: difference}, page.body} end) end diff --git a/lib/philomena_web/router.ex b/lib/philomena_web/router.ex index ff38a85f..f5d5653f 100644 --- a/lib/philomena_web/router.ex +++ b/lib/philomena_web/router.ex @@ -214,7 +214,9 @@ defmodule PhilomenaWeb.Router do resources "/reports", Gallery.ReportController, only: [:new, :create] end resources "/adverts", AdvertController, only: [:show] - resources "/pages", PageController, only: [:show] + resources "/pages", PageController, only: [:show] do + resources "/history", Page.HistoryController, only: [:index] + end resources "/dnp", DnpEntryController, only: [:index, :show] resources "/staff", StaffController, only: [:index] resources "/stats", StatController, only: [:index]