forked from e621ng/e621ng
Convert Tag links in PostVersions & Uploads to wiki links (#622)
This commit is contained in:
parent
1da52e3d0d
commit
2609990837
@ -29,14 +29,14 @@ module PostVersionsHelper
|
||||
|
||||
diff[:added_tags].each do |tag_name|
|
||||
classes = diff[:obsolete_added_tags].include?(tag_name) ? "obsolete" : ""
|
||||
changes << tag.ins(link_to("+#{tag_name}", posts_path(tags: tag_name)), class: classes)
|
||||
changes << tag.ins(link_to_wiki_or_new("+#{tag_name}", tag_name), class: classes)
|
||||
end
|
||||
diff[:removed_tags].each do |tag_name|
|
||||
classes = diff[:obsolete_removed_tags].include?(tag_name) ? "obsolete" : ""
|
||||
changes << tag.del(link_to("-#{tag_name}", posts_path(tags: tag_name)), class: classes)
|
||||
changes << tag.del(link_to_wiki_or_new("-#{tag_name}", tag_name), class: classes)
|
||||
end
|
||||
diff[:unchanged_tags].each do |tag_name|
|
||||
changes << tag.span(link_to(tag_name, posts_path(tags: tag_name)))
|
||||
changes << tag.span(link_to_wiki_or_new(tag_name))
|
||||
end
|
||||
|
||||
tag.span(safe_join(changes, " "), class: "diff-list")
|
||||
@ -47,13 +47,13 @@ module PostVersionsHelper
|
||||
changes = []
|
||||
|
||||
diff[:added_locked_tags].each do |tag_name|
|
||||
changes << tag.ins(link_to("+#{tag_name}", posts_path(tags: tag_name)))
|
||||
changes << tag.ins(link_to_wiki_or_new("+#{tag_name}", tag_name))
|
||||
end
|
||||
diff[:removed_locked_tags].each do |tag_name|
|
||||
changes << tag.del(link_to("-#{tag_name}", posts_path(tags: tag_name)))
|
||||
changes << tag.del(link_to_wiki_or_new("-#{tag_name}", tag_name))
|
||||
end
|
||||
diff[:unchanged_locked_tags].each do |tag_name|
|
||||
changes << tag.span(link_to(tag_name, posts_path(tags: tag_name)))
|
||||
changes << tag.span(link_to_wiki_or_new(tag_name))
|
||||
end
|
||||
|
||||
tag.span(safe_join(changes, " "), class: "diff-list")
|
||||
|
@ -7,6 +7,8 @@
|
||||
=end
|
||||
|
||||
class TagSetPresenter < Presenter
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
attr_reader :tag_names
|
||||
|
||||
# @param [Array<String>] a list of tags to present. Tags will be presented in
|
||||
@ -50,10 +52,10 @@ class TagSetPresenter < Presenter
|
||||
end
|
||||
|
||||
# compact (horizontal) list, as seen in the /comments index.
|
||||
def inline_tag_list_html
|
||||
def inline_tag_list_html(link_type = :tag)
|
||||
html = TagCategory::CATEGORIZED_LIST.map do |category|
|
||||
tags_for_category(category).map do |tag|
|
||||
%(<li class="category-#{tag.category}">#{tag_link(tag)}</li>)
|
||||
%(<li class="category-#{tag.category}">#{tag_link(tag, tag.name, link_type)}</li>)
|
||||
end.join
|
||||
end.join
|
||||
%(<ul class="inline-tag-list">#{html}</ul>).html_safe
|
||||
@ -166,8 +168,9 @@ class TagSetPresenter < Presenter
|
||||
html
|
||||
end
|
||||
|
||||
def tag_link(tag, link_text = tag.name)
|
||||
def tag_link(tag, link_text = tag.name, link_type = :tag)
|
||||
link = link_type == :wiki_page ? show_or_new_wiki_pages_path(title: tag.name) : posts_path(tags: tag.name)
|
||||
itemprop = 'itemprop="author"' if tag.category == Tag.categories.artist
|
||||
%(<a rel="nofollow" class="search-tag" #{itemprop} href="/posts?tags=#{u(tag.name)}">#{h(link_text)}</a> )
|
||||
%(<a rel="nofollow" class="search-tag" #{itemprop} href="#{link}">#{h(link_text)}</a>)
|
||||
end
|
||||
end
|
||||
|
@ -49,7 +49,7 @@
|
||||
|
||||
<span class="post-info">
|
||||
<strong>Tags</strong>
|
||||
<%= upload.presenter.inline_tag_list_html %>
|
||||
<%= upload.presenter.inline_tag_list_html(:wiki_page) %>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
|
Loading…
Reference in New Issue
Block a user