Merge branch 'master' of github.com:r888888888/danbooru

This commit is contained in:
albert
2013-03-30 12:14:19 -04:00
22 changed files with 52 additions and 28 deletions

View File

@@ -189,6 +189,16 @@ class PostQueryBuilder
has_constraints!
end
if q[:commenter_id]
relation = relation.where(:id => Comment.where("creator_id = ?", q[:commenter_id]).select("post_id").uniq)
has_constraints!
end
if q[:noter_id]
relation = relation.where(:id => Note.where("creator_id = ?", q[:noter_id]).select("post_id").uniq)
has_constraints!
end
if q[:parent_id]
relation = relation.where("(posts.id = ? or posts.parent_id = ?)", q[:parent_id], q[:parent_id])
has_constraints!
@@ -235,10 +245,10 @@ class PostQueryBuilder
when "favcount_asc"
relation = relation.order("posts.fav_count ASC, posts.id DESC")
when "comment"
when "comment", "comm"
relation = relation.order("posts.last_commented_at DESC, posts.id DESC").where("posts.last_commented_at is not null")
when "comment_asc"
when "comment_asc", "comm_asc"
relation = relation.order("posts.last_commented_at ASC, posts.id DESC").where("posts.last_commented_at is not null")
when "note"

View File

@@ -1,5 +1,5 @@
class ArtistVersion < ActiveRecord::Base
belongs_to :updater
belongs_to :updater, :class_name => "User"
belongs_to :artist
def self.search(params)

View File

@@ -3,6 +3,7 @@ class Comment < ActiveRecord::Base
validates_format_of :body, :with => /\S/, :message => 'has no content'
belongs_to :post
belongs_to :creator, :class_name => "User"
belongs_to :updater, :class_name => "User"
has_many :votes, :class_name => "CommentVote", :dependent => :destroy
before_validation :initialize_creator, :on => :create
before_validation :initialize_updater

View File

@@ -2,6 +2,7 @@ class ForumPost < ActiveRecord::Base
attr_accessible :body, :topic_id, :as => [:member, :builder, :janitor, :privileged, :platinum, :contributor, :admin, :moderator, :default]
attr_accessible :is_locked, :is_sticky, :is_deleted, :as => [:admin, :moderator, :janitor]
belongs_to :creator, :class_name => "User"
belongs_to :updater, :class_name => "User"
belongs_to :topic, :class_name => "ForumTopic"
before_validation :initialize_creator, :on => :create
before_validation :initialize_updater

View File

@@ -1,5 +1,5 @@
class Tag < ActiveRecord::Base
METATAGS = "-user|user|-approver|approver|-pool|pool|-fav|fav|sub|md5|-rating|rating|width|height|mpixels|score|filesize|source|id|date|order|-status|status|tagcount|gentags|arttags|chartags|copytags|parent|pixiv"
METATAGS = "-user|user|-approver|approver|commenter|comm|noter|-pool|pool|-fav|fav|sub|md5|-rating|rating|width|height|mpixels|score|filesize|source|id|date|order|-status|status|tagcount|gentags|arttags|chartags|copytags|parent|pixiv"
attr_accessible :category
has_one :wiki_page, :foreign_key => "name", :primary_key => "title"
@@ -280,6 +280,14 @@ class Tag < ActiveRecord::Base
q[:approver_id] = User.name_to_id($2)
q[:approver_id] = -1 if q[:approver_id].nil?
when "commenter", "comm"
q[:commenter_id] = User.name_to_id($2)
q[:commenter_id] = -1 if q[:commenter_id].nil?
when "noter"
q[:noter_id] = User.name_to_id($2)
q[:noter_id] = -1 if q[:noter_id].nil?
when "-pool"
q[:tags][:exclude] << "pool:#{Pool.name_to_id($2)}"

View File

@@ -355,6 +355,10 @@ class User < ActiveRecord::Base
return true
end
def level_class
"user-#{level_string.downcase}"
end
end
module EmailMethods

View File

@@ -105,7 +105,7 @@ class UserPresenter
def inviter(template)
if user.inviter_id
template.link_to(user.inviter.name, template.user_path(user.inviter_id))
template.link_to(user.inviter.name, template.user_path(user.inviter_id), { :class => user.inviter.level_class })
else
"None"
end

View File

@@ -27,7 +27,7 @@
<td><%= artist_version_other_names_diff(artist_version) %></td>
<td><%= artist_version.group_name %></td>
<td><%= compact_time artist_version.created_at %></td>
<td><%= link_to artist_version.updater_name, user_path(artist_version.updater_id) %></td>
<td><%= link_to artist_version.updater_name, user_path(artist_version.updater_id), { :class => artist_version.updater.level_class } %></td>
<td><%= artist_version.is_active? %></td>
<td>
<ul>

