diff --git a/app/presenters/post_set_presenters/favorite.rb b/app/presenters/post_set_presenters/favorite.rb
index 0d726b276..f08e454a1 100644
--- a/app/presenters/post_set_presenters/favorite.rb
+++ b/app/presenters/post_set_presenters/favorite.rb
@@ -1,7 +1,8 @@
module PostSetPresenters
class Favorite < Base
attr_accessor :post_set, :tag_set_presenter
- delegate :favorites, :to => :post_set
+ delegate :favorites, :posts, :to => :post_set
+ delegate :tag_list_html, to: :tag_set_presenter
def initialize(post_set)
@post_set = post_set
@@ -11,13 +12,5 @@ module PostSetPresenters
).map {|x| x[0]}
)
end
-
- def tag_list_html(template)
- tag_set_presenter.tag_list_html(template)
- end
-
- def posts
- @posts ||= post_set.posts
- end
end
end
diff --git a/app/presenters/post_set_presenters/pool.rb b/app/presenters/post_set_presenters/pool.rb
index 4bba321ed..798ec4d6b 100644
--- a/app/presenters/post_set_presenters/pool.rb
+++ b/app/presenters/post_set_presenters/pool.rb
@@ -12,10 +12,6 @@ module PostSetPresenters
)
end
- def tag_list_html(template)
- tag_set_presenter.tag_list_html(template)
- end
-
def post_previews_html(template)
html = ""
diff --git a/app/presenters/post_set_presenters/post.rb b/app/presenters/post_set_presenters/post.rb
index fbb7b473d..c0d62b13b 100644
--- a/app/presenters/post_set_presenters/post.rb
+++ b/app/presenters/post_set_presenters/post.rb
@@ -67,12 +67,8 @@ module PostSetPresenters
SavedSearch.labels_for(CurrentUser.user.id).map {|x| "search:#{x}"}
end
- def tag_list_html(template, options = {})
- if post_set.is_saved_search?
- options[:name_only] = true
- end
-
- tag_set_presenter.tag_list_html(template, options)
+ def tag_list_html(**options)
+ tag_set_presenter.tag_list_html(name_only: post_set.is_saved_search?, **options)
end
end
end
diff --git a/app/presenters/tag_set_presenter.rb b/app/presenters/tag_set_presenter.rb
index 307964484..b5cadc582 100644
--- a/app/presenters/tag_set_presenter.rb
+++ b/app/presenters/tag_set_presenter.rb
@@ -5,16 +5,18 @@
=end
class TagSetPresenter < Presenter
- def initialize(tags)
- @tags = tags
+ attr_reader :tag_names, :tags
+
+ def initialize(tag_names)
+ @tag_names = tag_names
end
- def tag_list_html(template, options = {})
+ def tag_list_html(current_query: "", show_extra_links: false, name_only: false)
html = ""
- if @tags.present?
+ if tag_names.present?
html << '
'
- @tags.each do |tag|
- html << build_list_item(tag, template, options)
+ tag_names.each do |tag|
+ html << build_list_item(tag, current_query: current_query, show_extra_links: show_extra_links, name_only: name_only)
end
html << "
"
end
@@ -22,7 +24,7 @@ class TagSetPresenter < Presenter
html.html_safe
end
- def split_tag_list_html(template, category_list: TagCategory.split_header_list, headers: true, **options)
+ def split_tag_list_html(headers: true, category_list: TagCategory.split_header_list, current_query: "", show_extra_links: false, name_only: false, humanize_tags: true)
html = ""
category_list.each do |category|
@@ -31,7 +33,7 @@ class TagSetPresenter < Presenter
html << TagCategory.header_mapping[category] if headers
html << %{}
typetags.each do |tag|
- html << build_list_item(tag, template, **options)
+ html << build_list_item(tag, current_query: current_query, show_extra_links: show_extra_links, name_only: name_only, humanize_tags: humanize_tags)
end
html << "
"
end
@@ -41,9 +43,9 @@ class TagSetPresenter < Presenter
end
# compact (horizontal) list, as seen in the /comments index.
- def inline_tag_list_html(template, classes: "inline-tag-list", **options)
- html = split_tag_list_html(template, category_list: TagCategory.categorized_list, headers: false, name_only: true, humanize_tags: true, **options)
- template.tag.span(html, class: classes)
+ def inline_tag_list_html(humanize_tags: true)
+ html = split_tag_list_html(category_list: TagCategory.categorized_list, headers: false, show_extra_links: false, name_only: true, humanize_tags: humanize_tags)
+ %{#{html}}.html_safe
end
private
@@ -51,27 +53,25 @@ class TagSetPresenter < Presenter
def typed_tags(name)
@typed_tags ||= {}
@typed_tags[name] ||= begin
- @tags.select do |tag|
+ tag_names.select do |tag|
categories[tag] == TagCategory.mapping[name]
end
end
end
def categories
- @categories ||= Tag.categories_for(@tags)
+ @categories ||= Tag.categories_for(tag_names)
end
def counts
- @counts ||= Tag.counts_for(@tags).inject({}) do |hash, x|
+ @counts ||= Tag.counts_for(tag_names).inject({}) do |hash, x|
hash[x["name"]] = x["post_count"]
hash
end
end
- def build_list_item(tag, template, name_only: false, humanize_tags: true, show_extra_links: CurrentUser.is_gold?)
- html = ""
- html << %{}
- current_query = template.params[:tags] || ""
+ def build_list_item(tag, name_only: false, humanize_tags: true, show_extra_links: false, current_query: "")
+ html = %{}
unless name_only
if categories[tag] == Tag.categories.artist
diff --git a/app/presenters/upload_presenter.rb b/app/presenters/upload_presenter.rb
index 44a1cce2e..d132530eb 100644
--- a/app/presenters/upload_presenter.rb
+++ b/app/presenters/upload_presenter.rb
@@ -1,5 +1,12 @@
class UploadPresenter < Presenter
+ attr_reader :upload
+ delegate :inline_tag_list_html, to: :tag_set_presenter
+
def initialize(upload)
@upload = upload
end
+
+ def tag_set_presenter
+ @tag_set_presenter ||= TagSetPresenter.new(upload.tag_string.split)
+ end
end
diff --git a/app/views/comments/partials/index/_header.html.erb b/app/views/comments/partials/index/_header.html.erb
index 83c48d12a..735bc541c 100644
--- a/app/views/comments/partials/index/_header.html.erb
+++ b/app/views/comments/partials/index/_header.html.erb
@@ -26,7 +26,7 @@
Tags
- <%= post.presenter.inline_tag_list_html(self) %>
+ <%= post.presenter.inline_tag_list_html %>
diff --git a/app/views/favorites/index.html.erb b/app/views/favorites/index.html.erb
index 630e0fcbe..ea14cc280 100644
--- a/app/views/favorites/index.html.erb
+++ b/app/views/favorites/index.html.erb
@@ -9,7 +9,7 @@
Tags
- <%= @favorite_set.presenter.tag_list_html(self) %>
+ <%= @favorite_set.presenter.tag_list_html %>
diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb
index bae084e0c..a7a2ca72a 100644
--- a/app/views/posts/index.html.erb
+++ b/app/views/posts/index.html.erb
@@ -9,7 +9,7 @@
Tags
- <%= @post_set.presenter.tag_list_html(self) %>
+ <%= @post_set.presenter.tag_list_html(current_query: params[:tags], show_extra_links: CurrentUser.user.is_gold?) %>
<%= render "posts/partials/index/options" %>
diff --git a/app/views/posts/show.html+tooltip.erb b/app/views/posts/show.html+tooltip.erb
index d9d896c33..a4bf9f04c 100644
--- a/app/views/posts/show.html+tooltip.erb
+++ b/app/views/posts/show.html+tooltip.erb
@@ -46,5 +46,5 @@
<% end %>
- <%= @post.presenter.inline_tag_list_html(self, humanize_tags: false) %>
+ <%= @post.presenter.inline_tag_list_html(humanize_tags: false) %>
diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb
index dddda0107..4e9e6a440 100644
--- a/app/views/posts/show.html.erb
+++ b/app/views/posts/show.html.erb
@@ -6,7 +6,7 @@
<%= render "posts/partials/index/blacklist" %>
- <%= @post.presenter.split_tag_list_html(self) %>
+ <%= @post.presenter.split_tag_list_html(current_query: params[:tags], show_extra_links: CurrentUser.user.is_gold?) %>
diff --git a/app/views/uploads/index.html.erb b/app/views/uploads/index.html.erb
index dc526624b..70dbe995d 100644
--- a/app/views/uploads/index.html.erb
+++ b/app/views/uploads/index.html.erb
@@ -57,7 +57,7 @@
Tags
- <%= TagSetPresenter.new(upload.tag_string.split).inline_tag_list_html(self) %>
+ <%= upload.presenter.inline_tag_list_html %>
|