mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 14:17:59 +01:00
forums pagination
This commit is contained in:
parent
3a8176b47a
commit
94f521e99c
5 changed files with 15 additions and 12 deletions
|
@ -27,8 +27,7 @@ defmodule PhilomenaWeb.ForumController do
|
|||
|> where(hidden_from_users: false)
|
||||
|> order_by(desc: :sticky, desc: :last_replied_to_at)
|
||||
|> preload([:poll, :forum, :user, last_post: :user])
|
||||
|> limit(25)
|
||||
|> Repo.all()
|
||||
|> Repo.paginate(page: conn.assigns.scrivener)
|
||||
|
||||
render(conn, "show.html", forum: conn.assigns.forum, topics: topics)
|
||||
end
|
||||
|
|
|
@ -22,8 +22,7 @@ defmodule PhilomenaWeb.TopicController do
|
|||
|> where(topic_id: ^conn.assigns.topic.id)
|
||||
|> order_by(asc: :created_at)
|
||||
|> preload([:user, topic: :forum])
|
||||
|> limit(25)
|
||||
|> Repo.all()
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
||||
render(conn, "show.html", posts: posts)
|
||||
end
|
||||
|
|
|
@ -31,5 +31,6 @@ defmodule PhilomenaWeb.Plugs.Pagination do
|
|||
|
||||
conn
|
||||
|> assign(:pagination, %{page_number: page_number, page_size: page_size})
|
||||
|> assign(:scrivener, [page: page_number, page_size: page_size])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @topics, route: fn p -> Routes.forum_path(@conn, :show, @forum, p) end
|
||||
|
||||
h1 = @forum.name
|
||||
.block
|
||||
.block__header
|
||||
|
@ -10,8 +12,7 @@ h1 = @forum.name
|
|||
=> @forum.topic_count
|
||||
' topics
|
||||
.block__header--sub.block__header--light
|
||||
/- if @forum.topic_count >= Topic.topics_per_page do
|
||||
/ = paginate @topics
|
||||
= pagination
|
||||
span.block__header__title = @forum.description
|
||||
/- if current_user
|
||||
/ = subscription_link(@forum, current_user)
|
||||
|
@ -50,9 +51,8 @@ h1 = @forum.name
|
|||
= render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: topic.last_post
|
||||
br
|
||||
=> pretty_time(topic.last_post.created_at)
|
||||
/= if @forum.topic_count >= Topic.topics_per_page do
|
||||
/ .block__header.block__header--light
|
||||
/ = paginate @topics
|
||||
.block__header.block__header--light
|
||||
= pagination
|
||||
|
||||
/- if current_user
|
||||
/ = render partial: 'topics/form'
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @posts, route: fn p -> Routes.forum_topic_path(@conn, :show, @forum, @topic, p) end
|
||||
|
||||
h1 = @topic.title
|
||||
/ Header section
|
||||
.block
|
||||
|
@ -11,8 +13,8 @@ h1 = @topic.title
|
|||
/ i.fa.fa-fw.fa-search>
|
||||
/ | Search Posts
|
||||
.flex.flex--wrap.block__header.block__header--light
|
||||
/.flex--fixed
|
||||
/ = paginate @posts
|
||||
.flex--fixed
|
||||
= pagination
|
||||
.flex--fixed.block__header__item
|
||||
' Started by
|
||||
=> render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @topic
|
||||
|
@ -42,7 +44,9 @@ h1 = @topic.title
|
|||
/.js-editable-posts data-editable=editable_communications(@posts).to_json
|
||||
|
||||
/ Footer section
|
||||
/.block: .block__header.block__header--light = paginate @posts
|
||||
.block
|
||||
.block__header.block__header--light
|
||||
= pagination
|
||||
|
||||
/ Post form
|
||||
= if @topic.post_count < 200_000 do
|
||||
|
|
Loading…
Reference in a new issue