View File

@@ -1,6 +1,6 @@
<article class="comment" data-post-id="<%= comment.post_id %>" data-comment-id="<%= comment.id %>" data-score="<%= comment.score %>">
<div class="author">
<h1><%= link_to comment.creator_name, user_path(comment.creator_id) %></h1>
<h1><%= link_to comment.creator_name, user_path(comment.creator_id), { :class => comment.creator.level_class } %></h1>
<p>
<%= time_ago_in_words_tagged(comment.created_at) %>
</p>
@@ -10,7 +10,7 @@
<%= format_text(comment.body) %>
<% if comment.updater_id.present? && (comment.updater_id != comment.creator_id || comment.created_at != comment.updated_at) %>
<p class="info">Updated by <%= link_to comment.updater_name, user_path(comment.updater_id) %> <%= time_ago_in_words_tagged(comment.updated_at) %></p>
<p class="info">Updated by <%= link_to comment.updater_name, user_path(comment.updater_id), { :class => comment.updater.level_class } %> <%= time_ago_in_words_tagged(comment.updated_at) %></p>
<% end %>
</div>

View File

@@ -21,8 +21,8 @@
<% @dmails.each do |dmail| %>
<tr class="read-<%= dmail.is_read? %>">
<td><%= compact_time(dmail.created_at) %></td>
<td><%= link_to dmail.from_name, user_path(dmail.from) %></td>
<td><%= link_to dmail.to_name, user_path(dmail.to) %></td>
<td><%= link_to dmail.from_name, user_path(dmail.from), { :class => dmail.from.level_class } %></td>
<td><%= link_to dmail.to_name, user_path(dmail.to), { :class => dmail.to.level_class } %></td>
<td><%= link_to dmail.title, dmail_path(dmail) %></td>
</tr>
<% end %>

View File

@@ -5,8 +5,8 @@
<h2><%= @dmail.title %></h2>
<ul style="margin-bottom: 1em;">
<li><strong>Sender</strong>: <%= link_to @dmail.from_name, user_path(@dmail.from_id) %></li>
<li><strong>Recipient</strong>: <%= link_to @dmail.to_name, user_path(@dmail.to_id) %></li>
<li><strong>Sender</strong>: <%= link_to @dmail.from_name, user_path(@dmail.from_id), { :class => @dmail.from.level_class } %></li>
<li><strong>Recipient</strong>: <%= link_to @dmail.to_name, user_path(@dmail.to_id), { :class => @dmail.to.level_class } %></li>
<li><strong>Date</strong>: <%= compact_time(@dmail.created_at) %></li>
</ul>

View File

@@ -2,7 +2,7 @@
<article data-forum-post-id="<%= forum_post.id %>">
<div class="author">
<h4>
<%= link_to forum_post.creator.name, user_path(forum_post.creator_id) %>
<%= link_to forum_post.creator.name, user_path(forum_post.creator_id), { :class => forum_post.creator.level_class } %>
<% if forum_post.is_deleted? %>
(deleted)
<% end %>
@@ -16,7 +16,7 @@
<%= format_text(forum_post.body) %>
</div>
<% if forum_post.updater_id != forum_post.creator_id %>
<p class="info">Updated by <%= link_to forum_post.updater_name, user_path(forum_post.updater_id) %> <%= time_ago_in_words_tagged(forum_post.updated_at) %></p>
<p class="info">Updated by <%= link_to forum_post.updater_name, user_path(forum_post.updater_id), { :class => forum_post.updater.level_class } %> <%= time_ago_in_words_tagged(forum_post.updated_at) %></p>
<% end %>
<menu>
<li>ID: <%= forum_post.id %></li>

View File

@@ -33,8 +33,8 @@
<span class="locked-topic">(locked)</span>
<% end %>
</td>
<td><%= link_to topic.creator.name, user_path(topic.creator) %></td>
<td><%= link_to topic.updater.name, user_path(topic.updater) %></td>
<td><%= link_to topic.creator.name, user_path(topic.creator), { :class => topic.creator.level_class } %></td>
<td><%= link_to topic.updater.name, user_path(topic.updater), { :class => topic.updater.level_class } %></td>
<td><%= compact_time topic.updated_at %></td>
</tr>
<% end %>

View File

@@ -13,7 +13,7 @@
<% @mod_actions.each do |mod_action| %>
<tr>
<td><%= compact_time mod_action.created_at %></td>
<td><%= link_to mod_action.creator.name, user_path(mod_action.creator) %></td>
<td><%= link_to mod_action.creator.name, user_path(mod_action.creator), { :class => mod_action.creator.level_class } %></td>
<td><%= format_text(mod_action.description) %></td>
</tr>
<% end %>

