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

@@ -35,7 +35,7 @@
<% if dtext_link.external_link? %>
<%= external_link_to(dtext_link.link_target) %>
<% elsif dtext_link.wiki_link? %>
<%= link_to(dtext_link.link_target, show_or_new_wiki_pages_path(title: dtext_link.link_target), class: "tag-type-#{Tag.category_for(dtext_link.link_target)}") %>
<%= link_to_wiki dtext_link.link_target, class: "tag-type-#{Tag.category_for(dtext_link.link_target)}" %>
<% end %>
<%= link_to("»", dtext_links_path(search: { link_target: dtext_link.link_target })) %>

View File

@@ -1,10 +1,10 @@
<div class="current-related-tags-columns">
<% if related_tags.present? %>
<%= render "related_tags/tag_column", tags: related_tags.tags, class: "general-related-tags-column", title: related_tags.pretty_name %>
<%= render "related_tags/tag_column", tags: related_tags.wiki_page_tags, class: "wiki-related-tags-column", title: link_to("wiki:#{related_tags.pretty_name}", show_or_new_wiki_pages_path(title: related_tags.query)) %>
<%= render "related_tags/tag_column", tags: related_tags.wiki_page_tags, class: "wiki-related-tags-column", title: link_to_wiki("wiki:#{related_tags.pretty_name}", related_tags.query) %>
<% related_tags.other_wiki_pages.each do |wiki| %>
<%= render "related_tags/tag_column", tags: wiki.tags, class: "other-wiki-related-tags-column", title: link_to("wiki:#{wiki.pretty_title}", show_or_new_wiki_pages_path(title: wiki.title)) %>
<%= render "related_tags/tag_column", tags: wiki.tags, class: "other-wiki-related-tags-column", title: link_to_wiki("wiki:#{wiki.pretty_title}", wiki.title) %>
<% end %>
<% end %>
</div>

View File

@@ -20,7 +20,7 @@
<% @query.tags_for_html.each do |tag, category| %>
<tr>
<td class="category-<%= category %>">
<%= link_to("?", show_or_new_wiki_pages_path(:title => tag)) %>
<%= link_to_wiki "?", tag %>
<%= link_to(tag, posts_path(:tags => tag)) %>
</td>
</tr>

View File

@@ -14,7 +14,7 @@
<tr>
<td><%= tag.post_count %></td>
<td class="category-<%= tag.category %> col-expand">
<%= link_to("?", show_or_new_wiki_pages_path(:title => tag.name)) %>
<%= link_to_wiki "?", tag.name %>
<%= link_to(tag.name, posts_path(:tags => tag.name)) %>
</td>
<td>