wiki pages: use names instead of ids in urls.

Switching to using wiki names in URLs instead of IDs:

* https://danbooru.donami.us/wiki_pages/vocaloid
* https://danbooru.donami.us/wiki_pages/hatsune_miku

ID numbers can still be used, but they redirect to the name instead:

* https://danbooru.donami.us/wiki_pages/11 (redirects to /wiki_pages/touhou).

Numeric tags are prefixed with '~' to distinguish them from IDs:

* https://danbooru.donami.us/wiki_pages/2019 (the wiki with id 2019)
* https://danbooru.donami.us/wiki_pages/~2019 (the wiki for the tag named 2019)

The tag names 'new' and 'search' are disallowed to prevent conflicts
with existing routes:

* https://danbooru.donami.us/wiki_pages/new
* https://danbooru.donami.us/wiki_pages/search
This commit is contained in:
evazion
2019-10-31 04:07:21 -05:00
parent 0ccfb3f5f6
commit 3a908f84bb
14 changed files with 76 additions and 38 deletions

View File

@@ -103,13 +103,14 @@ module ApplicationHelper
link_to search, posts_path(tags: search)
end
def link_to_wiki(text, title)
link_to text, wiki_page_path(title)
def link_to_wiki(text, title = text, **options)
title = "~#{title}" if title =~ /\A\d+\z/
link_to text, wiki_page_path(title), class: "wiki-link", **options
end
def link_to_wikis(*wiki_titles, last_word_connector: ", or", **options)
links = wiki_titles.map do |title|
link_to title.tr("_", " "), wiki_page_path(title)
link_to_wiki title.tr("_", " "), title
end
to_sentence(links, **options)

View File

@@ -6,32 +6,32 @@ module TagsHelper
if tag.antecedent_alias
html << "<p class='fineprint'>This tag has been aliased to "
html << link_to(tag.antecedent_alias.consequent_name, show_or_new_wiki_pages_path(:title => tag.antecedent_alias.consequent_name))
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(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", "))
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(x, show_or_new_wiki_pages_path(:title => x))}.join(", "))
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(x.consequent_name, show_or_new_wiki_pages_path(:title => x.consequent_name))}.join(", "))
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(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", "))
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