alias_and_implication_list: refactor alias/implication lookup.
Add alias and implications associations to Tag. Use them in alias_and_implication list instead of duplicating the alias/implication lookup code.
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
module ArtistsHelper
|
||||
def artist_alias_and_implication_list(artist)
|
||||
consequent_tag_aliases = TagAlias.where("status in ('active', 'processing') and consequent_name = ?", artist.name)
|
||||
antecedent_tag_alias = TagAlias.where("status in ('active', 'processing') and antecedent_name = ?", artist.name).first
|
||||
consequent_tag_implications = TagImplication.where("status in ('active', 'processing') and consequent_name = ?", artist.name)
|
||||
antecedent_tag_implications = TagImplication.where("status in ('active', 'processing') and antecedent_name = ?", artist.name)
|
||||
|
||||
alias_and_implication_list(antecedent_tag_alias, consequent_tag_aliases, antecedent_tag_implications, consequent_tag_implications)
|
||||
alias_and_implication_list(artist.tag)
|
||||
end
|
||||
|
||||
def link_to_artist(name)
|
||||
|
||||
@@ -1,28 +1,30 @@
|
||||
module TagsHelper
|
||||
def alias_and_implication_list(antecedent_alias, consequent_aliases, antecedent_implications, consequent_implications)
|
||||
def alias_and_implication_list(tag)
|
||||
return "" if tag.nil?
|
||||
|
||||
html = ""
|
||||
|
||||
if antecedent_alias
|
||||
if tag.antecedent_alias
|
||||
html << "<p class='hint'>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 << link_to(tag.antecedent_alias.consequent_name, show_or_new_wiki_pages_path(:title => tag.antecedent_alias.consequent_name))
|
||||
html << ".</p>"
|
||||
end
|
||||
|
||||
if consequent_aliases.any?
|
||||
if tag.consequent_aliases.any?
|
||||
html << "<p class='hint'>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 << raw(tag.consequent_aliases.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", "))
|
||||
html << ".</p>"
|
||||
end
|
||||
|
||||
if antecedent_implications.any?
|
||||
if tag.antecedent_implications.any?
|
||||
html << "<p class='hint'>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 << raw(tag.antecedent_implications.map {|x| link_to(x.consequent_name, show_or_new_wiki_pages_path(:title => x.consequent_name))}.join(", "))
|
||||
html << ".</p>"
|
||||
end
|
||||
|
||||
if consequent_implications.any?
|
||||
if tag.consequent_implications.any?
|
||||
html << "<p class='hint'>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 << raw(tag.consequent_implications.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", "))
|
||||
html << ".</p>"
|
||||
end
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
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
|
||||
|
||||
alias_and_implication_list(antecedent_alias, consequent_aliases, antecedent_implications, consequent_implications)
|
||||
alias_and_implication_list(wiki_page.tag)
|
||||
end
|
||||
|
||||
def wiki_page_post_previews(wiki_page)
|
||||
|
||||
Reference in New Issue
Block a user