added ip addr search
This commit is contained in:
@@ -342,6 +342,12 @@ div.clearfix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*** Post previews ***/
|
||||||
|
div.post-previews {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*** Paginator ***/
|
/*** Paginator ***/
|
||||||
div.paginator {
|
div.paginator {
|
||||||
display: block;
|
display: block;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class FavoritesController < ApplicationController
|
class FavoritesController < ApplicationController
|
||||||
|
before_filter :member_only
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if params[:tags]
|
if params[:tags]
|
||||||
redirect_to(posts_path(:tags => "fav:#{CurrentUser.name} #{params[:tags]}"))
|
redirect_to(posts_path(:tags => "fav:#{CurrentUser.name} #{params[:tags]}"))
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
module Moderator
|
module Moderator
|
||||||
class IpAddrsController < ApplicationController
|
class IpAddrsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
|
@search = IpAddrSearch.new(params[:search])
|
||||||
end
|
end
|
||||||
|
|
||||||
def search
|
def search
|
||||||
|
|||||||
@@ -40,6 +40,12 @@ class TagSubscriptionsController < ApplicationController
|
|||||||
respond_with(@tag_subscription)
|
respond_with(@tag_subscription)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def posts
|
||||||
|
@user = User.find(params[:id])
|
||||||
|
@post_set = PostSets::Post.new("sub:#{@user.name} #{params[:tags]}", params[:page])
|
||||||
|
@posts = @post_set.posts
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def check_privilege(tag_subscription)
|
def check_privilege(tag_subscription)
|
||||||
raise User::PrivilegeError unless tag_subscription.editable_by?(CurrentUser.user)
|
raise User::PrivilegeError unless tag_subscription.editable_by?(CurrentUser.user)
|
||||||
|
|||||||
@@ -73,7 +73,13 @@ protected
|
|||||||
|
|
||||||
when "artist_versions"
|
when "artist_versions"
|
||||||
/^\/artist/
|
/^\/artist/
|
||||||
|
|
||||||
|
when "moderator/post/dashboards"
|
||||||
|
/^\/post/
|
||||||
|
|
||||||
|
when "moderator/dashboards"
|
||||||
|
/^\/moderator/
|
||||||
|
|
||||||
else
|
else
|
||||||
/^\/#{controller}/
|
/^\/#{controller}/
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module PaginationHelper
|
module PaginationHelper
|
||||||
def sequential_paginator(records)
|
def sequential_paginator(records)
|
||||||
html = "<menu>"
|
html = '<div class="paginator"><menu>'
|
||||||
|
|
||||||
if records.any?
|
if records.any?
|
||||||
if params[:page] =~ /[ab]/
|
if params[:page] =~ /[ab]/
|
||||||
@@ -10,7 +10,7 @@ module PaginationHelper
|
|||||||
html << '<li>' + link_to("Next >", params.merge(:page => "b#{records[-1].id}")) + '</li>'
|
html << '<li>' + link_to("Next >", params.merge(:page => "b#{records[-1].id}")) + '</li>'
|
||||||
end
|
end
|
||||||
|
|
||||||
html << "</menu>"
|
html << "</menu></div>"
|
||||||
html.html_safe
|
html.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ module PaginationHelper
|
|||||||
return sequential_paginator(records)
|
return sequential_paginator(records)
|
||||||
end
|
end
|
||||||
|
|
||||||
html = "<menu>"
|
html = '<div class="paginator"><menu>'
|
||||||
window = 3
|
window = 3
|
||||||
if records.total_pages <= (window * 2) + 5
|
if records.total_pages <= (window * 2) + 5
|
||||||
1.upto(records.total_pages) do |page|
|
1.upto(records.total_pages) do |page|
|
||||||
@@ -50,7 +50,7 @@ module PaginationHelper
|
|||||||
html << numbered_paginator_item("...", records.current_page)
|
html << numbered_paginator_item("...", records.current_page)
|
||||||
html << numbered_paginator_final_item(records.total_pages, records.current_page)
|
html << numbered_paginator_final_item(records.total_pages, records.current_page)
|
||||||
end
|
end
|
||||||
html << "</menu>"
|
html << "</menu></div>"
|
||||||
html.html_safe
|
html.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
59
app/logical/moderator/ip_addr_search.rb
Normal file
59
app/logical/moderator/ip_addr_search.rb
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
module Moderator
|
||||||
|
class IpAddrSearch
|
||||||
|
attr_reader :params
|
||||||
|
|
||||||
|
def initialize(params)
|
||||||
|
@params = params
|
||||||
|
end
|
||||||
|
|
||||||
|
def execute
|
||||||
|
if params[:user_id]
|
||||||
|
search_by_user_id(params[:user_id].split(/,/))
|
||||||
|
elsif params[:user_name]
|
||||||
|
search_by_user_name(params[:user_name].split(/,/))
|
||||||
|
elsif params[:ip_addr]
|
||||||
|
search_by_ip_addr(params[:ip_addr].split(/,/))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def select_all_sql(sql, *params)
|
||||||
|
ActiveRecord::Base.select_all_sql(sql, *params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search_by_ip_addr(ip_addrs)
|
||||||
|
sums = Hash.new {|h, k| h[k] = 0}
|
||||||
|
|
||||||
|
add_row(sums, "select creator_id as k, count(*) from comments where ip_addr in (?) group by k", ip_addrs)
|
||||||
|
add_row(sums, "select updater_id as k, count(*) from post_versions where updater_ip_addr in (?) group by k", ip_addrs)
|
||||||
|
add_row(sums, "select updater_id as k, count(*) from note_versions where updater_ip_addr in (?) group by k", ip_addrs)
|
||||||
|
add_row(sums, "select updater_id as k, count(*) from pool_versions where updater_ip_addr in (?) group by k", ip_addrs)
|
||||||
|
add_row(sums, "select updater_id as k, count(*) from wiki_page_versions where updater_ip_addr in (?) group by k", ip_addrs)
|
||||||
|
|
||||||
|
sums
|
||||||
|
end
|
||||||
|
|
||||||
|
def search_by_user_name(user_names)
|
||||||
|
users = User.where("name in (?)", user_names)
|
||||||
|
search_by_user_id(users.map(&:id))
|
||||||
|
end
|
||||||
|
|
||||||
|
def search_by_user_id(user_ids)
|
||||||
|
sums = Hash.new {|h, k| h[k] = 0}
|
||||||
|
|
||||||
|
add_row(sums, "select ip_addr as k, count(*) from comments where creator_id in (?) group by k", user_ids)
|
||||||
|
add_row(sums, "select updater_ip_addr as k, count(*) from post_versions where updater_id in (?) group by k", user_ids)
|
||||||
|
add_row(sums, "select updater_ip_addr as k, count(*) from note_versions where updater_id in (?) group by k", user_ids)
|
||||||
|
add_row(sums, "select updater_ip_addr as k, count(*) from pool_versions where updater_id in (?) group by k", user_ids)
|
||||||
|
add_row(sums, "select updater_ip_addr as k, count(*) from wiki_page_versions where updater_id in (?) group by k", user_ids)
|
||||||
|
|
||||||
|
sums
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_row(sums, sql, ip_addrs)
|
||||||
|
select_all_sql(sql, ip_addrs).each do |row|
|
||||||
|
sums[row["k"]] += row["count"].to_i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -15,7 +15,7 @@ class PostSetPresenter < Presenter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def post_previews_html(template)
|
def post_previews_html(template)
|
||||||
html = ""
|
html = "<div class='post-previews'>"
|
||||||
|
|
||||||
if posts.empty?
|
if posts.empty?
|
||||||
return template.render(:partial => "post_sets/blank")
|
return template.render(:partial => "post_sets/blank")
|
||||||
@@ -25,6 +25,8 @@ class PostSetPresenter < Presenter
|
|||||||
html << PostPresenter.preview(post)
|
html << PostPresenter.preview(post)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
html << '</div>'
|
||||||
|
|
||||||
html.html_safe
|
html.html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,9 +31,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= sequential_paginator(@artist_versions) %>
|
||||||
<%= sequential_paginator(@artist_versions) %>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<div id="c-artists">
|
<div id="c-artists">
|
||||||
<div id="a-edit">
|
<div id="a-edit">
|
||||||
<h3>Edit Artist</h3>
|
<h1>Edit Artist</h1>
|
||||||
<%= render "form" %>
|
<%= render "form" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -34,9 +34,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= numbered_paginator(@artists) %>
|
||||||
<%= numbered_paginator(@artists) %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= render "secondary_links" %>
|
<%= render "secondary_links" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,9 +8,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= sequential_paginator(@comments) %>
|
||||||
<%= sequential_paginator(@comments) %>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= sequential_paginator(@posts) %>
|
||||||
<%= sequential_paginator(@posts) %>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
<div id="c-favorites">
|
<div id="c-favorites">
|
||||||
<div id="a-index">
|
<div id="a-index">
|
||||||
<aside id="sidebar">
|
<aside id="sidebar">
|
||||||
<section id="search-box">
|
<%= render :partial => "posts/partials/common/search", :locals => {:path => favorites_path, :tags => @favorite_set.tag_string} %>
|
||||||
<h1>Search Favorites</h1>
|
|
||||||
<%= form_tag(favorites_path, :method => "get") do %>
|
|
||||||
<%= text_field_tag("tags", @favorite_set.tag_string, :size => 20) %>
|
|
||||||
<%= submit_tag "Go" %>
|
|
||||||
<% end %>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<% if CurrentUser.is_privileged? %>
|
<% if CurrentUser.is_privileged? %>
|
||||||
<section id="mode-box">
|
<section id="mode-box">
|
||||||
@@ -25,13 +19,10 @@
|
|||||||
|
|
||||||
<section id="content">
|
<section id="content">
|
||||||
<h1>Posts</h1>
|
<h1>Posts</h1>
|
||||||
|
|
||||||
<%= @favorite_set.presenter.post_previews_html(self) %>
|
<%= @favorite_set.presenter.post_previews_html(self) %>
|
||||||
|
|
||||||
<div class="clearfix"></div>
|
<%= sequential_paginator(@favorite_set.favorites) %>
|
||||||
|
|
||||||
<div class="paginator">
|
|
||||||
<%= sequential_paginator(@favorite_set.favorites) %>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<% content_for(:page_title) do %>
|
<% content_for(:page_title) do %>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<div id="c-forum-topics">
|
<div id="c-forum-topics">
|
||||||
<div id="a-edit">
|
<div id="a-edit">
|
||||||
<h3>Edit Forum Post</h3>
|
<h1>Edit Forum Post</h1>
|
||||||
|
|
||||||
<%= render "form" %>
|
<%= render "form" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
<table width="100%" class="striped">
|
<div id="c-forum-posts">
|
||||||
<thead>
|
<div id="a-index">
|
||||||
<tr>
|
<table width="100%" class="striped">
|
||||||
<th>Topic</th>
|
<thead>
|
||||||
<th>Excerpt</th>
|
<tr>
|
||||||
<th>Creator</th>
|
<th>Topic</th>
|
||||||
<th>Date</th>
|
<th>Excerpt</th>
|
||||||
</tr>
|
<th>Creator</th>
|
||||||
</thead>
|
<th>Date</th>
|
||||||
<tbody>
|
</tr>
|
||||||
<% @forum_posts.each do |forum_post| %>
|
</thead>
|
||||||
<tr>
|
<tbody>
|
||||||
<td><%= link_to forum_post.topic.title, forum_topic_path(forum_post.topic) %></td>
|
<% @forum_posts.each do |forum_post| %>
|
||||||
<td><%= link_to truncate(forum_post.body, :length => 50), forum_post_path(forum_post) %></td>
|
<tr>
|
||||||
<td><%= forum_post.creator.name %></td>
|
<td><%= link_to forum_post.topic.title, forum_topic_path(forum_post.topic) %></td>
|
||||||
<td><%= time_ago_in_words forum_post.created_at %> ago</td>
|
<td><%= link_to truncate(forum_post.body, :length => 50), forum_post_path(forum_post) %></td>
|
||||||
</tr>
|
<td><%= forum_post.creator.name %></td>
|
||||||
<% end %>
|
<td><%= time_ago_in_words forum_post.created_at %> ago</td>
|
||||||
</tbody>
|
</tr>
|
||||||
</table>
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
<div id="paginator">
|
<%= numbered_paginator(@forum_posts) %>
|
||||||
<%= numbered_paginator(@forum_posts) do |page| %>
|
</div>
|
||||||
<%= link_to(page, forum_posts_path(:search => params[:search], :page => page)) %>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= render "forum_topics/secondary_links" %>
|
<%= render "forum_topics/secondary_links" %>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<div id="c-forum-topics">
|
<div id="c-forum-topics">
|
||||||
<div id="a-new">
|
<div id="a-new">
|
||||||
<h3>New Forum Post</h3>
|
<h1>New Forum Post</h1>
|
||||||
<%= render "form" %>
|
<%= render "form" %>
|
||||||
<%= error_messages_for "forum_post" %>
|
<%= error_messages_for "forum_post" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<div id="c-forum-topics">
|
<div id="c-forum-topics">
|
||||||
<div id="a-search">
|
<div id="a-search">
|
||||||
<h3>Search Forum Posts</h3>
|
<h1>Search Forum Posts</h1>
|
||||||
<%= simple_form_for @search do |f| %>
|
<%= simple_form_for @search do |f| %>
|
||||||
<%= f.input :topic_title_matches, :label => "Title" %>
|
<%= f.input :topic_title_matches, :label => "Title" %>
|
||||||
<%= f.input :body_matches, :label => "Body" %>
|
<%= f.input :body_matches, :label => "Body" %>
|
||||||
|
|||||||
@@ -1,3 +1 @@
|
|||||||
<div class="paginator">
|
<%= @forum_topic.presenter(@forum_posts).pagination_html(self) %>
|
||||||
<%= @forum_topic.presenter(@forum_posts).pagination_html(self) %>
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<div id="c-forum-topics">
|
<div id="c-forum-topics">
|
||||||
<div id="a-edit">
|
<div id="a-edit">
|
||||||
<h3>Edit Forum Topic</h3>
|
<h1>Edit Forum Topic</h1>
|
||||||
|
|
||||||
<%= render "form" %>
|
<%= render "form" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<div id="c-forum-topics">
|
<div id="c-forum-topics">
|
||||||
<div id="a-new">
|
<div id="a-new">
|
||||||
<h3>New Forum Topic</h3>
|
<h1>New Forum Topic</h1>
|
||||||
|
|
||||||
<%= render "form" %>
|
<%= render "form" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
22
app/views/moderator/ip_addrs/index.html.erb
Normal file
22
app/views/moderator/ip_addrs/index.html.erb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<div id="c-moderator-ip-addrs">
|
||||||
|
<div id="a-index">
|
||||||
|
<h1>IP Addresses</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Key</th>
|
||||||
|
<th>Count</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @search.execute.each do |k, count| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= k %></td>
|
||||||
|
<td><%= count %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
19
app/views/moderator/ip_addrs/search.html.erb
Normal file
19
app/views/moderator/ip_addrs/search.html.erb
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<div id="c-moderator-ip-addrs">
|
||||||
|
<div id="a-search">
|
||||||
|
<h1>IP Address Search</h1>
|
||||||
|
|
||||||
|
<%= form_tag(moderator_ip_addrs_path) do %>
|
||||||
|
<div class="input">
|
||||||
|
<label>User</label>
|
||||||
|
<%= text_field :search, :user_name %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input">
|
||||||
|
<label>IP Addr</label>
|
||||||
|
<%= text_field :search, :ip_addr %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= submit_tag %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -38,3 +38,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<%= render :partial => "posts/partials/common/secondary_links" %>
|
||||||
@@ -33,12 +33,9 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= sequential_paginator(@note_versions) %>
|
||||||
<%= sequential_paginator(@note_versions) %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= render :partial => "notes/secondary_links" %>
|
<%= render :partial => "notes/secondary_links" %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= sequential_paginator(@notes) %>
|
||||||
<%= sequential_paginator(@notes) %>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,7 @@
|
|||||||
<div id="a-index">
|
<div id="a-index">
|
||||||
<%= @post_set.presenter.post_previews_html(self) %>
|
<%= @post_set.presenter.post_previews_html(self) %>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= numbered_paginator(@posts, false) %>
|
||||||
<%= numbered_paginator(@posts, false) %>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<div id="c-pools">
|
<div id="c-pools">
|
||||||
<div id="a-index">
|
<div id="a-index">
|
||||||
<h3>Pool History</h3>
|
<h1>Pool History</h1>
|
||||||
|
|
||||||
<table width="100%">
|
<table width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -33,9 +33,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= numbered_paginator(@pool_versions) %>
|
||||||
<%= numbered_paginator(@pool_versions) %>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= numbered_paginator(@pools) %>
|
||||||
<%= sequential_paginator(@pools) %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= render "secondary_links" %>
|
<%= render "secondary_links" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,11 +9,7 @@
|
|||||||
<section id="content">
|
<section id="content">
|
||||||
<%= @post_set.presenter.post_previews_html(self) %>
|
<%= @post_set.presenter.post_previews_html(self) %>
|
||||||
|
|
||||||
<div class="clearfix"></div>
|
<%= numbered_paginator(@post_set) %>
|
||||||
|
|
||||||
<div class="paginator">
|
|
||||||
<%= numbered_paginator(@post_set) %>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -39,6 +39,4 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= sequential_paginator(post_versions) %>
|
||||||
<%= sequential_paginator(post_versions) %>
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -1,26 +1,11 @@
|
|||||||
<div id="c-posts">
|
<div id="c-posts">
|
||||||
<div id="a-index">
|
<div id="a-index">
|
||||||
<aside id="sidebar">
|
<aside id="sidebar">
|
||||||
<section id="search-box">
|
<%= render :partial => "posts/partials/common/search", :locals => {:path => posts_path, :tags => params[:tags]} %>
|
||||||
<h1>Search</h1>
|
|
||||||
<%= form_tag(posts_path, :method => "get") do %>
|
|
||||||
<%= text_field_tag("tags", params[:tags], :size => 20) %>
|
|
||||||
<%= submit_tag "Go" %>
|
|
||||||
<% end %>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<% if CurrentUser.user.is_privileged? %>
|
<%= render :partial => "posts/partials/index/mode_menu" %>
|
||||||
<section id="mode-box">
|
|
||||||
<%= render :partial => "posts/partials/index/mode_menu" %>
|
|
||||||
</section>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<section id="blacklist-box">
|
<%= render :partial => "posts/partials/index/blacklist" %>
|
||||||
<h1>Blacklist</h1>
|
|
||||||
<%= link_to "Hidden", "#" %>
|
|
||||||
<ul>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id="tag-box">
|
<section id="tag-box">
|
||||||
<h1>Tags</h1>
|
<h1>Tags</h1>
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
<%= form_tag(posts_path, :method => "get") do %>
|
<!--
|
||||||
<%= text_field_tag("tags", params[:tags]) %>
|
- path
|
||||||
<%= submit_tag "Go" %>
|
- tags
|
||||||
<% end %>
|
-->
|
||||||
|
|
||||||
|
<section id="search-box">
|
||||||
|
<h1>Search</h1>
|
||||||
|
<%= form_tag(path, :method => "get") do %>
|
||||||
|
<%= text_field_tag("tags", tags, :size => 20) %>
|
||||||
|
<%= submit_tag "Go" %>
|
||||||
|
<% end %>
|
||||||
|
</section>
|
||||||
|
|||||||
@@ -6,11 +6,10 @@
|
|||||||
<li><%= link_to "Hot", explore_post_hot_path %></li>
|
<li><%= link_to "Hot", explore_post_hot_path %></li>
|
||||||
<% unless CurrentUser.is_anonymous? %>
|
<% unless CurrentUser.is_anonymous? %>
|
||||||
<li><%= link_to "Favorites", favorites_path %></li>
|
<li><%= link_to "Favorites", favorites_path %></li>
|
||||||
<li><%= link_to "Subscriptions", tag_subscriptions_path(:user_id => CurrentUser.id) %></li>
|
<li><%= link_to "Subscriptions", posts_tag_subscription_path(CurrentUser.id) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li><%= link_to "Changes", post_versions_path %></li>
|
<li><%= link_to "Changes", post_versions_path %></li>
|
||||||
<li>Approvals</li>
|
|
||||||
<li><%= link_to "Moderate", moderator_post_dashboard_path %></li>
|
<li><%= link_to "Moderate", moderator_post_dashboard_path %></li>
|
||||||
<li>Help</li>
|
<li><%= link_to "Help", wiki_pages_path(:title => "help:posts") %></li>
|
||||||
</menu>
|
</menu>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
6
app/views/posts/partials/index/_blacklist.html.erb
Normal file
6
app/views/posts/partials/index/_blacklist.html.erb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<section id="blacklist-box">
|
||||||
|
<h1>Blacklisted</h1>
|
||||||
|
<%= link_to "Hidden", "#" %>
|
||||||
|
<ul>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
@@ -1,21 +1,25 @@
|
|||||||
<h1>Mode</h1>
|
<% if CurrentUser.is_privileged? %>
|
||||||
<form action="/">
|
<section id="mode-box">
|
||||||
<select name="mode">
|
<h1>Mode</h1>
|
||||||
<option value="view">View</option>
|
<form action="/">
|
||||||
<option value="edit">Edit</option>
|
<select name="mode">
|
||||||
<option value="add-fav">Favorite</option>
|
<option value="view">View</option>
|
||||||
<option value="remove-fav">Unfavorite</option>
|
<option value="edit">Edit</option>
|
||||||
<option value="rating-s">Rate safe</option>
|
<option value="add-fav">Favorite</option>
|
||||||
<option value="rating-q">Rate questionable</option>
|
<option value="remove-fav">Unfavorite</option>
|
||||||
<option value="rating-e">Rate explicit</option>
|
<option value="rating-s">Rate safe</option>
|
||||||
<option value="vote-up">Vote up</option>
|
<option value="rating-q">Rate questionable</option>
|
||||||
<option value="vote-down">Vote down</option>
|
<option value="rating-e">Rate explicit</option>
|
||||||
<option value="lock-rating">Lock rating</option>
|
<option value="vote-up">Vote up</option>
|
||||||
<option value="lock-note">Lock notes</option>
|
<option value="vote-down">Vote down</option>
|
||||||
<option value="edit-tag-script">Edit tag script</option>
|
<option value="lock-rating">Lock rating</option>
|
||||||
<option value="apply-tag-script">Apply tag script</option>
|
<option value="lock-note">Lock notes</option>
|
||||||
<% if CurrentUser.user.is_janitor? %>
|
<option value="edit-tag-script">Edit tag script</option>
|
||||||
<option value="approve">Approve</option>
|
<option value="apply-tag-script">Apply tag script</option>
|
||||||
<% end %>
|
<% if CurrentUser.user.is_janitor? %>
|
||||||
</select>
|
<option value="approve">Approve</option>
|
||||||
</form>
|
<% end %>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -2,8 +2,4 @@
|
|||||||
|
|
||||||
<%= post_set.presenter.post_previews_html(self) %>
|
<%= post_set.presenter.post_previews_html(self) %>
|
||||||
|
|
||||||
<div class="clearfix"></div>
|
<%= numbered_paginator(post_set.posts) %>
|
||||||
|
|
||||||
<div class="paginator">
|
|
||||||
<%= numbered_paginator(post_set.posts) %>
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
<div id="c-posts">
|
<div id="c-posts">
|
||||||
<div id="a-show">
|
<div id="a-show">
|
||||||
<aside id="sidebar">
|
<aside id="sidebar">
|
||||||
<section>
|
<%= render :partial => "posts/partials/common/search", :locals => {:path => posts_path, :tags => params[:tags]} %>
|
||||||
<h1>Search</h1>
|
|
||||||
<%= render :partial => "posts/partials/common/search" %>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<% if @post.pools.any? %>
|
<% if @post.pools.any? %>
|
||||||
<section id="pool-sidebar">
|
<section id="pool-sidebar">
|
||||||
|
|||||||
@@ -36,11 +36,9 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<%= numbered_paginator(@tag_aliases) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="paginator">
|
|
||||||
<%= numbered_paginator(@tag_aliases) %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= render "secondary_links" %>
|
<%= render "secondary_links" %>
|
||||||
|
|||||||
@@ -36,11 +36,9 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<%= numbered_paginator(@tag_implications) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="paginator">
|
|
||||||
<%= numbered_paginator(@tag_implications) %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= render "secondary_links" %>
|
<%= render "secondary_links" %>
|
||||||
|
|||||||
26
app/views/tag_subscriptions/posts.html.erb
Normal file
26
app/views/tag_subscriptions/posts.html.erb
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<div id="c-tag-subscriptions">
|
||||||
|
<div id="a-posts">
|
||||||
|
<aside id="sidebar">
|
||||||
|
<%= render :partial => "posts/partials/common/search", :locals => {:path => posts_tag_subscription_path, :tags => @post_set.tag_string} %>
|
||||||
|
|
||||||
|
<%= render :partial => "posts/partials/index/mode_menu" %>
|
||||||
|
|
||||||
|
<%= render :partial => "posts/partials/index/blacklist" %>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<section id="content">
|
||||||
|
<h1>Posts</h1>
|
||||||
|
|
||||||
|
<%= @post_set.presenter.post_previews_html(self) %>
|
||||||
|
|
||||||
|
<%= numbered_paginator(@posts) %>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<% content_for(:page_title) do %>
|
||||||
|
/fav:<%= CurrentUser.name %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= render :partial => "posts/partials/common/secondary_links" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@@ -1,25 +1,27 @@
|
|||||||
<table width="100%" class="striped">
|
<div id="c-tags">
|
||||||
<thead>
|
<div id="a-index">
|
||||||
<tr>
|
<table width="100%" class="striped">
|
||||||
<th>Count</th>
|
<thead>
|
||||||
<th>Name</th>
|
<tr>
|
||||||
</tr>
|
<th>Count</th>
|
||||||
</thead>
|
<th>Name</th>
|
||||||
<tbody>
|
</tr>
|
||||||
<% @tags.each do |tag| %>
|
</thead>
|
||||||
<tr>
|
<tbody>
|
||||||
<td><%= tag.post_count %></td>
|
<% @tags.each do |tag| %>
|
||||||
<td class="tag-category-<%= tag.category_name %>">
|
<tr>
|
||||||
<%= link_to("?", wiki_pages_path(:title => tag.name)) %>
|
<td><%= tag.post_count %></td>
|
||||||
<%= link_to(tag.name, posts_path(:tags => tag.name)) %>
|
<td class="tag-category-<%= tag.category_name %>">
|
||||||
</td>
|
<%= link_to("?", wiki_pages_path(:title => tag.name)) %>
|
||||||
</tr>
|
<%= link_to(tag.name, posts_path(:tags => tag.name)) %>
|
||||||
<% end %>
|
</td>
|
||||||
</tbody>
|
</tr>
|
||||||
</table>
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= numbered_paginator(@tags) %>
|
||||||
<%= numbered_paginator(@tags) %>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= render "secondary_links" %>
|
<%= render "secondary_links" %>
|
||||||
|
|||||||
@@ -23,9 +23,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= sequential_paginator(@uploads) %>
|
||||||
<%= sequential_paginator(@uploads) %>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= numbered_paginator(@user_feedbacks) %>
|
||||||
<%= numbered_paginator(@user_feedbacks) %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= render "secondary_links" %>
|
<%= render "secondary_links" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -29,3 +29,5 @@
|
|||||||
<% content_for(:page_title) do %>
|
<% content_for(:page_title) do %>
|
||||||
/Users/<%= @user.name %>/Settings
|
/Users/<%= @user.name %>/Settings
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<%= render "secondary_links" %>
|
||||||
@@ -48,9 +48,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= numbered_paginator(@users) %>
|
||||||
<%= numbered_paginator(@users) %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= render "secondary_links" %>
|
<%= render "secondary_links" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -32,9 +32,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= numbered_paginator(@wiki_page_versions) %>
|
||||||
<%= numbered_paginator(@wiki_page_versions) %>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -22,9 +22,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="paginator">
|
<%= numbered_paginator(@wiki_pages) %>
|
||||||
<%= numbered_paginator(@wiki_pages) %>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ Danbooru::Application.routes.draw do
|
|||||||
get :search
|
get :search
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
resource :tag
|
||||||
namespace :post do
|
namespace :post do
|
||||||
resource :dashboard, :only => [:show]
|
resource :dashboard, :only => [:show]
|
||||||
resource :approval, :only => [:create]
|
resource :approval, :only => [:create]
|
||||||
@@ -107,7 +108,11 @@ Danbooru::Application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :tag_implications
|
resources :tag_implications
|
||||||
resources :tag_subscriptions
|
resources :tag_subscriptions do
|
||||||
|
member do
|
||||||
|
get :posts
|
||||||
|
end
|
||||||
|
end
|
||||||
resources :uploads
|
resources :uploads
|
||||||
resources :users
|
resources :users
|
||||||
resources :user_feedbacks
|
resources :user_feedbacks
|
||||||
|
|||||||
32
db/seeds.rb
32
db/seeds.rb
@@ -5,6 +5,14 @@ if User.count == 0
|
|||||||
:password => "password1",
|
:password => "password1",
|
||||||
:password_confirmation => "password1"
|
:password_confirmation => "password1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
0.upto(100) do |i|
|
||||||
|
User.create(
|
||||||
|
:name => i.to_s * 5,
|
||||||
|
:password => i.to_s * 5,
|
||||||
|
:password_confirmation => i.to_s * 5
|
||||||
|
)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
puts "Skipping users"
|
puts "Skipping users"
|
||||||
user = User.first
|
user = User.first
|
||||||
@@ -93,3 +101,27 @@ if Pool.count == 0
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Favorite.count == 0
|
||||||
|
puts "Creating favorites"
|
||||||
|
|
||||||
|
Post.order("random()").limit(50).each do |post|
|
||||||
|
user = User.order("random()").first
|
||||||
|
post.add_favorite!(user)
|
||||||
|
post.add_favorite!(CurrentUser.user)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
puts "Skipping favorites"
|
||||||
|
end
|
||||||
|
|
||||||
|
if TagSubscription.count == 0
|
||||||
|
puts "Creating tag subscriptions"
|
||||||
|
TagSubscription.create(:name => "0", :tag_query => Tag.order("random()").first.name)
|
||||||
|
1.upto(50) do |i|
|
||||||
|
CurrentUser.user = User.order("random()").first
|
||||||
|
TagSubscription.create(:name => i.to_s, :tag_query => Tag.order("random()").first.name)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
puts "Skipping tag subscriptions"
|
||||||
|
end
|
||||||
|
|
||||||
|
|||||||
35
test/functional/moderator/ip_addrs_controller_test.rb
Normal file
35
test/functional/moderator/ip_addrs_controller_test.rb
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
module Moderator
|
||||||
|
class IpAddrsControllerTest < ActionController::TestCase
|
||||||
|
context "The ip addrs controller" do
|
||||||
|
setup do
|
||||||
|
@user = Factory.create(:moderator_user)
|
||||||
|
CurrentUser.user = @user
|
||||||
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
Factory.create(:comment)
|
||||||
|
MEMCACHE.flush_all
|
||||||
|
end
|
||||||
|
|
||||||
|
should "find by ip addr" do
|
||||||
|
get :index, {:search => {:ip_addr => "127.0.0.1"}}, {:user_id => @user.id}
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
should "find by user id" do
|
||||||
|
get :index, {:search => {:user_id => @user.id.to_s}}, {:user_id => @user.id}
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
should "find by user name" do
|
||||||
|
get :index, {:search => {:user_name => @user.name}}, {:user_id => @user.id}
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
should "render the search page" do
|
||||||
|
get :search, {}, {:user_id => @user.id}
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -23,6 +23,17 @@ class TagSubscriptionsControllerTest < ActionController::TestCase
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "posts action" do
|
||||||
|
setup do
|
||||||
|
@tag_subscription = Factory.create(:tag_subscription, :name => "aaa")
|
||||||
|
end
|
||||||
|
|
||||||
|
should "list all visible tag subscriptions" do
|
||||||
|
get :posts, {:id => @tag_subscription.creator_id}
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "edit action" do
|
context "edit action" do
|
||||||
setup do
|
setup do
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require_relative '../test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class IpBanTest < ActiveSupport::TestCase
|
class IpBanTest < ActiveSupport::TestCase
|
||||||
setup do
|
setup do
|
||||||
|
|||||||
35
test/unit/moderator/ip_addr_search_test.rb
Normal file
35
test/unit/moderator/ip_addr_search_test.rb
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
module Moderator
|
||||||
|
class IpAddrSearchTest < ActiveSupport::TestCase
|
||||||
|
context "an ip addr search" do
|
||||||
|
setup do
|
||||||
|
@user = Factory.create(:user)
|
||||||
|
CurrentUser.user = @user
|
||||||
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
Factory.create(:comment)
|
||||||
|
MEMCACHE.flush_all
|
||||||
|
end
|
||||||
|
|
||||||
|
teardown do
|
||||||
|
CurrentUser.user = nil
|
||||||
|
CurrentUser.ip_addr = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
should "find by ip addr" do
|
||||||
|
@search = IpAddrSearch.new(:ip_addr => "127.0.0.1")
|
||||||
|
assert_equal({@user.id.to_s => 2}, @search.execute)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "find by user id" do
|
||||||
|
@search = IpAddrSearch.new(:user_id => @user.id.to_s)
|
||||||
|
assert_equal({"127.0.0.1" => 2}, @search.execute)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "find by user name" do
|
||||||
|
@search = IpAddrSearch.new(:user_name => @user.name)
|
||||||
|
assert_equal({"127.0.0.1" => 2}, @search.execute)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user