fixes #298
This commit is contained in:
@@ -76,7 +76,10 @@ div#c-comments {
|
|||||||
|
|
||||||
div.preview {
|
div.preview {
|
||||||
float: left;
|
float: left;
|
||||||
width: 180px;
|
width: 150px;
|
||||||
|
height: 150px;
|
||||||
|
margin-right: 30px;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.post {
|
div.post {
|
||||||
|
|||||||
@@ -114,9 +114,7 @@ div#c-posts {
|
|||||||
padding: 0.25em 0.5em;
|
padding: 0.25em 0.5em;
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
background-color: $menu_color;
|
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@include border-radius(4px);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,21 +13,22 @@ class PostPresenter < Presenter
|
|||||||
|
|
||||||
html = %{<article class="post-preview" 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="#{flags.join(' ')}" data-parent-id="#{post.parent_id}" data-has-children="#{post.has_children?}">}
|
html = %{<article class="post-preview" 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="#{flags.join(' ')}" data-parent-id="#{post.parent_id}" data-has-children="#{post.has_children?}">}
|
||||||
html << %{<a href="#{path}/#{post.id}">}
|
html << %{<a href="#{path}/#{post.id}">}
|
||||||
|
html << %{<img style="margin-left: #{margin(post)};" src="#{post.preview_file_url}" alt="#{h(post.tag_string)}">}
|
||||||
if post.is_image? && post.image_width > post.image_height && post.image_width.to_i > Danbooru.config.small_image_width
|
|
||||||
ratio = Danbooru.config.small_image_width.to_f / post.image_height.to_f
|
|
||||||
offset = ((ratio * post.image_width) - Danbooru.config.small_image_width).to_i / 2
|
|
||||||
margin = "-#{offset}px"
|
|
||||||
else
|
|
||||||
margin = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
html << %{<img style="margin-left: #{margin};" src="#{post.preview_file_url}" alt="#{h(post.tag_string)}">}
|
|
||||||
html << %{</a>}
|
html << %{</a>}
|
||||||
html << %{</article>}
|
html << %{</article>}
|
||||||
html.html_safe
|
html.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.margin(post)
|
||||||
|
if post.is_image? && post.image_width > post.image_height && post.image_width.to_i > Danbooru.config.small_image_width
|
||||||
|
ratio = Danbooru.config.small_image_width.to_f / post.image_height.to_f
|
||||||
|
offset = ((ratio * post.image_width) - Danbooru.config.small_image_width).to_i / 2
|
||||||
|
return "-#{offset}px"
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(post)
|
def initialize(post)
|
||||||
@post = post
|
@post = post
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<% @posts.each do |post| %>
|
<% @posts.each do |post| %>
|
||||||
<div class="post">
|
<div class="post">
|
||||||
<div class="preview">
|
<div class="preview">
|
||||||
<%= link_to(image_tag(post.preview_file_url), post_path(post)) %>
|
<%= link_to(image_tag(post.preview_file_url, :style => "margin-left: #{PostPresenter.margin(post)};"), post_path(post)) %>
|
||||||
</div>
|
</div>
|
||||||
<%= render "comments/partials/index/list", :post => post, :comments => post.comments.visible(CurrentUser.user).recent, :show_header => true %>
|
<%= render "comments/partials/index/list", :post => post, :comments => post.comments.visible(CurrentUser.user).recent, :show_header => true %>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user