diff --git a/app/helpers/artists_helper.rb b/app/helpers/artists_helper.rb index 4decd1467..0fa29ed5a 100644 --- a/app/helpers/artists_helper.rb +++ b/app/helpers/artists_helper.rb @@ -1,8 +1,4 @@ module ArtistsHelper - def artist_alias_and_implication_list(artist) - alias_and_implication_list(artist.tag) - end - def link_to_artist(name) artist = Artist.find_by(name: name) diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index 0ef0b70e1..45f78ac7e 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -1,36 +1,4 @@ module TagsHelper - def alias_and_implication_list(tag) - return "" if tag.nil? - - html = "" - - if tag.antecedent_alias - html << "
This tag has been aliased to " - html << link_to_wiki_or_new(tag.antecedent_alias.consequent_name) - html << " (#{link_to "learn more", wiki_pages_path(title: "e621:tag_aliases")}).
" - end - - if tag.consequent_aliases.present? - html << "The following tags are aliased to this tag: " - html << raw(tag.consequent_aliases.map {|x| link_to_wiki_or_new(x.antecedent_name) }.join(", ")) - html << " (#{link_to "learn more", wiki_pages_path(title: "e621:tag_aliases")}).
" - end - - if tag.antecedent_implications.present? - html << "This tag implicates " - html << raw(tag.antecedent_implications.map {|x| link_to_wiki_or_new(x.consequent_name) }.join(", ")) - html << " (#{link_to "learn more", wiki_pages_path(title: "e621:tag_implications")}).
" - end - - if tag.consequent_implications.present? - html << "The following tags implicate this tag: " - html << raw(tag.consequent_implications.map {|x| link_to_wiki_or_new(x.antecedent_name) }.join(", ")) - html << " (#{link_to "learn more", wiki_pages_path(title: "e621:tag_implications")}).
" - end - - html.html_safe - end - def format_transitive_item(transitive) html = "#{transitive[0].to_s.titlecase} ".html_safe if transitive[0] == :alias diff --git a/app/helpers/wiki_pages_helper.rb b/app/helpers/wiki_pages_helper.rb index 0fec878d9..4bf5b91d2 100644 --- a/app/helpers/wiki_pages_helper.rb +++ b/app/helpers/wiki_pages_helper.rb @@ -3,21 +3,21 @@ module WikiPagesHelper link_to(text, show_or_new_wiki_pages_path(title: tag)) end + def multiple_link_to_wiki_or_new(tags) + safe_join(tags.map { |tag| link_to_wiki_or_new(tag) }, ", ") + end + def wiki_page_alias_and_implication_list(wiki_page) - alias_and_implication_list(wiki_page.tag || Tag.new({name: wiki_page.title})) + render "tags/alias_and_implication_list", tag: wiki_page.tag || Tag.new(name: wiki_page.title) end def wiki_page_post_previews(wiki_page) - html = '<%= link_to_wiki_or_new "View wiki page", @artist.name %>
<% end %> - <%= artist_alias_and_implication_list(@artist) %> + <%= render "tags/alias_and_implication_list", tag: @artist.tag %> <%= yield %>+ This tag has been aliased to <%= link_to_wiki_or_new(tag.antecedent_alias.consequent_name) %> + (<%= link_to "learn more", wiki_pages_path(title: "e621:tag_aliases") %>). +
+<% end %> +<% if tag&.consequent_aliases&.present? %> ++ The following tags are aliased to this tag: <%= multiple_link_to_wiki_or_new(tag.consequent_aliases.map(&:antecedent_name)) %> + (<%= link_to "learn more", wiki_pages_path(title: "e621:tag_aliases") %>). +
+<% end %> +<% if tag&.antecedent_implications&.present? %> ++ This tag implicates <%= multiple_link_to_wiki_or_new(tag.antecedent_implications.map(&:consequent_name)) %> + (<%= link_to "learn more", wiki_pages_path(title: "e621:tag_implications") %>). +
+<% end %> +<% if tag&.consequent_implications&.present? %> ++ The following tags implicate this tag: <%= multiple_link_to_wiki_or_new(tag.consequent_implications.map(&:antecedent_name)) %> + (<%= link_to "learn more", wiki_pages_path(title: "e621:tag_implications") %>). +
+<% end %>