View File

@@ -29,7 +29,7 @@
<%= note_version.updater_ip_addr %>
</td>
<% end %>
<td><%= link_to note_version.updater.try(:name), user_path(note_version.updater) %></td>
<td><%= link_to note_version.updater.try(:name), user_path(note_version.updater), { :class => note_version.updater.level_class } %></td>
<td><%= compact_time note_version.updated_at %></td>
<td>
<% if CurrentUser.is_member? %>

View File

@@ -16,7 +16,7 @@
<% @notes.each do |note| %>
<tr>
<td><%= link_to note.post_id, post_path(note.post_id) %></td>
<td><%= link_to note.creator.name, user_path(note.creator_id) %></td>
<td><%= link_to note.creator.name, user_path(note.creator_id), { :class => note.creator.level_class } %></td>
<td><%= compact_time(note.created_at) %></td>
<td><%= note.is_active? %></td>
<td><%= format_text(note.body) %></td>

View File

@@ -20,7 +20,7 @@
<td><%= link_to pool_version.pool.name, pool_path(pool_version.pool_id) %></td>
<td><%= link_to pool_version.post_id_array.size, pool_versions_path(:search => {:pool_id => pool_version.pool_id}) %></td>
<td><%= pool_version_diff(pool_version) %></td>
<td><%= link_to pool_version.updater_name, user_path(pool_version.updater_id) %></td>
<td><%= link_to pool_version.updater_name, user_path(pool_version.updater_id), { :class => pool_version.updater.level_class } %></td>
<td>
<% if CurrentUser.is_janitor? %>
<%= pool_version.updater_ip_addr %>

View File

@@ -19,7 +19,7 @@
<%= link_to h(pool.pretty_name), pool_path(pool) %>
</td>
<td>
<%= link_to h(pool.creator.name), user_path(pool.creator) %>
<%= link_to h(pool.creator.name), user_path(pool.creator), { :class => pool.creator.level_class } %>
</td>
<td>
<%= pool.post_count %>

View File

@@ -1,9 +1,9 @@
<ul>
<li>ID: <%= post.id %></li>
<li>Uploader: <%= link_to_unless(post.uploader.nil?, post.uploader_name, user_path(post.uploader)) %></li>
<li>Uploader: <%= link_to_unless(post.uploader.nil?, post.uploader_name, user_path(post.uploader), { :class => post.uploader.level_class }) %></li>
<li>Date: <%= link_to time_ago_in_words_tagged(post.created_at), posts_path(:tags => "date:#{post.created_at.to_date}") %></li>
<% if post.approver %>
<li>Approver: <%= link_to(post.approver.name, user_path(post.approver_id)) %></li>
<li>Approver: <%= link_to(post.approver.name, user_path(post.approver_id), { :class => post.approver.level_class }) %></li>
<% end %>
<li>
Size: <%= link_to_if Danbooru.config.can_user_see_post?(CurrentUser.user, post), number_to_human_size(post.file_size), post.file_url %>

View File

@@ -15,8 +15,8 @@
<tbody>
<% @user_feedbacks.each do |feedback| %>
<tr class="feedback-category-<%= feedback.category %>">
<td><%= link_to feedback.user_name, user_path(feedback.user_id) %></td>
<td><%= link_to feedback.creator_name, user_path(feedback.creator_id) %></td>
<td><%= link_to feedback.user_name, user_path(feedback.user_id), { :class => feedback.user.level_class } %></td>
<td><%= link_to feedback.creator_name, user_path(feedback.creator_id), { :class => feedback.creator.level_class } %></td>
<td><%= compact_time(feedback.created_at) %></td>
<td><%= format_text(feedback.body) %></td>
<td>

View File

@@ -30,9 +30,9 @@
<% end %>
</td>
<td>
<%= link_to user.pretty_name, user_path(user.id) %>
<%= link_to user.pretty_name, user_path(user.id), { :class => user.level_class } %>
<% if user.inviter %>
&larr; <%= link_to user.inviter.name, user_path(user.inviter_id) %>
&larr; <%= link_to user.inviter.name, user_path(user.inviter_id), { :class => user.inviter.level_class } %>
<% end %>
</td>
<td><%= link_to user.posts.count, posts_path(:tags => "user:#{user.name}") %></td>

View File

@@ -43,7 +43,7 @@
<%= compact_time(wiki_page_version.updated_at) %>
<% if wiki_page_version.updater %>
by
<%= link_to wiki_page_version.updater_name, user_path(wiki_page_version.updater) %>
<%= link_to wiki_page_version.updater_name, user_path(wiki_page_version.updater), { :class => wiki_page_version.updater.level_class } %>
<% end %>
</td>
</tr>