add post previews to user profile, improved ui for tag subscriptions
This commit is contained in:
@@ -2,6 +2,28 @@
|
||||
|
||||
div#c-users {
|
||||
div#a-show {
|
||||
div.grid {
|
||||
div.col {
|
||||
float: left;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
div.box {
|
||||
clear: both;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
/* clearfix hacks */
|
||||
div.box:before, div.box:after {
|
||||
content: "";
|
||||
display: table;
|
||||
}
|
||||
|
||||
div.box:after {
|
||||
clear: both;
|
||||
}
|
||||
}
|
||||
|
||||
dl {
|
||||
dt {
|
||||
width: 12em;
|
||||
|
||||
@@ -6,6 +6,7 @@ class TagSubscription < ActiveRecord::Base
|
||||
before_save :limit_tag_count
|
||||
attr_accessible :name, :tag_query, :post_ids, :is_public, :is_visible_on_profile
|
||||
validates_presence_of :name, :tag_query, :is_public, :creator_id
|
||||
validate :creator_can_create_subscriptions
|
||||
|
||||
def normalize_name
|
||||
self.name = name.gsub(/\W/, "_")
|
||||
@@ -18,6 +19,15 @@ class TagSubscription < ActiveRecord::Base
|
||||
def initialize_post_ids
|
||||
process
|
||||
end
|
||||
|
||||
def creator_can_create_subscriptions
|
||||
if TagSubscription.owned_by(creator).count >= Danbooru.config.max_tag_subscriptions
|
||||
self.errors.add(:creator, "can subscribe up to #{Danbooru.config.max_tag_subscriptions} tags")
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
def tag_query_array
|
||||
Tag.scan_query(tag_query)
|
||||
@@ -94,10 +104,10 @@ class TagSubscription < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.find_post_ids(user_id, name = nil, limit = Danbooru.config.tag_subscription_post_limit)
|
||||
relation = where(["creator_id = ?", user_id])
|
||||
relation = where("creator_id = ?", user_id)
|
||||
|
||||
if name
|
||||
relation = relation.where(["name ILIKE ? ESCAPE E'\\\\'", name.to_escaped_for_sql_like])
|
||||
relation = relation.where("name ILIKE ? ESCAPE E'\\\\'", name.to_escaped_for_sql_like)
|
||||
end
|
||||
|
||||
relation.each do |tag_sub|
|
||||
|
||||
@@ -25,10 +25,16 @@ class UserPresenter
|
||||
end
|
||||
end
|
||||
|
||||
def tag_subscriptions(template)
|
||||
user.subscriptions.map do |subscription|
|
||||
template.link_to(subscription.name, template.tag_subscription_path(subscription))
|
||||
end.join("; ")
|
||||
def tag_subscriptions
|
||||
if CurrentUser.user.id == user.id
|
||||
user.subscriptions
|
||||
else
|
||||
user.subscriptions.select {|x| x.is_public?}
|
||||
end
|
||||
end
|
||||
|
||||
def posts_for_subscription(subscription)
|
||||
Post.where("id in (?)", subscription.post_id_array.slice(0, 6).map(&:to_i))
|
||||
end
|
||||
|
||||
def upload_limit
|
||||
@@ -57,39 +63,55 @@ class UserPresenter
|
||||
return string
|
||||
end
|
||||
|
||||
def uploads(template)
|
||||
def uploads
|
||||
@uploads ||= Post.where("uploader_id = ?", user.id).order("id desc").limit(6)
|
||||
end
|
||||
|
||||
def has_uploads?
|
||||
user.post_upload_count > 0
|
||||
end
|
||||
|
||||
def favorites
|
||||
@favorites ||= user.favorites.limit(6).includes(:post).map(&:post)
|
||||
end
|
||||
|
||||
def has_favorites?
|
||||
user.favorite_count > 0
|
||||
end
|
||||
|
||||
def upload_count(template)
|
||||
template.link_to(user.post_upload_count, template.posts_path(:tags => "user:#{user.name}"))
|
||||
end
|
||||
|
||||
def deleted_uploads(template)
|
||||
def deleted_upload_count(template)
|
||||
template.link_to(Post.for_user(user.id).deleted.count, template.posts_path(:tags => "status:deleted user:#{user.name}"))
|
||||
end
|
||||
|
||||
def favorites(template)
|
||||
def favorite_count(template)
|
||||
template.link_to(user.favorite_count, template.posts_path(:tags => "fav:#{user.name}"))
|
||||
end
|
||||
|
||||
def comments(template)
|
||||
def comment_count(template)
|
||||
template.link_to(Comment.for_creator(user.id).count, template.comments_path(:search => {:creator_id => user.id}))
|
||||
end
|
||||
|
||||
def post_versions(template)
|
||||
def post_version_count(template)
|
||||
template.link_to(user.post_update_count, template.post_versions_path(:search => {:updater_id => user.id}))
|
||||
end
|
||||
|
||||
def note_versions(template)
|
||||
def note_version_count(template)
|
||||
template.link_to(user.note_update_count, template.note_versions_path(:search => {:updater_id => user.id}))
|
||||
end
|
||||
|
||||
def wiki_page_versions(template)
|
||||
def wiki_page_version_count(template)
|
||||
template.link_to(WikiPageVersion.for_user(user.id).count, template.wiki_page_versions_path(:search => {:updater_id => user.id}))
|
||||
end
|
||||
|
||||
def forum_posts(template)
|
||||
def forum_post_count(template)
|
||||
template.link_to(ForumPost.for_user(user.id).count, template.forum_posts_path(:search => {:creator_id => user.id}))
|
||||
end
|
||||
|
||||
def pool_versions(template)
|
||||
def pool_version_count(template)
|
||||
template.link_to(PoolVersion.for_user(user.id).count, template.pool_versions_path(:search => {:updater_id => user.id}))
|
||||
end
|
||||
|
||||
@@ -101,7 +123,7 @@ class UserPresenter
|
||||
end
|
||||
end
|
||||
|
||||
def approvals(template)
|
||||
def approval_count(template)
|
||||
template.link_to(Post.where("approver_id = ?", user.id).count, template.posts_path(:tags => "approver:#{user.name}"))
|
||||
end
|
||||
|
||||
@@ -113,15 +135,17 @@ class UserPresenter
|
||||
template.link_to("positive:#{positive} neutral:#{neutral} negative:#{negative}", template.user_feedbacks_path(:search => {:user_id => user.id}))
|
||||
end
|
||||
|
||||
def subscriptions(template)
|
||||
if user.subscriptions.any?
|
||||
str = user.subscriptions.map do |subscription|
|
||||
template.link_to(subscription.name, template.posts_path(:tags => "sub:#{user.name}:#{subscription.name}"))
|
||||
end.join(", ")
|
||||
str += " [" + template.link_to("edit", template.tag_subscriptions_path) + "]"
|
||||
str.html_safe
|
||||
else
|
||||
"None"
|
||||
end
|
||||
def subscriptions
|
||||
user.subscriptions
|
||||
#
|
||||
# if user.subscriptions.any?
|
||||
# str = user.subscriptions.map do |subscription|
|
||||
# template.link_to(subscription.name, template.posts_path(:tags => "sub:#{user.name}:#{subscription.name}"))
|
||||
# end.join(", ")
|
||||
# str += " [" + template.link_to("edit", template.tag_subscriptions_path) + "]"
|
||||
# str.html_safe
|
||||
# else
|
||||
# "None"
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<h1>Tags</h1>
|
||||
<%= @post_set.presenter.tag_list_html(self) %>
|
||||
</section>
|
||||
|
||||
|
||||
<%= render "posts/partials/index/blacklist" %>
|
||||
<%= render "posts/partials/index/related" %>
|
||||
</aside>
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
<section id="related-box">
|
||||
<h1>Related Searches</h1>
|
||||
<h1>Related</h1>
|
||||
<ul id="related-list">
|
||||
<% if @post_set.has_deleted? %>
|
||||
<li><%= link_to "Deleted", posts_path(:tags => "#{params[:tags]} status:deleted") %></li>
|
||||
<li><%= link_to "Deleted posts", posts_path(:tags => "#{params[:tags]} status:deleted") %></li>
|
||||
<% end %>
|
||||
|
||||
<% if @post_set.is_tag_subscription? %>
|
||||
<li><%= link_to "Edit tag subscription", tag_subscriptions_path %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
@@ -2,60 +2,106 @@
|
||||
<div id="a-show">
|
||||
<h1><%= @presenter.name %></h1>
|
||||
|
||||
<dl>
|
||||
<dt>Join Date</dt>
|
||||
<dd><%= @presenter.join_date %></dd>
|
||||
<div class="grid">
|
||||
<div class="col">
|
||||
<div class="box">
|
||||
<h2><%= link_to "Uploads", posts_path(:tags => "user:#{@user.name}") %></h2>
|
||||
<% if @presenter.has_uploads? %>
|
||||
<div>
|
||||
<% @presenter.uploads.each do |post| %>
|
||||
<%= PostPresenter.preview(post) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<p>None</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<h2><%= link_to "Favorites", posts_path(:tags => "fav:#{@user.name}") %></h2>
|
||||
<% if @presenter.has_favorites? %>
|
||||
<div>
|
||||
<% @presenter.favorites.each do |post| %>
|
||||
<%= PostPresenter.preview(post) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<p>None</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<h2>Subscriptions</h2>
|
||||
<% @presenter.subscriptions.each do |subscription| %>
|
||||
<div class="box">
|
||||
<h3><%= link_to subscription.name, posts_path(:tags => "sub:#{@user.name}:#{subscription.name}") %></h3>
|
||||
|
||||
<div>
|
||||
<% @presenter.posts_for_subscription(subscription).each do |post| %>
|
||||
<%= PostPresenter.preview(post) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<dt>Inviter</dt>
|
||||
<dd><%= @presenter.inviter(self) %></dd>
|
||||
|
||||
<dt>Level</dt>
|
||||
<dd><%= @presenter.level %></dd>
|
||||
|
||||
<% if @user.is_banned? %>
|
||||
<dt>Ban reason</dt>
|
||||
<dd><%= @presenter.ban_reason %></dd>
|
||||
<% end %>
|
||||
|
||||
<dt>Upload Limit</dt>
|
||||
<dd><%= @presenter.upload_limit %></dd>
|
||||
<div class="col">
|
||||
<h2>Statistics</h2>
|
||||
<dl>
|
||||
<dt>Join Date</dt>
|
||||
<dd><%= @presenter.join_date %></dd>
|
||||
|
||||
<dt>Uploads</dt>
|
||||
<dd><%= @presenter.uploads(self) %></dd>
|
||||
<dt>Inviter</dt>
|
||||
<dd><%= @presenter.inviter(self) %></dd>
|
||||
|
||||
<dt>Deleted Uploads</dt>
|
||||
<dd><%= @presenter.deleted_uploads(self) %></dd>
|
||||
<dt>Level</dt>
|
||||
<dd><%= @presenter.level %></dd>
|
||||
|
||||
<dt>Favorites</dt>
|
||||
<dd><%= @presenter.favorites(self) %></dd>
|
||||
<% if @user.is_banned? %>
|
||||
<dt>Ban reason</dt>
|
||||
<dd><%= @presenter.ban_reason %></dd>
|
||||
<% end %>
|
||||
|
||||
<dt>Subscriptions</dt>
|
||||
<dd><%= @presenter.subscriptions(self) %></dd>
|
||||
<dt>Upload Limit</dt>
|
||||
<dd><%= @presenter.upload_limit %></dd>
|
||||
|
||||
<dt>Post Changes</dt>
|
||||
<dd><%= @presenter.post_versions(self) %></dd>
|
||||
<dt>Uploads</dt>
|
||||
<dd><%= @presenter.upload_count(self) %></dd>
|
||||
|
||||
<dt>Note Changes</dt>
|
||||
<dd><%= @presenter.note_versions(self) %></dd>
|
||||
<dt>Deleted Uploads</dt>
|
||||
<dd><%= @presenter.deleted_upload_count(self) %></dd>
|
||||
|
||||
<dt>Wiki Page Changes</dt>
|
||||
<dd><%= @presenter.wiki_page_versions(self) %></dd>
|
||||
<dt>Favorites</dt>
|
||||
<dd><%= @presenter.favorite_count(self) %></dd>
|
||||
|
||||
<dt>Pool Changes</dt>
|
||||
<dd><%= @presenter.pool_versions(self) %></dd>
|
||||
<dt>Post Changes</dt>
|
||||
<dd><%= @presenter.post_version_count(self) %></dd>
|
||||
|
||||
<dt>Forum Posts</dt>
|
||||
<dd><%= @presenter.forum_posts(self) %></dd>
|
||||
<dt>Note Changes</dt>
|
||||
<dd><%= @presenter.note_version_count(self) %></dd>
|
||||
|
||||
<dt>Approvals</dt>
|
||||
<dd><%= @presenter.approvals(self) %></dd>
|
||||
|
||||
<dt>Comments</dt>
|
||||
<dd><%= @presenter.comments(self) %></dd>
|
||||
<dt>Wiki Page Changes</dt>
|
||||
<dd><%= @presenter.wiki_page_version_count(self) %></dd>
|
||||
|
||||
<dt>Feedback</dt>
|
||||
<dd><%= @presenter.feedbacks(self) %></dd>
|
||||
</dl>
|
||||
<dt>Pool Changes</dt>
|
||||
<dd><%= @presenter.pool_version_count(self) %></dd>
|
||||
|
||||
<dt>Forum Posts</dt>
|
||||
<dd><%= @presenter.forum_post_count(self) %></dd>
|
||||
|
||||
<dt>Approvals</dt>
|
||||
<dd><%= @presenter.approval_count(self) %></dd>
|
||||
|
||||
<dt>Comments</dt>
|
||||
<dd><%= @presenter.comment_count(self) %></dd>
|
||||
|
||||
<dt>Feedback</dt>
|
||||
<dd><%= @presenter.feedbacks(self) %></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user