diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 865d12eef..bccd84089 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -1,5 +1,6 @@ class PostPresenter < Presenter attr_reader :pool, :next_post_in_pool + delegate :tag_list_html, :split_tag_list_html, :inline_tag_list_html, :split_inline_tag_list_html, to: :tag_set_presenter def self.preview(post, options = {}) if post.nil? @@ -162,10 +163,6 @@ class PostPresenter < Presenter categorized_tag_groups.join(" \n") end - def humanized_categorized_tag_string - categorized_tag_groups.flatten.slice(0, 25).join(", ").tr("_", " ") - end - def safe_mode_message(template) html = ["This image is unavailable on safe mode (#{Danbooru.config.app_name}). Go to "] html << template.link_to("Danbooru", "http://danbooru.donmai.us") # XXX don't hardcode. @@ -193,18 +190,6 @@ class PostPresenter < Presenter end end - def tag_list_html(template, options = {}) - tag_set_presenter.tag_list_html(template, options.merge(:show_extra_links => CurrentUser.user.is_gold?)) - end - - def split_tag_list_html(template, options = {}) - tag_set_presenter.split_tag_list_html(template, options.merge(:show_extra_links => CurrentUser.user.is_gold?)) - end - - def inline_tag_list_html(template) - tag_set_presenter.inline_tag_list(template) - end - def has_nav_links?(template) has_sequential_navigation?(template.params) || @post.pools.undeleted.any? || @post.favorite_groups(active_id=template.params[:favgroup_id]).any? end diff --git a/app/presenters/tag_set_presenter.rb b/app/presenters/tag_set_presenter.rb index 4f149055c..b6e4b1e93 100644 --- a/app/presenters/tag_set_presenter.rb +++ b/app/presenters/tag_set_presenter.rb @@ -22,16 +22,16 @@ class TagSetPresenter < Presenter html.html_safe end - def split_tag_list_html(template, options = {}) + def split_tag_list_html(template, category_list: TagCategory.split_header_list, headers: true, **options) html = "" - TagCategory.split_header_list.each do |category| + category_list.each do |category| typetags = typed_tags(category) if typetags.any? - html << TagCategory.header_mapping[category] + html << TagCategory.header_mapping[category] if headers html << %{" end @@ -41,7 +41,7 @@ class TagSetPresenter < Presenter end # compact (horizontal) list, as seen in the /comments index. - def inline_tag_list(template) + def inline_tag_list_html(template) @tags.map do |tag_name| <<-EOS @@ -51,7 +51,8 @@ class TagSetPresenter < Presenter end.join.html_safe end -private + private + def typed_tags(name) @typed_tags ||= {} @typed_tags[name] ||= begin @@ -72,34 +73,33 @@ private end end - def build_list_item(tag, template, options) + 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] || "" - unless options[:name_only] + unless name_only if categories[tag] == Tag.categories.artist html << %{? } else html << %{? } end - if CurrentUser.user.is_gold? && current_query.present? + if show_extra_links && current_query.present? html << %{+ } html << %{ } end end - humanized_tag = tag.tr("_", " ") - path = options[:path_prefix] || "/posts" + humanized_tag = humanize_tags ? tag.tr("_", " ") : tag if categories[tag] == Tag.categories.artist itemprop = 'itemprop="author"' else itemprop = nil end - html << %{#{h(humanized_tag)} } + html << %{#{h(humanized_tag)} } - unless options[:name_only] + unless name_only if counts[tag].to_i >= 10_000 post_count = "#{counts[tag].to_i / 1_000}k" elsif counts[tag].to_i >= 1_000 diff --git a/app/views/uploads/index.html.erb b/app/views/uploads/index.html.erb index f68c2be31..f092c4754 100644 --- a/app/views/uploads/index.html.erb +++ b/app/views/uploads/index.html.erb @@ -49,7 +49,7 @@ Tags - <%= TagSetPresenter.new(upload.tag_string.split).inline_tag_list(self) %> + <%= TagSetPresenter.new(upload.tag_string.split).inline_tag_list_html(self) %>