views: convert helpers to partials.
This commit is contained in:
@@ -1,8 +1,4 @@
|
|||||||
module ArtistsHelper
|
module ArtistsHelper
|
||||||
def artist_alias_and_implication_list(artist)
|
|
||||||
alias_and_implication_list(artist.tag)
|
|
||||||
end
|
|
||||||
|
|
||||||
def link_to_artist(name)
|
def link_to_artist(name)
|
||||||
artist = Artist.find_by_name(name)
|
artist = Artist.find_by_name(name)
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
module ForumPostVotesControllerHelper
|
|
||||||
end
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
module TagsHelper
|
|
||||||
def alias_and_implication_list(tag)
|
|
||||||
return "" if tag.nil?
|
|
||||||
|
|
||||||
html = ""
|
|
||||||
|
|
||||||
if tag.antecedent_alias
|
|
||||||
html << "<p class='fineprint'>This tag has been aliased to "
|
|
||||||
html << link_to_wiki(tag.antecedent_alias.consequent_name)
|
|
||||||
html << " (#{link_to_wiki "learn more", "help:tag_aliases"}).</p>"
|
|
||||||
end
|
|
||||||
|
|
||||||
if tag.consequent_aliases.present?
|
|
||||||
html << "<p class='fineprint'>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"}).</p>"
|
|
||||||
end
|
|
||||||
|
|
||||||
automatic_tags = TagImplication.automatic_tags_for([tag.name])
|
|
||||||
if automatic_tags.present?
|
|
||||||
html << "<p class='fineprint'>This tag automatically adds "
|
|
||||||
html << raw(automatic_tags.map {|x| link_to_wiki x, x }.join(", "))
|
|
||||||
html << " (#{link_to_wiki "learn more", "help:autotags"}).</p>"
|
|
||||||
end
|
|
||||||
|
|
||||||
if tag.antecedent_implications.present?
|
|
||||||
html << "<p class='fineprint'>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"}).</p>"
|
|
||||||
end
|
|
||||||
|
|
||||||
if tag.consequent_implications.present?
|
|
||||||
html << "<p class='fineprint'>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"}).</p>"
|
|
||||||
end
|
|
||||||
|
|
||||||
html.html_safe
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
module UploadTagsReportHelper
|
|
||||||
def diff_to_current(report)
|
|
||||||
html = '<span class="diff-list">'
|
|
||||||
|
|
||||||
report.added_tags_array.each do |tag|
|
|
||||||
html << '<ins>+' + link_to(wordbreakify(tag), posts_path(:tags => tag)) + '</ins>'
|
|
||||||
end
|
|
||||||
report.removed_tags_array.each do |tag|
|
|
||||||
html << '<del>-' + link_to(wordbreakify(tag), posts_path(:tags => tag)) + '</del>'
|
|
||||||
end
|
|
||||||
|
|
||||||
html << "</span>"
|
|
||||||
html.html_safe
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,22 +1,4 @@
|
|||||||
module WikiPagesHelper
|
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 = '<div id="wiki-page-posts">'
|
|
||||||
|
|
||||||
if Post.fast_count(wiki_page.title) > 0
|
|
||||||
full_link = link_to("view all", posts_path(:tags => wiki_page.title))
|
|
||||||
html << "<h2>Posts (#{full_link})</h2>"
|
|
||||||
html << wiki_page.post_set.presenter.post_previews_html(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
html << "</div>"
|
|
||||||
|
|
||||||
html.html_safe
|
|
||||||
end
|
|
||||||
|
|
||||||
def wiki_page_other_names_list(wiki_page)
|
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 = 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
|
names_html.join(" ").html_safe
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= render "artists/summary", artist: artist %>
|
<%= render "artists/summary", artist: artist %>
|
||||||
<%= artist_alias_and_implication_list(artist) %>
|
<%= render "tag_relationships/alias_and_implication_list", tag: artist.tag %>
|
||||||
|
|
||||||
<p class="links">
|
<p class="links">
|
||||||
<%= link_to "View wiki", artist.wiki_page %> |
|
<%= link_to "View wiki", artist.wiki_page %> |
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= format_text(wiki_page.presenter.excerpt) %>
|
<%= format_text(wiki_page.presenter.excerpt) %>
|
||||||
<%= wiki_page_alias_and_implication_list(wiki_page) %>
|
<%= render "tag_relationships/alias_and_implication_list", tag: wiki_page.tag %>
|
||||||
|
|
||||||
<p class="links">
|
<p class="links">
|
||||||
<%= link_to_wiki "View wiki", wiki_page.title %>
|
<%= link_to_wiki "View wiki", wiki_page.title %>
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
<% if post_set.tag_string.present? %>
|
<% if post_set.tag_string.present? %>
|
||||||
<p>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}) %>.</p>
|
<p>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}) %>.</p>
|
||||||
|
|
||||||
<%= alias_and_implication_list(post_set.tag) %>
|
<%= render "tag_relationships/alias_and_implication_list", tag: post_set.tag %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
9
app/views/reports/_tag_diff_list.html.erb
Normal file
9
app/views/reports/_tag_diff_list.html.erb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<span class="diff-list">
|
||||||
|
<% added_tags.each do |tag| %>
|
||||||
|
<ins>+<%= link_to wordbreakify(tag), posts_path(tags: tag) %></ins>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% removed_tags.each do |tag| %>
|
||||||
|
<del>-<%= link_to wordbreakify(tag), posts_path(tags: tag) %></del>
|
||||||
|
<% end %>
|
||||||
|
</span>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<%= TagSetPresenter.new(upload_report.uploader_tags_array).inline_tag_list_html %>
|
<%= TagSetPresenter.new(upload_report.uploader_tags_array).inline_tag_list_html %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% t.column "Tags added by uploader", width: "45%" do |upload_report| %>
|
<% 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 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<% if tag.antecedent_alias %>
|
||||||
|
<p class="fineprint">
|
||||||
|
This tag has been aliased to <%= link_to_wiki(tag.antecedent_alias.consequent_name) %>
|
||||||
|
(<%= link_to_wiki "learn more", "help:tag_aliases" %>).
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if tag.consequent_aliases.present? %>
|
||||||
|
<p class="fineprint">
|
||||||
|
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" %>).
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% TagImplication.automatic_tags_for([tag.name]).tap do |automatic_tags| %>
|
||||||
|
<% if automatic_tags.present? %>
|
||||||
|
<p class="fineprint">
|
||||||
|
This tag automatically adds
|
||||||
|
<%= to_sentence(automatic_tags.map { |tag| link_to_wiki tag }) %>
|
||||||
|
(<%= link_to_wiki "learn more", "help:autotags" %>).
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if tag.antecedent_implications.present? %>
|
||||||
|
<p class="fineprint">
|
||||||
|
This tag implicates
|
||||||
|
<%= to_sentence(tag.antecedent_implications.map { |ti| link_to_wiki ti.consequent_name }) %>
|
||||||
|
(<%= link_to_wiki "learn more", "help:tag_implications" %>).
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if tag.consequent_implications.present? %>
|
||||||
|
<p class="fineprint">
|
||||||
|
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" %>).
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
7
app/views/wiki_pages/_posts.html.erb
Normal file
7
app/views/wiki_pages/_posts.html.erb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<% if wiki_page.tag.present? && wiki_page.tag.post_count > 0 %>
|
||||||
|
<div id="wiki-page-posts">
|
||||||
|
<h2>Posts (<%= link_to "view all", posts_path(tags: wiki_page.title) %>)</h2>
|
||||||
|
|
||||||
|
<%= wiki_page.post_set.presenter.post_previews_html(self) %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
@@ -19,8 +19,8 @@
|
|||||||
<%= dtext_preview_button "wiki_page", "body" %>
|
<%= dtext_preview_button "wiki_page", "body" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= wiki_page_alias_and_implication_list(@wiki_page)%>
|
<%= render "tag_relationships/alias_and_implication_list", tag: @wiki_page.tag %>
|
||||||
<%= wiki_page_post_previews(@wiki_page) %>
|
<%= render "wiki_pages/posts", wiki_page: @wiki_page %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render "secondary_links" %>
|
<%= render "secondary_links" %>
|
||||||
|
|||||||
@@ -29,13 +29,13 @@
|
|||||||
<p><%= link_to "View artist", @wiki_page.artist %></p>
|
<p><%= link_to "View artist", @wiki_page.artist %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= wiki_page_alias_and_implication_list(@wiki_page) %>
|
<%= render "tag_relationships/alias_and_implication_list", tag: @wiki_page.tag %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<p>This artist has requested removal of their information.</p>
|
<p>This artist has requested removal of their information.</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= wiki_page_post_previews(@wiki_page) %>
|
<%= render "wiki_pages/posts", wiki_page: @wiki_page %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% content_for(:page_title) do %>
|
<% content_for(:page_title) do %>
|
||||||
|
|||||||
Reference in New Issue
Block a user