diff --git a/config/config.exs b/config/config.exs
index 536831a15b..82a29aa98e 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -68,10 +68,6 @@ config :phoenix, :generators,
migration: true,
binary_id: false
-config :scrivener_html,
- routes_helper: ChangelogWeb.Router.Helpers,
- view_style: :semantic
-
config :mime, :types, %{"application/javascript" => ["js"], "application/xml" => ["xml"]}
config :shopify,
diff --git a/lib/changelog_web.ex b/lib/changelog_web.ex
index 5fb36d4d1e..044dd106ec 100644
--- a/lib/changelog_web.ex
+++ b/lib/changelog_web.ex
@@ -63,8 +63,9 @@ defmodule ChangelogWeb do
quote do
use Phoenix.View, root: "lib/changelog_web/templates", namespace: ChangelogWeb
use Phoenix.HTML
+
import Phoenix.Controller, only: [get_flash: 1, get_flash: 2, view_module: 1]
- import Scrivener.HTML
+
alias ChangelogWeb.Router.Helpers, as: Routes
alias ChangelogWeb.Helpers.{AdminHelpers, SharedHelpers}
alias Changelog.Policies
diff --git a/lib/changelog_web/templates/admin/episode/index.html.eex b/lib/changelog_web/templates/admin/episode/index.html.eex
index 31c590be77..04775058da 100644
--- a/lib/changelog_web/templates/admin/episode/index.html.eex
+++ b/lib/changelog_web/templates/admin/episode/index.html.eex
@@ -63,6 +63,6 @@
<%= render("_table.html", Map.merge(assigns, %{status: :published, podcast: @podcast, episodes: @episodes, actions: false})) %>
- <%= pagination_links(@conn, @page, [@podcast.slug], path: &Routes.admin_podcast_episode_path/4) %>
+ <%= render(SharedView, "_pagination.html", assigns) %>
<% end %>
diff --git a/lib/changelog_web/templates/admin/membership/index.html.heex b/lib/changelog_web/templates/admin/membership/index.html.heex
index 34484bdf6f..50308c990c 100644
--- a/lib/changelog_web/templates/admin/membership/index.html.heex
+++ b/lib/changelog_web/templates/admin/membership/index.html.heex
@@ -18,5 +18,5 @@
<%= render("_table.html", assigns) %>
- <%= pagination_links(@conn, @page, path: &Routes.admin_membership_path/3, filter: @filter) %>
+ <%= render(SharedView, "_pagination.html", assigns) %>
diff --git a/lib/changelog_web/templates/admin/news_issue/index.html.eex b/lib/changelog_web/templates/admin/news_issue/index.html.eex
index a2c4b443ae..a66ae4423b 100644
--- a/lib/changelog_web/templates/admin/news_issue/index.html.eex
+++ b/lib/changelog_web/templates/admin/news_issue/index.html.eex
@@ -41,6 +41,6 @@
<%= render("_table.html", conn: @conn, issues: @issues) %>
- <%= pagination_links(@conn, @page, path: &Routes.admin_news_source_path/3) %>
+ <%= render(SharedView, "_pagination.html", assigns) %>
<% end %>
diff --git a/lib/changelog_web/templates/admin/news_item/index.html.eex b/lib/changelog_web/templates/admin/news_item/index.html.eex
index a4b5243de2..eb9aa670ba 100644
--- a/lib/changelog_web/templates/admin/news_item/index.html.eex
+++ b/lib/changelog_web/templates/admin/news_item/index.html.eex
@@ -52,6 +52,6 @@
<%= if Enum.any?(@published) do %>
<%= render("_table.html", Map.merge(assigns, %{status: :published, items: @published})) %>
- <%= pagination_links(@conn, @page, path: &Routes.admin_news_item_path/3) %>
+ <%= render(SharedView, "_pagination.html", assigns) %>
<% end %>
diff --git a/lib/changelog_web/templates/admin/news_item_comment/index.html.eex b/lib/changelog_web/templates/admin/news_item_comment/index.html.eex
index 432c7e632e..181bb237e9 100644
--- a/lib/changelog_web/templates/admin/news_item_comment/index.html.eex
+++ b/lib/changelog_web/templates/admin/news_item_comment/index.html.eex
@@ -11,6 +11,6 @@
<%= if Enum.any?(@comments) do %>
<%= render("_table.html", conn: @conn, comments: @comments) %>
- <%= pagination_links @conn, @page, path: &Routes.admin_news_item_comment_path/3 %>
+ <%= render(SharedView, "_pagination.html", assigns) %>
<% end %>
diff --git a/lib/changelog_web/templates/admin/news_item_subscription/index.html.eex b/lib/changelog_web/templates/admin/news_item_subscription/index.html.eex
index 4f70908f97..33db33b5d2 100644
--- a/lib/changelog_web/templates/admin/news_item_subscription/index.html.eex
+++ b/lib/changelog_web/templates/admin/news_item_subscription/index.html.eex
@@ -55,6 +55,6 @@
- <%= pagination_links(@conn, @page, [@item], path: &Routes.admin_news_item_subscription_path/4) %>
+ <%= render(SharedView, "_pagination.html", assigns) %>
<% end %>
diff --git a/lib/changelog_web/templates/admin/news_source/index.html.eex b/lib/changelog_web/templates/admin/news_source/index.html.eex
index c1c32f28ec..27d1d25295 100644
--- a/lib/changelog_web/templates/admin/news_source/index.html.eex
+++ b/lib/changelog_web/templates/admin/news_source/index.html.eex
@@ -33,6 +33,6 @@
<%= if Enum.any?(@sources) do %>
<%= render("_table.html", conn: @conn, sources: @sources) %>
- <%= pagination_links(@conn, @page, path: &Routes.admin_news_source_path/3) %>
+ <%= render(SharedView, "_pagination.html", assigns) %>
<% end %>
diff --git a/lib/changelog_web/templates/admin/news_sponsorship/index.html.eex b/lib/changelog_web/templates/admin/news_sponsorship/index.html.eex
index 054e125c6c..2bde394bcd 100644
--- a/lib/changelog_web/templates/admin/news_sponsorship/index.html.eex
+++ b/lib/changelog_web/templates/admin/news_sponsorship/index.html.eex
@@ -22,6 +22,6 @@
<%= if Enum.any?(@sponsorships) do %>
<%= render("_table.html", conn: @conn, sponsorships: @sponsorships) %>
- <%= pagination_links(@conn, @page, path: &Routes.admin_news_sponsorship_path/3) %>
+ <%= render(SharedView, "_pagination.html", assigns) %>
<% end %>
diff --git a/lib/changelog_web/templates/admin/person/comments.html.eex b/lib/changelog_web/templates/admin/person/comments.html.eex
index e03dcabeb2..ef84a2480d 100644
--- a/lib/changelog_web/templates/admin/person/comments.html.eex
+++ b/lib/changelog_web/templates/admin/person/comments.html.eex
@@ -10,5 +10,5 @@
<%= render(NewsItemCommentView, "_table.html", Map.merge(assigns, %{comments: @comments})) %>
- <%= pagination_links(@conn, @page, [@person], path: &Routes.admin_person_path/4, action: :comments) %>
+ <%= render(SharedView, "_pagination.html", assigns) %>
diff --git a/lib/changelog_web/templates/admin/person/index.html.eex b/lib/changelog_web/templates/admin/person/index.html.heex
similarity index 87%
rename from lib/changelog_web/templates/admin/person/index.html.eex
rename to lib/changelog_web/templates/admin/person/index.html.heex
index b98ca73ab1..332e73e997 100644
--- a/lib/changelog_web/templates/admin/person/index.html.eex
+++ b/lib/changelog_web/templates/admin/person/index.html.heex
@@ -19,6 +19,6 @@
<%= if Enum.any?(@people) do %>
<%= render("_table.html", assigns) %>
- <%= pagination_links(@conn, @page, path: &Routes.admin_person_path/3, filter: @filter) %>
+ <%= render(SharedView, "_pagination.html", assigns) %>
<% end %>
diff --git a/lib/changelog_web/templates/admin/person/news.html.eex b/lib/changelog_web/templates/admin/person/news.html.eex
index cdf2e23171..b4e3546b7d 100644
--- a/lib/changelog_web/templates/admin/person/news.html.eex
+++ b/lib/changelog_web/templates/admin/person/news.html.eex
@@ -10,5 +10,5 @@
<%= render(NewsItemView, "_table.html", Map.merge(assigns, %{status: :published, items: @published})) %>
- <%= pagination_links(@conn, @page, [@person], path: &Routes.admin_person_path/4, action: :news) %>
+ <%= render(SharedView, "_pagination.html", assigns) %>
diff --git a/lib/changelog_web/templates/admin/podcast_subscription/index.html.heex b/lib/changelog_web/templates/admin/podcast_subscription/index.html.heex
index b06eecef27..f9bfb49615 100644
--- a/lib/changelog_web/templates/admin/podcast_subscription/index.html.heex
+++ b/lib/changelog_web/templates/admin/podcast_subscription/index.html.heex
@@ -76,6 +76,6 @@
- <%= pagination_links(@conn, @page, [@podcast.slug], path: &Routes.admin_podcast_subscription_path/4) %>
+ <%= render(SharedView, "_pagination.html", assigns) %>
<% end %>
diff --git a/lib/changelog_web/templates/admin/post/index.html.eex b/lib/changelog_web/templates/admin/post/index.html.eex
index 4649d8238a..422c5c1812 100644
--- a/lib/changelog_web/templates/admin/post/index.html.eex
+++ b/lib/changelog_web/templates/admin/post/index.html.eex
@@ -28,6 +28,6 @@
<%= if Enum.any?(@posts) do %>
<%= render("_table.html", Map.merge(assigns, %{conn: @conn, status: :published, posts: @posts})) %>
- <%= pagination_links(@conn, @page, path: &Routes.admin_post_path/3) %>
+ <%= render(SharedView, "_pagination.html", assigns) %>
<% end %>
diff --git a/lib/changelog_web/templates/admin/shared/_pagination.html.heex b/lib/changelog_web/templates/admin/shared/_pagination.html.heex
new file mode 100644
index 0000000000..8dec743129
--- /dev/null
+++ b/lib/changelog_web/templates/admin/shared/_pagination.html.heex
@@ -0,0 +1,15 @@
+<%= if @page.total_pages > 1 do %>
+
+<% end %>
diff --git a/lib/changelog_web/views/admin/episode_view.ex b/lib/changelog_web/views/admin/episode_view.ex
index d2a7227fcd..e2df14b389 100644
--- a/lib/changelog_web/views/admin/episode_view.ex
+++ b/lib/changelog_web/views/admin/episode_view.ex
@@ -3,7 +3,7 @@ defmodule ChangelogWeb.Admin.EpisodeView do
alias Changelog.{Episode, Person, Podcast, Sponsor, StringKit, Topic}
alias ChangelogWeb.{EpisodeView, PersonView, TimeView}
- alias ChangelogWeb.Admin.{EpisodeRequestView, PodcastView}
+ alias ChangelogWeb.Admin.{EpisodeRequestView, PodcastView, SharedView}
def audio_filename(episode), do: EpisodeView.audio_filename(episode)
def plusplus_filename(episode), do: EpisodeView.plusplus_filename(episode)
diff --git a/lib/changelog_web/views/admin/membership_view.ex b/lib/changelog_web/views/admin/membership_view.ex
index c6991d5c55..56b700ae4e 100644
--- a/lib/changelog_web/views/admin/membership_view.ex
+++ b/lib/changelog_web/views/admin/membership_view.ex
@@ -2,6 +2,7 @@ defmodule ChangelogWeb.Admin.MembershipView do
use ChangelogWeb, :admin_view
alias ChangelogWeb.PersonView
+ alias ChangelogWeb.Admin.SharedView
def last_changed_at(membership) do
if membership.updated_at > membership.inserted_at do
diff --git a/lib/changelog_web/views/admin/news_item_comment_view.ex b/lib/changelog_web/views/admin/news_item_comment_view.ex
index c91de18014..d54bcedff3 100644
--- a/lib/changelog_web/views/admin/news_item_comment_view.ex
+++ b/lib/changelog_web/views/admin/news_item_comment_view.ex
@@ -3,6 +3,7 @@ defmodule ChangelogWeb.Admin.NewsItemCommentView do
alias Changelog.NewsItem
alias ChangelogWeb.{NewsItemCommentView, PersonView}
+ alias ChangelogWeb.Admin.SharedView
def permalink(conn, comment) do
Routes.news_item_path(conn, :show, NewsItem.slug(comment.news_item)) <>
diff --git a/lib/changelog_web/views/admin/news_item_subscription_view.ex b/lib/changelog_web/views/admin/news_item_subscription_view.ex
index 9475de5b41..401608d365 100644
--- a/lib/changelog_web/views/admin/news_item_subscription_view.ex
+++ b/lib/changelog_web/views/admin/news_item_subscription_view.ex
@@ -3,4 +3,5 @@ defmodule ChangelogWeb.Admin.NewsItemSubscriptionView do
alias Changelog.{NewsItem, Subscription}
alias ChangelogWeb.PersonView
+ alias ChangelogWeb.Admin.SharedView
end
diff --git a/lib/changelog_web/views/admin/news_item_view.ex b/lib/changelog_web/views/admin/news_item_view.ex
index 34cb774f1e..224003c100 100644
--- a/lib/changelog_web/views/admin/news_item_view.ex
+++ b/lib/changelog_web/views/admin/news_item_view.ex
@@ -3,6 +3,7 @@ defmodule ChangelogWeb.Admin.NewsItemView do
alias Changelog.{NewsItem, NewsSource, Person, Topic}
alias ChangelogWeb.{Endpoint, PersonView, NewsItemView}
+ alias ChangelogWeb.Admin.SharedView
def bookmarklet_code do
url = Routes.admin_news_item_url(Endpoint, :new, quick: true, url: "")
diff --git a/lib/changelog_web/views/admin/news_source_view.ex b/lib/changelog_web/views/admin/news_source_view.ex
index 1f0763c147..9aef4b95a1 100644
--- a/lib/changelog_web/views/admin/news_source_view.ex
+++ b/lib/changelog_web/views/admin/news_source_view.ex
@@ -2,6 +2,7 @@ defmodule ChangelogWeb.Admin.NewsSourceView do
use ChangelogWeb, :admin_view
alias ChangelogWeb.NewsSourceView
+ alias ChangelogWeb.Admin.SharedView
def icon_url(source), do: NewsSourceView.icon_url(source)
end
diff --git a/lib/changelog_web/views/admin/news_sponsorship_view.ex b/lib/changelog_web/views/admin/news_sponsorship_view.ex
index 37d1465358..a1aee36747 100644
--- a/lib/changelog_web/views/admin/news_sponsorship_view.ex
+++ b/lib/changelog_web/views/admin/news_sponsorship_view.ex
@@ -3,7 +3,7 @@ defmodule ChangelogWeb.Admin.NewsSponsorshipView do
alias Changelog.{ListKit, NewsAd, NewsSponsorship, Sponsor}
alias ChangelogWeb.{Endpoint, TimeView}
- alias ChangelogWeb.Admin.{NewsAdView}
+ alias ChangelogWeb.Admin.{NewsAdView, SharedView}
def active_ads(sponsorship), do: Enum.filter(sponsorship.ads, & &1.active)
def inactive_ads(sponsorship), do: Enum.reject(sponsorship.ads, & &1.active)
diff --git a/lib/changelog_web/views/admin/person_view.ex b/lib/changelog_web/views/admin/person_view.ex
index c96259c573..87481bda1a 100644
--- a/lib/changelog_web/views/admin/person_view.ex
+++ b/lib/changelog_web/views/admin/person_view.ex
@@ -3,7 +3,7 @@ defmodule ChangelogWeb.Admin.PersonView do
alias Changelog.Person
alias ChangelogWeb.PersonView
- alias ChangelogWeb.Admin.{EpisodeView, EpisodeRequestView, FeedView, NewsItemView, NewsItemCommentView}
+ alias ChangelogWeb.Admin.{EpisodeView, EpisodeRequestView, FeedView, NewsItemView, NewsItemCommentView, SharedView}
def avatar_url(person), do: PersonView.avatar_url(person)
diff --git a/lib/changelog_web/views/admin/podcast_subscription_view.ex b/lib/changelog_web/views/admin/podcast_subscription_view.ex
index f29c803b3a..024df48ee2 100644
--- a/lib/changelog_web/views/admin/podcast_subscription_view.ex
+++ b/lib/changelog_web/views/admin/podcast_subscription_view.ex
@@ -3,6 +3,7 @@ defmodule ChangelogWeb.Admin.PodcastSubscriptionView do
alias Changelog.Subscription
alias ChangelogWeb.PersonView
+ alias ChangelogWeb.Admin.SharedView
def chart_data(podcast) do
this_month = Timex.today() |> Timex.beginning_of_month()
diff --git a/lib/changelog_web/views/admin/post_view.ex b/lib/changelog_web/views/admin/post_view.ex
index 507fa61650..951247f509 100644
--- a/lib/changelog_web/views/admin/post_view.ex
+++ b/lib/changelog_web/views/admin/post_view.ex
@@ -3,6 +3,7 @@ defmodule ChangelogWeb.Admin.PostView do
alias Changelog.{Post, Topic}
alias ChangelogWeb.PostView
+ alias ChangelogWeb.Admin.SharedView
def image_url(post, version), do: PostView.image_url(post, version)
diff --git a/lib/changelog_web/views/admin/shared_view.ex b/lib/changelog_web/views/admin/shared_view.ex
new file mode 100644
index 0000000000..947d5a8468
--- /dev/null
+++ b/lib/changelog_web/views/admin/shared_view.ex
@@ -0,0 +1,22 @@
+defmodule ChangelogWeb.Admin.SharedView do
+ use ChangelogWeb, :admin_view
+
+ def pagination_link_classes(paginator, page_number) do
+ if paginator.page_number == page_number do
+ "active item"
+ else
+ "item"
+ end
+ end
+
+
+ @doc"""
+ Constructs a pagination path for the given page, extracting relevant
+ path params [filter, action] from the connection to construct said path
+ """
+ def pagination_path(conn, page) do
+ scopes = [:filter, :action]
+ params = Map.merge(%{page: page}, Map.take(conn.assigns, scopes))
+ SharedHelpers.current_path(conn, params)
+ end
+end
diff --git a/mix.exs b/mix.exs
index b81b3fb6fd..7089cee306 100644
--- a/mix.exs
+++ b/mix.exs
@@ -52,7 +52,6 @@ defmodule Changelog.Mixfile do
{:oban_web, "~> 2.10.2", repo: "oban", only: @oban_envs},
{:timex, "~> 3.0"},
{:scrivener_ecto, "~> 2.0"},
- {:scrivener_html, "~> 1.8", github: "jerodsanto/scrivener_html", branch: "phx-1-7"},
{:cmark, "~> 0.6"},
{:floki, "~> 0.35.2"},
{:waffle_ecto, "~> 0.0"},