TagSetPresenter: refactor tag string for post edit form.
Move PostPresenter#categorized_tag_groups to TagSetPresenter#split_tag_list_text. This allows split_tag_list_text to reuse the same set of tags already fetched by the tag set presenter for the sidebar. This avoids a memcache call to get the tag categories when rendering the tag string for the post edit form.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class PostPresenter < Presenter
|
||||
attr_reader :pool, :next_post_in_pool
|
||||
delegate :tag_list_html, :split_tag_list_html, :inline_tag_list_html, to: :tag_set_presenter
|
||||
delegate :tag_list_html, :split_tag_list_html, :split_tag_list_text, :inline_tag_list_html, to: :tag_set_presenter
|
||||
|
||||
def self.preview(post, options = {})
|
||||
if post.nil?
|
||||
@@ -151,22 +151,6 @@ class PostPresenter < Presenter
|
||||
"#{humanized_essential_tag_string} - #{@post.md5}.#{@post.file_ext}"
|
||||
end
|
||||
|
||||
def categorized_tag_groups
|
||||
string = []
|
||||
|
||||
TagCategory.categorized_list.each do |category|
|
||||
if @post.typed_tags(category).any?
|
||||
string << @post.typed_tags(category).join(" ")
|
||||
end
|
||||
end
|
||||
|
||||
string
|
||||
end
|
||||
|
||||
def categorized_tag_string
|
||||
categorized_tag_groups.join(" \n")
|
||||
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", "https://danbooru.donmai.us") # XXX don't hardcode.
|
||||
|
||||
Reference in New Issue
Block a user