2016-10-06 08:14:24 -04:00
|
|
|
require 'constraints/user_url_constrainer'
|
|
|
|
|
2016-10-05 08:21:27 -04:00
|
|
|
devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks,
|
|
|
|
registrations: :registrations,
|
|
|
|
passwords: :passwords,
|
|
|
|
sessions: :sessions,
|
|
|
|
confirmations: :confirmations }
|
|
|
|
|
|
|
|
devise_scope :user do
|
|
|
|
get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
|
|
|
|
get '/users/almost_there' => 'confirmations#almost_there'
|
|
|
|
end
|
2016-10-06 08:14:24 -04:00
|
|
|
|
|
|
|
constraints(UserUrlConstrainer.new) do
|
2016-10-08 12:25:06 -04:00
|
|
|
scope(path: ':username',
|
|
|
|
as: :user,
|
|
|
|
constraints: { username: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ },
|
|
|
|
controller: :users) do
|
2016-10-06 08:14:24 -04:00
|
|
|
get '/', action: :show
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-12 11:49:41 -04:00
|
|
|
scope(path: 'users/:username',
|
2016-10-06 08:14:24 -04:00
|
|
|
as: :user,
|
|
|
|
constraints: { username: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ },
|
|
|
|
controller: :users) do
|
|
|
|
get :calendar
|
|
|
|
get :calendar_activities
|
|
|
|
get :groups
|
|
|
|
get :projects
|
|
|
|
get :contributed, as: :contributed_projects
|
|
|
|
get :snippets
|
2016-10-11 12:28:00 -04:00
|
|
|
get :exists
|
2016-10-06 08:14:24 -04:00
|
|
|
get '/', to: redirect('/%{username}')
|
|
|
|
end
|
2016-10-12 11:49:41 -04:00
|
|
|
|
|
|
|
# Compatibility with old routing
|
2016-10-13 09:07:16 -04:00
|
|
|
# TODO (dzaporozhets): remove in 10.0
|
2016-10-12 11:49:41 -04:00
|
|
|
get '/u/:username', to: redirect('/%{username}'), constraints: { username: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }
|
2016-10-13 09:07:16 -04:00
|
|
|
# TODO (dzaporozhets): remove in 9.0
|
2016-10-12 11:49:41 -04:00
|
|
|
get '/u/:username/groups', to: redirect('/users/%{username}/groups'), constraints: { username: /[a-zA-Z.0-9_\-]+/ }
|
|
|
|
get '/u/:username/projects', to: redirect('/users/%{username}/projects'), constraints: { username: /[a-zA-Z.0-9_\-]+/ }
|
|
|
|
get '/u/:username/snippets', to: redirect('/users/%{username}/snippets'), constraints: { username: /[a-zA-Z.0-9_\-]+/ }
|
|
|
|
get '/u/:username/contributed', to: redirect('/users/%{username}/contributed'), constraints: { username: /[a-zA-Z.0-9_\-]+/ }
|