changes
This commit is contained in:
@@ -68,10 +68,18 @@ class Post < ActiveRecord::Base
|
|||||||
def file_url_for(user)
|
def file_url_for(user)
|
||||||
case user.default_image_size
|
case user.default_image_size
|
||||||
when "medium"
|
when "medium"
|
||||||
medium_file_url
|
if image_width > Danbooru.config.medium_image_width
|
||||||
|
medium_file_url
|
||||||
|
else
|
||||||
|
file_url
|
||||||
|
end
|
||||||
|
|
||||||
when "large"
|
when "large"
|
||||||
large_file_url
|
if image_width > Danbooru.config.large_image_width
|
||||||
|
large_file_url
|
||||||
|
else
|
||||||
|
file_url
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
file_url
|
file_url
|
||||||
@@ -81,10 +89,18 @@ class Post < ActiveRecord::Base
|
|||||||
def file_path_for(user)
|
def file_path_for(user)
|
||||||
case user.default_image_size
|
case user.default_image_size
|
||||||
when "medium"
|
when "medium"
|
||||||
medium_file_path
|
if image_width > Danbooru.config.medium_image_width
|
||||||
|
medium_file_path
|
||||||
|
else
|
||||||
|
file_path
|
||||||
|
end
|
||||||
|
|
||||||
when "large"
|
when "large"
|
||||||
large_file_path
|
if image_width > Danbooru.config.large_image_width
|
||||||
|
large_file_path
|
||||||
|
else
|
||||||
|
file_path
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
file_path
|
file_path
|
||||||
@@ -94,6 +110,10 @@ class Post < ActiveRecord::Base
|
|||||||
def is_image?
|
def is_image?
|
||||||
file_ext =~ /jpg|gif|png/
|
file_ext =~ /jpg|gif|png/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_flash?
|
||||||
|
file_ext =~ /swf/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module ImageMethods
|
module ImageMethods
|
||||||
@@ -105,13 +125,39 @@ class Post < ActiveRecord::Base
|
|||||||
image_width > Danbooru.config.large_image_width
|
image_width > Danbooru.config.large_image_width
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def medium_image_width
|
||||||
|
[Danbooru.config.medium_image_width, image_width].min
|
||||||
|
end
|
||||||
|
|
||||||
|
def large_image_width
|
||||||
|
[Danbooru.config.large_image_width, image_width].min
|
||||||
|
end
|
||||||
|
|
||||||
|
def medium_image_height
|
||||||
|
ratio = Danbooru.config.medium_image_width.to_f / image_width.to_f
|
||||||
|
if ratio < 1
|
||||||
|
image_height * ratio
|
||||||
|
else
|
||||||
|
image_height
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def large_image_height
|
||||||
|
ratio = Danbooru.config.large_image_width.to_f / image_width.to_f
|
||||||
|
if ratio < 1
|
||||||
|
image_height * ratio
|
||||||
|
else
|
||||||
|
image_height
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def image_width_for(user)
|
def image_width_for(user)
|
||||||
case user.default_image_size
|
case user.default_image_size
|
||||||
when "medium"
|
when "medium"
|
||||||
[Danbooru.config.medium_image_width, image_width].min
|
medium_image_width
|
||||||
|
|
||||||
when "large"
|
when "large"
|
||||||
[Danbooru.config.large_image_width, image_width].min
|
large_image_width
|
||||||
|
|
||||||
else
|
else
|
||||||
image_width
|
image_width
|
||||||
@@ -121,17 +167,11 @@ class Post < ActiveRecord::Base
|
|||||||
def image_height_for(user)
|
def image_height_for(user)
|
||||||
case user.default_image_size
|
case user.default_image_size
|
||||||
when "medium"
|
when "medium"
|
||||||
ratio = Danbooru.config.medium_image_width.to_f / image_width.to_f
|
medium_image_height
|
||||||
|
|
||||||
when "large"
|
when "large"
|
||||||
ratio = Danbooru.config.large_image_width.to_f / image_width.to_f
|
large_image_height
|
||||||
|
|
||||||
else
|
|
||||||
ratio = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if ratio < 1
|
|
||||||
image_height * ratio
|
|
||||||
else
|
else
|
||||||
image_height
|
image_height
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
class PostPresenter < Presenter
|
class PostPresenter < Presenter
|
||||||
def initialize(post, current_user)
|
def initialize(post)
|
||||||
@post = post
|
@post = post
|
||||||
@current_user = current_user
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_list_html
|
def tag_list_html
|
||||||
end
|
end
|
||||||
|
|
||||||
def image_html(template)
|
def image_html(template, current_user)
|
||||||
return "" if @post.is_deleted? && !@current_user.is_janitor?
|
return "" if @post.is_deleted? && !current_user.is_janitor?
|
||||||
|
|
||||||
if @post.is_flash?
|
if @post.is_flash?
|
||||||
template.render(:partial => "posts/flash", :locals => {:post => @post})
|
template.render(:partial => "posts/flash", :locals => {:post => @post})
|
||||||
elsif @post.is_image?
|
elsif @post.is_image?
|
||||||
template.image_tag(
|
template.image_tag(
|
||||||
@post.file_path_for(@current_user),
|
@post.file_url_for(current_user),
|
||||||
:width => @post.image_width_for(@current_user),
|
:alt => @post.tag_string,
|
||||||
:height => @post.image_height_for(@current_user),
|
:width => @post.image_width_for(current_user),
|
||||||
|
:height => @post.image_height_for(current_user),
|
||||||
"data-original-width" => @post.image_width,
|
"data-original-width" => @post.image_width,
|
||||||
"data-original-height" => @post.image_height
|
"data-original-height" => @post.image_height
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -14,41 +14,12 @@
|
|||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h1>Information</h1>
|
<h1>Information</h1>
|
||||||
<ul>
|
<%= render :partial => "information", :locals => {:post => @post} %>
|
||||||
<li>Id: <%= @post.id %></li>
|
|
||||||
<li>Uploaded <%= time_ago_in_words(@post.created_at) %> ago by <%= link_to_unless(@post.uploader.nil?, @post.uploader_name, user_path(@post.uploader)) %></li>
|
|
||||||
<% if @post.approver %>
|
|
||||||
<li>Approver: <%= @post.approver.name %></li>
|
|
||||||
<% end %>
|
|
||||||
<% if @post.is_image? %>
|
|
||||||
<li>
|
|
||||||
[M]
|
|
||||||
[L]
|
|
||||||
[O]
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
<li><%= link_to "Tag History", post_versions_path(:post_id => @post) %></li>
|
|
||||||
<li><%= link_to "Note History", note_versions_path(:post_id => @post) %></li>
|
|
||||||
</ul>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h1>Options</h1>
|
<h1>Options</h1>
|
||||||
<menu>
|
<%= render :partial => "options", :locals => {:post => @post} %>
|
||||||
<% if !@post.is_deleted? && @post.is_image? && @post.image_width && @post.image_width > 700 %>
|
|
||||||
<li><%= link_to "Resize", "#" %></li>
|
|
||||||
<% end %>
|
|
||||||
<li><%= link_to "Favorite", "#" %></li>
|
|
||||||
<li><%= link_to "Unfavorite", "#" %></li>
|
|
||||||
<li><%= link_to "Add translation", "#" %></li>
|
|
||||||
<li><%= link_to "Unapprove", "#" %></li>
|
|
||||||
<% if @current_user.is_janitor? %>
|
|
||||||
<li><%= link_to "Approve", "#" %></li>
|
|
||||||
<li><%= link_to "Undelete", "#" %></li>
|
|
||||||
<li><%= link_to "Delete", "#" %></li>
|
|
||||||
<% end %>
|
|
||||||
<li><%= link_to "Add to Pool", "#" %></li>
|
|
||||||
</menu>
|
|
||||||
</section>
|
</section>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
@@ -57,7 +28,7 @@
|
|||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h2>Image</h2>
|
<h2>Image</h2>
|
||||||
<%= @post.presenter.image_html %>
|
<%= @post.presenter.image_html(self, @current_user) %>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
|||||||
Reference in New Issue
Block a user