* Continued work on improving post view templates

* Added statistics-based estimator for related tag calculator
* Fleshed out IpBan class based on changes to Danbooru 1.xx
This commit is contained in:
albert
2010-04-29 17:32:15 -04:00
parent 3666364469
commit 23656e3fa9
39 changed files with 816 additions and 86 deletions

View File

@@ -9,6 +9,10 @@ module ApplicationHelper
content_tag("li", link_to(text, url, options), :class => klass)
end
def format_text(text, options = {})
DText.parse(text)
end
protected
def nav_link_match(controller, url)
url =~ case controller

View File

@@ -1,2 +0,0 @@
module PostHelper
end

View File

@@ -0,0 +1,27 @@
module PostsHelper
def image_dimensions(post, current_user)
if post.is_image?
"(#{post.image_width_for(current_user)}x#{post.image_height_for(current_user)})"
else
""
end
end
def image_dimension_menu(post, current_user)
html = ""
file_size = number_to_human_size(post.file_size)
original_dimensions = post.is_image? ? "(#{post.image_width}x#{post.image_height})" : nil
large_dimensions = post.has_large? ? "(#{post.large_image_width}x#{post.large_image_height})" : nil
medium_dimensions = post.has_medium? ? "(#{post.medium_image_width}x#{post.medium_image_height})" : nil
current_dimensions = "(#{post.image_width_for(current_user)}x#{post.image_height_for(current_user)})"
html << %{<menu type="context" data-user-default="<%= current_user.default_image_size %>">}
html << %{<li>#{file_size} #{current_dimensions}</li>}
html << %{<ul>}
html << %{<li id="original">#{file_size} #{original_dimensions}</li>}
html << %{<li id="medium">#{file_size} #{medium_dimensions}</li>} if medium_dimensions
html << %{<li id="large">#{file_size} #{large_dimensions}</li>} if large_dimensions
html << %{</ul>}
html << %{</menu>}
html.html_safe
end
end