mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 21:47:59 +01:00
misc fixes
This commit is contained in:
parent
b56485f13a
commit
da16bd48d8
2 changed files with 6 additions and 4 deletions
|
@ -6,12 +6,12 @@ defmodule PhilomenaWeb.Page.HistoryController do
|
||||||
alias Philomena.Repo
|
alias Philomena.Repo
|
||||||
import Ecto.Query
|
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
|
def index(conn, _params) do
|
||||||
page = conn.assigns.static_page
|
page = conn.assigns.static_page
|
||||||
|
|
||||||
versions =
|
{versions, _last_body} =
|
||||||
Version
|
Version
|
||||||
|> where(static_page_id: ^page.id)
|
|> where(static_page_id: ^page.id)
|
||||||
|> preload(:user)
|
|> preload(:user)
|
||||||
|
@ -26,7 +26,7 @@ defmodule PhilomenaWeb.Page.HistoryController do
|
||||||
Enum.map_reduce(pages, current_body, fn page, previous_body ->
|
Enum.map_reduce(pages, current_body, fn page, previous_body ->
|
||||||
difference = List.myers_difference(split(previous_body), split(page.body))
|
difference = List.myers_difference(split(previous_body), split(page.body))
|
||||||
|
|
||||||
%{page | difference: difference}
|
{%{page | difference: difference}, page.body}
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,9 @@ defmodule PhilomenaWeb.Router do
|
||||||
resources "/reports", Gallery.ReportController, only: [:new, :create]
|
resources "/reports", Gallery.ReportController, only: [:new, :create]
|
||||||
end
|
end
|
||||||
resources "/adverts", AdvertController, only: [:show]
|
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 "/dnp", DnpEntryController, only: [:index, :show]
|
||||||
resources "/staff", StaffController, only: [:index]
|
resources "/staff", StaffController, only: [:index]
|
||||||
resources "/stats", StatController, only: [:index]
|
resources "/stats", StatController, only: [:index]
|
||||||
|
|
Loading…
Reference in a new issue