diff --git a/app/assets/javascripts/discourse/pre-initializers/dynamic-route-builders.js.es6 b/app/assets/javascripts/discourse/pre-initializers/dynamic-route-builders.js.es6 index 26ac79cd02..9c96d01e42 100644 --- a/app/assets/javascripts/discourse/pre-initializers/dynamic-route-builders.js.es6 +++ b/app/assets/javascripts/discourse/pre-initializers/dynamic-route-builders.js.es6 @@ -103,10 +103,15 @@ export default { }); app["TagsShowParentCategoryRoute"] = TagsShowRoute.extend(); + app["TagShowRoute"] = TagsShowRoute; + site.get("filters").forEach(function(filter) { app["TagsShow" + filter.capitalize() + "Route"] = TagsShowRoute.extend({ navMode: filter }); + app["TagShow" + filter.capitalize() + "Route"] = TagsShowRoute.extend({ + navMode: filter + }); app[ "TagsShowCategory" + filter.capitalize() + "Route" ] = TagsShowRoute.extend({ navMode: filter }); diff --git a/app/assets/javascripts/discourse/routes/app-route-map.js.es6 b/app/assets/javascripts/discourse/routes/app-route-map.js.es6 index 3dc0d5787a..42d8f57f5c 100644 --- a/app/assets/javascripts/discourse/routes/app-route-map.js.es6 +++ b/app/assets/javascripts/discourse/routes/app-route-map.js.es6 @@ -209,8 +209,17 @@ export default function() { this.route("full-page-search", { path: "/search" }); - this.route("tags", { resetNamespace: true }, function() { + this.route("tag", { resetNamespace: true }, function() { this.route("show", { path: "/:tag_id" }); + + Site.currentProp("filters").forEach(filter => { + this.route("show" + filter.capitalize(), { + path: "/:tag_id/l/" + filter + }); + }); + }); + + this.route("tags", { resetNamespace: true }, function() { this.route("showCategory", { path: "/c/*category_slug_path_with_id/:tag_id" }); @@ -219,9 +228,6 @@ export default function() { }); Site.currentProp("filters").forEach(filter => { - this.route("show" + filter.capitalize(), { - path: "/:tag_id/l/" + filter - }); this.route("showCategory" + filter.capitalize(), { path: "/c/*category_slug_path_with_id/:tag_id/l/" + filter }); @@ -232,6 +238,14 @@ export default function() { this.route("intersection", { path: "intersection/:tag_id/*additional_tags" }); + + // legacy routes + this.route("show", { path: "/:tag_id" }); + Site.currentProp("filters").forEach(filter => { + this.route("show" + filter.capitalize(), { + path: "/:tag_id/l/" + filter + }); + }); }); this.route( diff --git a/config/routes.rb b/config/routes.rb index 60a82ae476..21e536ce9c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -840,6 +840,27 @@ Discourse::Application.routes.draw do get "apple-app-site-association" => "metadata#app_association_ios", format: false get "opensearch" => "metadata#opensearch", constraints: { format: :xml } + scope '/tag/:tag_id' do + constraints format: :json do + get '/' => 'tags#show' + get '/info' => 'tags#info' + get '/notifications' => 'tags#notifications' + put '/notifications' => 'tags#update_notifications' + put '/' => 'tags#update' + delete '/' => 'tags#destroy' + post '/synonyms' => 'tags#create_synonyms' + delete '/synonyms/:synonym_id' => 'tags#destroy_synonym' + + Discourse.filters.each do |filter| + get "/l/#{filter}" => "tags#show_#{filter}" + end + end + + constraints format: :rss do + get '/' => 'tags#tag_feed' + end + end + scope "/tags" do get '/' => 'tags#index' get '/filter/list' => 'tags#index' @@ -849,6 +870,7 @@ Discourse::Application.routes.draw do post '/upload' => 'tags#upload' get '/unused' => 'tags#list_unused' delete '/unused' => 'tags#destroy_unused' + constraints(tag_id: /[^\/]+?/, format: /json|rss/) do scope path: '/c/*category_slug_path_with_id' do Discourse.filters.each do |filter| @@ -864,9 +886,13 @@ Discourse::Application.routes.draw do get '/:tag_id' => 'tags#show', as: 'tag_category_show' end + get '/intersection/:tag_id/*additional_tag_ids' => 'tags#show', as: 'tag_intersection' + end + + # legacy routes + constraints(tag_id: /[^\/]+?/, format: /json|rss/) do get '/:tag_id.rss' => 'tags#tag_feed' get '/:tag_id' => 'tags#show', as: 'tag_show' - get '/intersection/:tag_id/*additional_tag_ids' => 'tags#show', as: 'tag_intersection' get '/:tag_id/info' => 'tags#info' get '/:tag_id/notifications' => 'tags#notifications' put '/:tag_id/notifications' => 'tags#update_notifications'