diff --git a/app/helpers/artists_helper.rb b/app/helpers/artists_helper.rb index b50241d3a..cc236a4b9 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/forum_post_votes_controller_helper.rb b/app/helpers/forum_post_votes_controller_helper.rb deleted file mode 100644 index e39878914..000000000 --- a/app/helpers/forum_post_votes_controller_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ForumPostVotesControllerHelper -end diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb deleted file mode 100644 index cf2ecc9c7..000000000 --- a/app/helpers/tags_helper.rb +++ /dev/null @@ -1,40 +0,0 @@ -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(tag.antecedent_alias.consequent_name) - html << " (#{link_to_wiki "learn more", "help: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 x.antecedent_name }.join(", ")) - html << " (#{link_to_wiki "learn more", "help:tag_aliases"}).

" - end - - automatic_tags = TagImplication.automatic_tags_for([tag.name]) - if automatic_tags.present? - html << "

This tag automatically adds " - html << raw(automatic_tags.map {|x| link_to_wiki x, x }.join(", ")) - html << " (#{link_to_wiki "learn more", "help:autotags"}).

" - end - - if tag.antecedent_implications.present? - html << "

This tag implicates " - html << raw(tag.antecedent_implications.map {|x| link_to_wiki x.consequent_name }.join(", ")) - html << " (#{link_to_wiki "learn more", "help: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 x.antecedent_name }.join(", ")) - html << " (#{link_to_wiki "learn more", "help:tag_implications"}).

" - end - - html.html_safe - end -end diff --git a/app/helpers/upload_tags_report_helper.rb b/app/helpers/upload_tags_report_helper.rb deleted file mode 100644 index 76ef3f3b2..000000000 --- a/app/helpers/upload_tags_report_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -module UploadTagsReportHelper - def diff_to_current(report) - html = '' - - report.added_tags_array.each do |tag| - html << '+' + link_to(wordbreakify(tag), posts_path(:tags => tag)) + '' - end - report.removed_tags_array.each do |tag| - html << '-' + link_to(wordbreakify(tag), posts_path(:tags => tag)) + '' - end - - html << "" - html.html_safe - end -end diff --git a/app/helpers/wiki_pages_helper.rb b/app/helpers/wiki_pages_helper.rb index 7529d8109..0f0d2ebaa 100644 --- a/app/helpers/wiki_pages_helper.rb +++ b/app/helpers/wiki_pages_helper.rb @@ -1,22 +1,4 @@ module WikiPagesHelper - def wiki_page_alias_and_implication_list(wiki_page) - alias_and_implication_list(wiki_page.tag) - end - - def wiki_page_post_previews(wiki_page) - html = '
' - - if Post.fast_count(wiki_page.title) > 0 - full_link = link_to("view all", posts_path(:tags => wiki_page.title)) - html << "

Posts (#{full_link})

" - html << wiki_page.post_set.presenter.post_previews_html(self) - end - - html << "
" - - html.html_safe - end - def wiki_page_other_names_list(wiki_page) names_html = wiki_page.other_names.map {|name| link_to(name, "http://www.pixiv.net/search.php?s_mode=s_tag_full&word=#{u(name)}", :class => "wiki-other-name")} names_html.join(" ").html_safe diff --git a/app/views/posts/partials/index/_excerpt.html.erb b/app/views/posts/partials/index/_excerpt.html.erb index 923d8d857..c8243c2bf 100644 --- a/app/views/posts/partials/index/_excerpt.html.erb +++ b/app/views/posts/partials/index/_excerpt.html.erb @@ -12,7 +12,7 @@
<%= render "artists/summary", artist: artist %> - <%= artist_alias_and_implication_list(artist) %> + <%= render "tag_relationships/alias_and_implication_list", tag: artist.tag %>

There is currently no wiki page for the tag "<%= post_set.tag_string %>". You can <%= link_to "create one", new_wiki_page_path(:wiki_page => {:title => post_set.tag_string}) %>.

- <%= alias_and_implication_list(post_set.tag) %> + <%= render "tag_relationships/alias_and_implication_list", tag: post_set.tag %> <% end %> <% end %>
diff --git a/app/views/reports/_tag_diff_list.html.erb b/app/views/reports/_tag_diff_list.html.erb new file mode 100644 index 000000000..7c928f3b6 --- /dev/null +++ b/app/views/reports/_tag_diff_list.html.erb @@ -0,0 +1,9 @@ + + <% added_tags.each do |tag| %> + +<%= link_to wordbreakify(tag), posts_path(tags: tag) %> + <% end %> + + <% removed_tags.each do |tag| %> + -<%= link_to wordbreakify(tag), posts_path(tags: tag) %> + <% end %> + diff --git a/app/views/reports/upload_tags.html.erb b/app/views/reports/upload_tags.html.erb index b96570128..7967826ca 100644 --- a/app/views/reports/upload_tags.html.erb +++ b/app/views/reports/upload_tags.html.erb @@ -12,7 +12,7 @@ <%= TagSetPresenter.new(upload_report.uploader_tags_array).inline_tag_list_html %> <% end %> <% t.column "Tags added by uploader", width: "45%" do |upload_report| %> - <%= diff_to_current(upload_report) %> + <%= render "reports/tag_diff_list", added_tags: upload_report.added_tags_array, removed_tags: upload_report.removed_tags_array %> <% end %> <% end %> diff --git a/app/views/tag_relationships/_alias_and_implication_list.html.erb b/app/views/tag_relationships/_alias_and_implication_list.html.erb new file mode 100644 index 000000000..0ead3409c --- /dev/null +++ b/app/views/tag_relationships/_alias_and_implication_list.html.erb @@ -0,0 +1,40 @@ +<% if tag.antecedent_alias %> +

+ This tag has been aliased to <%= link_to_wiki(tag.antecedent_alias.consequent_name) %> + (<%= link_to_wiki "learn more", "help:tag_aliases" %>). +

+<% end %> + +<% if tag.consequent_aliases.present? %> +

+ The following tags are aliased to this tag: + <%= to_sentence(tag.consequent_aliases.map { |ta| link_to_wiki ta.antecedent_name }) %> + (<%= link_to_wiki "learn more", "help:tag_aliases" %>). +

+<% end %> + +<% TagImplication.automatic_tags_for([tag.name]).tap do |automatic_tags| %> + <% if automatic_tags.present? %> +

+ This tag automatically adds + <%= to_sentence(automatic_tags.map { |tag| link_to_wiki tag }) %> + (<%= link_to_wiki "learn more", "help:autotags" %>). +

+ <% end %> +<% end %> + +<% if tag.antecedent_implications.present? %> +

+ This tag implicates + <%= to_sentence(tag.antecedent_implications.map { |ti| link_to_wiki ti.consequent_name }) %> + (<%= link_to_wiki "learn more", "help:tag_implications" %>). +

+<% end %> + +<% if tag.consequent_implications.present? %> +

+ The following tags implicate this tag: + <%= to_sentence(tag.consequent_implications.map { |ti| link_to_wiki ti.antecedent_name }) %> + (<%= link_to_wiki "learn more", "help:tag_implications" %>). +

+<% end %> diff --git a/app/views/wiki_pages/_posts.html.erb b/app/views/wiki_pages/_posts.html.erb new file mode 100644 index 000000000..9ff4512c9 --- /dev/null +++ b/app/views/wiki_pages/_posts.html.erb @@ -0,0 +1,7 @@ +<% if wiki_page.tag.present? && wiki_page.tag.post_count > 0 %> +
+

Posts (<%= link_to "view all", posts_path(tags: wiki_page.title) %>)

+ + <%= wiki_page.post_set.presenter.post_previews_html(self) %> +
+<% end %> diff --git a/app/views/wiki_pages/new.html.erb b/app/views/wiki_pages/new.html.erb index 46cab8a15..1449e530b 100644 --- a/app/views/wiki_pages/new.html.erb +++ b/app/views/wiki_pages/new.html.erb @@ -19,8 +19,8 @@ <%= dtext_preview_button "wiki_page", "body" %> <% end %> - <%= wiki_page_alias_and_implication_list(@wiki_page)%> - <%= wiki_page_post_previews(@wiki_page) %> + <%= render "tag_relationships/alias_and_implication_list", tag: @wiki_page.tag %> + <%= render "wiki_pages/posts", wiki_page: @wiki_page %> <% end %> <%= render "secondary_links" %> diff --git a/app/views/wiki_pages/show.html.erb b/app/views/wiki_pages/show.html.erb index 654f7680b..5101995ec 100644 --- a/app/views/wiki_pages/show.html.erb +++ b/app/views/wiki_pages/show.html.erb @@ -29,13 +29,13 @@

<%= link_to "View artist", @wiki_page.artist %>

<% end %> - <%= wiki_page_alias_and_implication_list(@wiki_page) %> + <%= render "tag_relationships/alias_and_implication_list", tag: @wiki_page.tag %> <% else %>

This artist has requested removal of their information.

<% end %> - <%= wiki_page_post_previews(@wiki_page) %> + <%= render "wiki_pages/posts", wiki_page: @wiki_page %> <% end %> <% content_for(:page_title) do %>