From 3dc0bce9474ac52046f5c3efb2532af6334a7aae Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Date: Sat, 7 Jun 2014 15:06:55 +0300 Subject: [PATCH] Add users to /:id route So now when you type site/:username it redirects you to users page. And if you type site/:groupname it redirects you to group page Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> --- app/controllers/namespaces_controller.rb | 18 ++++++++++++++++++ config/routes.rb | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 app/controllers/namespaces_controller.rb diff --git a/app/controllers/namespaces_controller.rb b/app/controllers/namespaces_controller.rb new file mode 100644 index 0000000000..c59a2401ce --- /dev/null +++ b/app/controllers/namespaces_controller.rb @@ -0,0 +1,18 @@ +class NamespacesController < ApplicationController + skip_before_filter :authenticate_user! + + def show + namespace = Namespace.find_by(path: params[:id]) + + unless namespace + return render_404 + end + + if namespace.type == "Group" + redirect_to group_path(namespace) + else + redirect_to user_path(namespace.owner) + end + end +end + diff --git a/config/routes.rb b/config/routes.rb index 7c2ab6bd1d..67ff66757e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -315,7 +315,7 @@ Gitlab::Application.routes.draw do end end - get ':id' => "groups#show", constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} + get ':id' => "namespaces#show", constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} root to: "dashboard#show" end -- 2.30.9