From 7a5c0bd16698de0aeb36a2a6eaf49f6b58f204ee Mon Sep 17 00:00:00 2001 From: Keshav Sethi <36025262+keshavsethi@users.noreply.github.com> Date: Tue, 30 Jun 2020 16:16:35 +0530 Subject: [PATCH] Spam2: pagination added (#8063) * pagination added * indentation * pagination of spam2 * indentation * spam2 pagination * more pagination feature added * travis restart * travis restart 1 * tooltips added * formatting of spam2 * IMPROVE: _comments.html.erb - closed the `page-table` div * formatting of spam2 * author color Co-authored-by: Vladimir Mikulic <35997844+VladimirMikulic@users.noreply.github.com> --- app/assets/javascripts/spam2.js | 19 ++++++----- app/assets/stylesheets/spam2.css | 49 +++++++++++++++++------------ app/controllers/spam2_controller.rb | 11 ++++--- app/views/spam2/_comments.html.erb | 10 +++++- app/views/spam2/_nodes.html.erb | 30 ++++++++++++------ app/views/spam2/_revisions.html.erb | 10 +++++- app/views/spam2/_spam.html.erb | 8 ++--- 7 files changed, 90 insertions(+), 47 deletions(-) diff --git a/app/assets/javascripts/spam2.js b/app/assets/javascripts/spam2.js index 8d8d635224..baedd16a02 100644 --- a/app/assets/javascripts/spam2.js +++ b/app/assets/javascripts/spam2.js @@ -5,13 +5,17 @@ function table_main(id) { var table = $(id).DataTable({ - "order": [[1, "desc"]], - "stateSave": false, "autoWidth": false, "search": { "regex": true }, - "scrollX": true + "scrollX": true, + "language": { + "search": "Search in this batch", + "info": "Showing _START_ to _END_ of _TOTAL_ entries in batch", + "infoFiltered": "(filtered from this batch of _MAX_ entries)", + "lengthMenu": "Show _MENU_ entries for this batch" + } }); $('#selectall').click(function () { $('.selectedId').prop('checked', this.checked); @@ -27,11 +31,10 @@ function table_main(id) { return table; } -function disable_buttons(id){ - if ($(id).is(":checked")){ +function disable_buttons(id) { + if ($(id).is(":checked")) { $("#batch-spam, #batch-publish, #delete-batch, #batch-ban, #batch-unban").removeClass("disabled"); - } - else { + } else { $("#batch-spam, #batch-publish, #delete-batch, #batch-ban, #batch-unban").addClass("disabled"); } -} +} \ No newline at end of file diff --git a/app/assets/stylesheets/spam2.css b/app/assets/stylesheets/spam2.css index a5bbf9cc08..da7f3ba5df 100644 --- a/app/assets/stylesheets/spam2.css +++ b/app/assets/stylesheets/spam2.css @@ -1,13 +1,14 @@ /* *= require datatables/dataTables.bootstrap4 */ + .nav_top { z-index: 5; width: 100%; } #batch-spam:hover { - color: red !important; + color: red !important; cursor: pointer; } @@ -32,12 +33,12 @@ } #batch-unban:hover { - color: green !important; + color: green !important; cursor: pointer; } -#node-hover:hover{ - color:blue !important; +#node-hover:hover { + color: blue !important; } #table-card { @@ -45,40 +46,48 @@ } #card-top { - margin-top:2vh; + margin-top: 2vh; } -#bulk-nav{ +#bulk-nav { margin-top: 2%; margin-bottom: 1%; - width:100%; + width: 100%; } -.active .drop{ - color:white !important; +.active .drop { + color: white !important; } -#col-search{ +#col-search { cursor: text; - text-align:left !important; - margin-top:2px; + text-align: left !important; + margin-top: 2px; +} + +#col-select { + margin-top: 2px; } -#col-select{ - margin-top:2px; +.page-table { + width: 100%; + margin-top: 10px; } @media (max-width: 750px) { - #table-card, #bulk-nav, .nav_top, + #table-card, + #bulk-nav, + .nav_top, + .page-table, #card-top { - margin-left: 5vw; - width:90vw; + margin-left: 5vw; + width: 90vw; } - .nav_title{ + .nav_title { font-size: 18px; - margin-bottom : 10px; + margin-bottom: 10px; } - #card-top .card-header{ + #card-top .card-header { font-size: 18px; } } \ No newline at end of file diff --git a/app/controllers/spam2_controller.rb b/app/controllers/spam2_controller.rb index 2dcf11b715..c8096c0404 100644 --- a/app/controllers/spam2_controller.rb +++ b/app/controllers/spam2_controller.rb @@ -3,7 +3,8 @@ class Spam2Controller < ApplicationController def _spam if logged_in_as(%w(moderator admin)) - @nodes = Node.order('nid DESC') + @nodes = Node.order('changed DESC') + .paginate(page: params[:page], per_page: 100) @nodes = if params[:type] == 'wiki' @nodes.where(type: 'page', status: 1) else @@ -22,7 +23,8 @@ def _spam def _spam_revisions if logged_in_as(%w(admin moderator)) @revisions = Revision.where(status: 0) - .order('timestamp DESC') + .paginate(page: params[:page], per_page: 100) + .order('timestamp DESC') render template: 'spam2/_spam' else flash[:error] = 'Only moderators and admins can moderate this.' @@ -32,8 +34,9 @@ def _spam_revisions def _spam_comments if logged_in_as(%w(moderator admin)) - @comments = Comment.order('timestamp DESC') - .where(status: 0) + @comments = Comment.where(status: 0) + .order('timestamp DESC') + .paginate(page: params[:page], per_page: 100) render template: 'spam2/_spam' else flash[:error] = 'Only moderators can moderate comments.' diff --git a/app/views/spam2/_comments.html.erb b/app/views/spam2/_comments.html.erb index 9cfde28142..cca70a7a98 100644 --- a/app/views/spam2/_comments.html.erb +++ b/app/views/spam2/_comments.html.erb @@ -71,4 +71,12 @@ $(document).ready(function () { - \ No newline at end of file + +
+
+ <%= will_paginate @comments, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated || @comments.empty?%> +
+
+ Batch <%= @comments.current_page%> of <%= @comments.total_pages %> total Batches +
+
diff --git a/app/views/spam2/_nodes.html.erb b/app/views/spam2/_nodes.html.erb index 86de9d6438..a1bf61f2eb 100644 --- a/app/views/spam2/_nodes.html.erb +++ b/app/views/spam2/_nodes.html.erb @@ -100,7 +100,7 @@ $(document).ready(function () {
@@ -149,22 +152,22 @@ $(document).ready(function () { - <%= node.title.truncate(20) %>
+ <%= node.title.truncate(15) %>
- <%= node.author&.name %> <%= node.author&.new_contributor%> + <%= node.author&.name %> <%= node.author&.new_contributor%> - <%= node.type.capitalize %> (<% if node.status == 1 %>Published<% elsif node.status == 0 %>Spammed<% elsif node.status == 4 %>Unmoderated<% end %>) + <%= node.type.capitalize %> <% if node.status == 1 %>Published<% elsif node.status == 0 %>Spammed<% elsif node.status == 4 %>Unmoderated<% end %> <%= time_ago_in_words(node.updated_at) %> ago - Publish post - Spam post - style="display:none;"<% end %> data-remote="true" href="/ban/<%= node.author.id %>">Ban user - style="display:none;"<% end %> data-remote="true" href="/unban/<%= node.author.id %>">Unban user + Publish post + Spam post + style="display:none;"<% end %> data-remote="true" href="/ban/<%= node.author.id %>">Ban user + style="display:none;"<% end %> data-remote="true" href="/unban/<%= node.author.id %>">Unban user <%= link_to "/notes/delete/#{node.id}", data: { confirm: "Are you sure you want to delete #{node.path}?" }, :remote => true, :class => "px-3 delete" do %> <% end %> @@ -226,4 +229,13 @@ $(document).ready(function () {
- \ No newline at end of file + + +
+
+ <%= will_paginate @nodes, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated || @nodes.empty?%> +
+
+ Batch <%= @nodes.current_page%> of <%= @nodes.total_pages %> total Batches +
+
diff --git a/app/views/spam2/_revisions.html.erb b/app/views/spam2/_revisions.html.erb index c77a29d308..7d8875a72b 100644 --- a/app/views/spam2/_revisions.html.erb +++ b/app/views/spam2/_revisions.html.erb @@ -60,4 +60,12 @@ $(document).ready(function () { - \ No newline at end of file + +
+
+ <%= will_paginate @revisions, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated || @revisions.empty?%> +
+
+ Batch <%= @revisions.current_page%> of <%= @revisions.total_pages %> total Batches +
+
diff --git a/app/views/spam2/_spam.html.erb b/app/views/spam2/_spam.html.erb index f7053cc2fc..471e750f23 100644 --- a/app/views/spam2/_spam.html.erb +++ b/app/views/spam2/_spam.html.erb @@ -30,9 +30,9 @@
-

Moderate Potential Spam

+

Moderate Potential Spam

-

Moderators and admins have the ability to "spam" posts if they include inappropriate content, blatant advertising, or are otherwise problematic. If you're not sure, email at moderators@<%= request.host %> If we all work together, we can keep spam to a minimum. Thanks for helping out!

+

Moderators and admins have the ability to "spam" posts if they include inappropriate content, blatant advertising, or are otherwise problematic. If you're not sure, email at moderators@<%= request.host %> If we all work together, we can keep spam to a minimum. Thanks for helping out!

@@ -50,7 +50,7 @@ Delete