Commit 3dc0bce9474ac52046f5c3efb2532af6334a7aae

Authored by Dmitriy Zaporozhets
1 parent ab094e67

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 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +class NamespacesController < ApplicationController
  2 + skip_before_filter :authenticate_user!
  3 +
  4 + def show
  5 + namespace = Namespace.find_by(path: params[:id])
  6 +
  7 + unless namespace
  8 + return render_404
  9 + end
  10 +
  11 + if namespace.type == "Group"
  12 + redirect_to group_path(namespace)
  13 + else
  14 + redirect_to user_path(namespace.owner)
  15 + end
  16 + end
  17 +end
  18 +
... ...
config/routes.rb
... ... @@ -315,7 +315,7 @@ Gitlab::Application.routes.draw do
315 315 end
316 316 end
317 317  
318   - get ':id' => "groups#show", constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}
  318 + get ':id' => "namespaces#show", constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}
319 319  
320 320 root to: "dashboard#show"
321 321 end
... ...