Skip to content

Commit 22b2356

Browse files
authored
Merge pull request #337 from linuxfrorg/filter_get
Fix #2042 filter params for pagination
2 parents 2182644 + 6bb2cab commit 22b2356

27 files changed

+37
-0
lines changed

app/helpers/node_helper.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ def link_to_content(content)
5858
link_to content.title, path_for_content(content)
5959
end
6060

61+
def filter_pagination_params(allowed_params)
62+
allowed_params += ['action', 'controller']
63+
params.each do |k,v|
64+
if allowed_params.include?(k)
65+
params[k] = v
66+
else
67+
params[k] = nil
68+
end
69+
end
70+
end
71+
6172
def paginated_nodes(nodes, link=nil)
6273
paginated_section(nodes, link) do
6374
content_tag(:main, render(nodes.map &:content), id: 'contents', role: 'main')

app/views/admin/accounts/index.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,5 @@
8484
= button_to "Animateur", admin_account_editor_path(account.id), class: "change_role"
8585
= button_to "Admin", admin_account_admin_path(account.id), class: "change_role"
8686

87+
- filter_pagination_params ['login', 'date', 'ip', 'email', 'inactive', 'page']
8788
= paginate @accounts

app/views/admin/applications/index.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
= link_to "Modifier", edit_admin_application_path(app), class: "edit_client_app"
1717
= button_to "Supprimer", admin_application_path(app), method: :delete, class: "delete_button", data: { confirm: "Confirmez‑vous vouloir supprimer cette application ?" }
1818

19+
- filter_pagination_params ['page']
1920
= paginate @applications
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
=h1 "Les liens"
22
- feed "Flux Atom des liens"
33
- new_content_link = link_to("Partager un lien", "/liens/nouveau") if current_account
4+
- filter_pagination_params ['order', 'page']
45
= paginated_nodes @nodes, new_content_link

app/views/diaries/index.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
=h1 "Les journaux"
22
- feed "Flux Atom des journaux"
33
- new_content_link = link_to("Écrire un journal", "/journaux/nouveau") if current_account
4+
- filter_pagination_params ['order', 'page']
45
= paginated_nodes @nodes, new_content_link

app/views/forums/index.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
=h1 "Les forums"
55
- feed "Flux Atom des forums"
66
- new_content_link = link_to("Poster dans les forums", "/posts/nouveau") if current_account
7+
- filter_pagination_params ['order', 'page']
78
= paginated_nodes @nodes, new_content_link

app/views/forums/show.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
=h1 "Les messages du forum #{@forum.title}"
55
- feed "Flux Atom du forum #{@forum.title}", "/forums/#{@forum.to_param}.atom"
66
- new_content_link = link_to("Poster dans les forums", controller: 'posts', action: 'new', forum_id: @forum.id) if current_account
7+
- filter_pagination_params ['id', 'order', 'page']
78
= paginated_contents @posts, new_content_link

app/views/home/index.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- if @banner
1414
%aside.banner
1515
= @banner
16+
- filter_pagination_params ['order', 'page']
1617
= paginated_section @nodes, link_to("Proposer une dépêche", "/news/nouveau") do
1718
%main#contents(role="main")
1819
= render @nodes.map(&:content)

app/views/news/calendar.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
= h1 "Les dépêches du #{@day}/#{@month}/#{@year}"
2+
- filter_pagination_params ['day', 'month', 'order', 'page', 'year']
23
= paginated_nodes @nodes, link_to("Proposer une dépêche", "/news/nouveau")

app/views/news/index.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
= h1 "Les dépêches"
22
- feed "Flux Atom des dépêches"
3+
- filter_pagination_params ['order', 'page']
34
= paginated_nodes @nodes, link_to("Proposer une dépêche", "/news/nouveau")

0 commit comments

Comments
 (0)