This commit is contained in:
Toks
2013-04-28 08:36:55 -04:00
parent 5706a8e488
commit 4de5e7eee7
4 changed files with 14 additions and 11 deletions

View File

@@ -14,14 +14,7 @@ class PostPresenter < Presenter
path = options[:path_prefix] || "/posts"
klass = "post-preview"
klass << " post-status-pending" if post.is_pending?
klass << " post-status-flagged" if post.is_flagged?
klass << " post-status-deleted" if post.is_deleted?
klass << " post-status-has-parent" if post.parent_id
klass << " post-status-has-children" if post.has_children?
html = %{<article class="#{klass}" id="post_#{post.id}" data-id="#{post.id}" data-tags="#{h(post.tag_string)}" data-uploader="#{h(post.uploader_name)}" data-rating="#{post.rating}" data-width="#{post.image_width}" data-height="#{post.image_height}" data-flags="#{post.status_flags}" data-parent-id="#{post.parent_id}" data-has-children="#{post.has_children?}" data-score="#{post.score}" data-fav-count="#{post.fav_count}">}
html = %{<article class="#{preview_class(post)}" id="post_#{post.id}" data-id="#{post.id}" data-tags="#{h(post.tag_string)}" data-uploader="#{h(post.uploader_name)}" data-rating="#{post.rating}" data-width="#{post.image_width}" data-height="#{post.image_height}" data-flags="#{post.status_flags}" data-parent-id="#{post.parent_id}" data-has-children="#{post.has_children?}" data-score="#{post.score}" data-fav-count="#{post.fav_count}">}
if options[:tags].present?
tag_param = "?tags=#{CGI::escape(options[:tags])}"
elsif options[:pool_id]
@@ -36,6 +29,16 @@ class PostPresenter < Presenter
html.html_safe
end
def self.preview_class(post)
klass = "post-preview"
klass << " post-status-pending" if post.is_pending?
klass << " post-status-flagged" if post.is_flagged?
klass << " post-status-deleted" if post.is_deleted?
klass << " post-status-has-parent" if post.parent_id
klass << " post-status-has-children" if post.has_children?
klass
end
def initialize(post)
@post = post
end

View File

@@ -5,7 +5,7 @@
<div class="comments-for-post">
<div class="list-of-comments">
<% @comments.each do |comment| %>
<div class="post post-preview" data-tags="<%= comment.post.tag_string %>" data-uploader="<%= comment.post.uploader_name %>" data-rating="<%= comment.post.rating %>" data-flags="<%= comment.post.status %>" data-score="<%= comment.post.score %>" data-parent-id="<%= comment.post.parent_id %>" data-has-children="<%= comment.post.has_children? %>">
<div class="post <%= PostPresenter.preview_class(comment.post) %>" data-tags="<%= comment.post.tag_string %>" data-uploader="<%= comment.post.uploader_name %>" data-rating="<%= comment.post.rating %>" data-flags="<%= comment.post.status %>" data-score="<%= comment.post.score %>" data-parent-id="<%= comment.post.parent_id %>" data-has-children="<%= comment.post.has_children? %>">
<div class="preview">
<%= link_to(image_tag(comment.post.preview_file_url), post_path(comment.post)) %>
</div>

View File

@@ -7,7 +7,7 @@
<% end %>
<% @posts.select {|x| Danbooru.config.can_user_see_post?(CurrentUser.user, x)}.each do |post| %>
<div class="post post-preview" data-tags="<%= post.tag_string %>" data-uploader="<%= post.uploader_name %>" data-rating="<%= post.rating %>" data-flags="<%= post.status %>" data-score="<%= post.score %>" data-parent-id="<%= post.parent_id %>" data-has-children="<%= post.has_children? %>" data-id="<%= post.id %>" data-width="<%= post.image_width %>" data-height="<%= post.image_height %>">
<div class="post <%= PostPresenter.preview_class(post) %>" data-tags="<%= post.tag_string %>" data-uploader="<%= post.uploader_name %>" data-rating="<%= post.rating %>" data-flags="<%= post.status %>" data-score="<%= post.score %>" data-parent-id="<%= post.parent_id %>" data-has-children="<%= post.has_children? %>" data-id="<%= post.id %>" data-width="<%= post.image_width %>" data-height="<%= post.image_height %>">
<div class="preview">
<%= link_to(image_tag(post.preview_file_url), post_path(post)) %>
</div>

View File

@@ -2,7 +2,7 @@
<div id="a-show">
<div class="comments-for-post">
<div class="list-of-comments">
<div class="post post-preview" data-tags="<%= @comment.post.tag_string %>" data-uploader="<%= @comment.post.uploader_name %>" data-rating="<%= @comment.post.rating %>" data-flags="<%= @comment.post.status %>" data-score="<%= @comment.post.score %>" data-parent-id="<%= @comment.post.parent_id %>" data-has-children="<%= @comment.post.has_children? %>">
<div class="post <%= PostPresenter.preview_class(@comment.post) %>" data-tags="<%= @comment.post.tag_string %>" data-uploader="<%= @comment.post.uploader_name %>" data-rating="<%= @comment.post.rating %>" data-flags="<%= @comment.post.status %>" data-score="<%= @comment.post.score %>" data-parent-id="<%= @comment.post.parent_id %>" data-has-children="<%= @comment.post.has_children? %>">
<div class="preview">
<%= link_to(image_tag(@comment.post.preview_file_url), post_path(@comment.post)) %>
</div>