From f3167f1f62d7f1dc13119f6c8b5fd48f20619b7f Mon Sep 17 00:00:00 2001 From: Toks Date: Wed, 7 Aug 2013 20:07:47 -0400 Subject: [PATCH] Allow #image-container to share data attributes with previews Related to #1902 --- app/presenters/post_presenter.rb | 25 ++++++++++---------- app/views/comments/index_by_comment.html.erb | 2 +- app/views/comments/index_by_post.html.erb | 2 +- app/views/comments/show.html.erb | 2 +- app/views/posts/show.html.erb | 2 +- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index d37031ba0..f3ffa08ca 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -12,7 +12,7 @@ class PostPresenter < Presenter path = options[:path_prefix] || "/posts" - html = %{
} + html = %{
} if options[:tags].present? tag_param = "?tags=#{CGI::escape(options[:tags])}" elsif options[:pool_id] @@ -37,20 +37,19 @@ class PostPresenter < Presenter klass end - def self.preview_attributes(post) + def self.data_attributes(post) %{ - id="post_#{post.id}" - data-id="#{post.id}" - data-tags="#{h(post.tag_string)}" + data-id="#{post.id}" + data-tags="#{h(post.tag_string)}" data-pools="#{post.pool_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-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_safe end diff --git a/app/views/comments/index_by_comment.html.erb b/app/views/comments/index_by_comment.html.erb index 4fc834eee..752fa1cf4 100644 --- a/app/views/comments/index_by_comment.html.erb +++ b/app/views/comments/index_by_comment.html.erb @@ -5,7 +5,7 @@
<% @comments.each do |comment| %> -
> +
>
<% if comment.post.visible? %> <%= link_to(image_tag(comment.post.preview_file_url), post_path(comment.post)) %> diff --git a/app/views/comments/index_by_post.html.erb b/app/views/comments/index_by_post.html.erb index cde6df9ef..73db2afe3 100644 --- a/app/views/comments/index_by_post.html.erb +++ b/app/views/comments/index_by_post.html.erb @@ -12,7 +12,7 @@ <% end %> <% @posts.select {|x| Danbooru.config.can_user_see_post?(CurrentUser.user, x)}.each do |post| %> -
> +
>
<% if post.visible? %> <%= link_to(image_tag(post.preview_file_url), post_path(post)) %> diff --git a/app/views/comments/show.html.erb b/app/views/comments/show.html.erb index a2a227d86..79ddc57a6 100644 --- a/app/views/comments/show.html.erb +++ b/app/views/comments/show.html.erb @@ -2,7 +2,7 @@
-
+
>
<% if @comment.post.visible? %> <%= link_to(image_tag(@comment.post.preview_file_url), post_path(@comment.post)) %> diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index 6a42f6f5b..e0638eb7a 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -40,7 +40,7 @@ <%= render "posts/partials/show/notices", :post => @post %> -
+
>
<%= @post.presenter.image_html(self) %>