diff --git a/app/helpers/wiki_pages_helper.rb b/app/helpers/wiki_pages_helper.rb index 283018a93..9fbc3862c 100644 --- a/app/helpers/wiki_pages_helper.rb +++ b/app/helpers/wiki_pages_helper.rb @@ -1,2 +1,36 @@ module WikiPagesHelper + def wiki_page_alias_and_implication_list(wiki_page) + antecedent_alias = wiki_page.presenter.antecedent_tag_alias + consequent_aliases = wiki_page.presenter.consequent_tag_aliases + antecedent_implications = wiki_page.presenter.antecedent_tag_implications + consequent_implications = wiki_page.presenter.consequent_tag_implications + + html = "" + + if antecedent_alias + html << "
This tag has been aliased to " + html << link_to(antecedent_alias.consequent_name, show_or_new_wiki_pages_path(:title => antecedent_alias.consequent_name)) + html << ".
" + end + + if consequent_aliases.any? + html << "The following tags are aliased to this tag: " + html << raw(consequent_aliases.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ")) + html << ".
" + end + + if antecedent_implications.any? + html << "This tag implicates " + html << raw(antecedent_implications.map {|x| link_to(x.consequent_name, show_or_new_wiki_pages_path(:title => x.consequent_name))}.join(", ")) + html << ".
" + end + + if consequent_implications.any? + html << "The following tags implicate this tag: " + html << raw(consequent_implications.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ")) + html << ".
" + end + + html.html_safe + end end diff --git a/app/views/wiki_pages/new.html.erb b/app/views/wiki_pages/new.html.erb index 70da40f21..0d56f5858 100644 --- a/app/views/wiki_pages/new.html.erb +++ b/app/views/wiki_pages/new.html.erb @@ -13,21 +13,7 @@ <%= render "form" %> - <% if @wiki_page.presenter.antecedent_tag_alias %> -This tag has been aliased to <%= link_to @wiki_page.presenter.antecedent_tag_alias.consequent_name, show_or_new_wiki_pages_path(:title => @wiki_page.presenter.antecedent_tag_alias.consequent_name) %>.
- <% end %> - - <% if @wiki_page.presenter.consequent_tag_aliases.any? %> -The following tags are aliased to this tag: <%= raw @wiki_page.presenter.consequent_tag_aliases.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ") %>.
- <% end %> - - <% if @wiki_page.presenter.antecedent_tag_implications.any? %> -This tag implicates <%= raw @wiki_page.presenter.antecedent_tag_implications.map {|x| link_to(x.consequent_name, show_or_new_wiki_pages_path(:title => x.consequent_name))}.join(", ") %>.
- <% end %> - - <% if @wiki_page.presenter.consequent_tag_implications.any? %> -The following tags implicate this tag: <%= raw @wiki_page.presenter.consequent_tag_implications.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ") %>.
- <% end %> + <%= wiki_page_alias_and_implication_list(@wiki_page)%>This tag has been aliased to <%= link_to @wiki_page.presenter.antecedent_tag_alias.consequent_name, show_or_new_wiki_pages_path(:title => @wiki_page.presenter.antecedent_tag_alias.consequent_name) %>.
- <% end %> - - <% if @wiki_page.presenter.consequent_tag_aliases.any? %> -The following tags are aliased to this tag: <%= raw @wiki_page.presenter.consequent_tag_aliases.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ") %>.
- <% end %> - - <% if @wiki_page.presenter.antecedent_tag_implications.any? %> -This tag implicates <%= raw @wiki_page.presenter.antecedent_tag_implications.map {|x| link_to(x.consequent_name, show_or_new_wiki_pages_path(:title => x.consequent_name))}.join(", ") %>.
- <% end %> - - <% if @wiki_page.presenter.consequent_tag_implications.any? %> -The following tags implicate this tag: <%= raw @wiki_page.presenter.consequent_tag_implications.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ") %>.
- <% end %> + <%= wiki_page_alias_and_implication_list(@wiki_page) %>