Commit efe2f5f8c7e147f83785d34dc5a006f1dc62ad65

Authored by Dmitriy Zaporozhets
2 parents e0fb0703 0ed7f32d

Merge branch 'features/profile_page'

  1 +v 4.2.0
  2 + - User show page. Via /u/username
  3 + - Show help contents on pages for better navigation
  4 +
1 v 4.1.0 5 v 4.1.0
2 - Optional Sign-Up 6 - Optional Sign-Up
3 - Discussions 7 - Discussions
app/assets/stylesheets/gitlab_bootstrap/common.scss
@@ -95,6 +95,7 @@ img.avatar { float: left; margin-right: 12px; width: 40px; border: 1px solid #dd @@ -95,6 +95,7 @@ img.avatar { float: left; margin-right: 12px; width: 40px; border: 1px solid #dd
95 img.avatar.s16 { width: 16px; height: 16px; margin-right: 6px; } 95 img.avatar.s16 { width: 16px; height: 16px; margin-right: 6px; }
96 img.avatar.s24 { width: 24px; height: 24px; margin-right: 8px; } 96 img.avatar.s24 { width: 24px; height: 24px; margin-right: 8px; }
97 img.avatar.s32 { width: 32px; height: 32px; margin-right: 10px; } 97 img.avatar.s32 { width: 32px; height: 32px; margin-right: 10px; }
  98 +img.avatar.s90 { width: 90px; height: 90px; margin-right: 15px; }
98 img.lil_av { padding-left: 4px; padding-right: 3px; } 99 img.lil_av { padding-left: 4px; padding-right: 3px; }
99 img.small { width: 80px; } 100 img.small { width: 80px; }
100 101
app/assets/stylesheets/sections/header.scss
@@ -13,7 +13,7 @@ header { @@ -13,7 +13,7 @@ header {
13 color: $style_color; 13 color: $style_color;
14 text-shadow: 0 1px 0 #fff; 14 text-shadow: 0 1px 0 #fff;
15 font-size: 18px; 15 font-size: 18px;
16 - padding: 11px; 16 + padding: 12px;
17 } 17 }
18 18
19 /** NAV block with links and profile **/ 19 /** NAV block with links and profile **/
app/controllers/users_controller.rb 0 → 100644
@@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
  1 +class UsersController < ApplicationController
  2 + def show
  3 + @user = User.find_by_username!(params[:username])
  4 + @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id))
  5 + @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20)
  6 + end
  7 +end
app/helpers/events_helper.rb
1 module EventsHelper 1 module EventsHelper
2 def link_to_author(event) 2 def link_to_author(event)
3 - project = event.project  
4 - tm = project.team_member_by_id(event.author_id) if project 3 + author = event.author
5 4
6 - if tm  
7 - link_to event.author_name, project_team_member_path(project, tm) 5 + if author
  6 + link_to author.name, user_path(author.username)
8 else 7 else
9 event.author_name 8 event.author_name
10 end 9 end
app/models/team.rb
@@ -21,6 +21,10 @@ class Team @@ -21,6 +21,10 @@ class Team
21 end 21 end
22 end 22 end
23 23
  24 + def get_tm user_id
  25 + project.users_projects.find_by_user_id(user_id)
  26 + end
  27 +
24 def add_user(user, access) 28 def add_user(user, access)
25 add_users_ids([user.id], access) 29 add_users_ids([user.id], access)
26 end 30 end
app/views/users/_projects.html.haml 0 → 100644
@@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
  1 +.ui-box
  2 + %h5.title Projects
  3 + %ul.well-list
  4 + - @projects.each do |project|
  5 + %li
  6 + = link_to project_path(project), class: dom_class(project) do
  7 + - if project.namespace
  8 + = project.namespace.human_name
  9 + \/
  10 + %strong.well-title
  11 + = truncate(project.name, length: 45)
  12 + %span.right.light
  13 + - if project.owner == @user
  14 + %i.icon-wrench
  15 + - tm = project.team.get_tm(@user.id)
  16 + - if tm
  17 + = tm.project_access_human
  18 +%p.light
  19 + %i.icon-wrench
  20 + &ndash; user is a project owner
app/views/users/show.html.haml 0 → 100644
@@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
  1 +.row
  2 + .span8
  3 + %h3.page_title
  4 + = image_tag gravatar_icon(@user.email, 90), class: "avatar s90"
  5 + = @user.name
  6 + %br
  7 + %small @#{@user.username}
  8 + %br
  9 + %small member since #{@user.created_at.stamp("Nov 12, 2031")}
  10 + .clearfix
  11 + %hr
  12 + %h5 Recent events
  13 + = render @events
  14 + .span4
  15 + .ui-box
  16 + %h5.title Profile
  17 + %ul.well-list
  18 + %li
  19 + %strong Email
  20 + %span.right= mail_to @user.email
  21 + - unless @user.skype.blank?
  22 + %li
  23 + %strong Skype
  24 + %span.right= @user.skype
  25 + - unless @user.linkedin.blank?
  26 + %li
  27 + %strong LinkedIn
  28 + %span.right= @user.linkedin
  29 + - unless @user.twitter.blank?
  30 + %li
  31 + %strong Twitter
  32 + %span.right= @user.twitter
  33 + - unless @user.bio.blank?
  34 + %li
  35 + %strong Bio
  36 + %span.right= @user.bio
  37 + = render 'projects'
config/routes.rb
@@ -97,6 +97,9 @@ Gitlab::Application.routes.draw do @@ -97,6 +97,9 @@ Gitlab::Application.routes.draw do
97 end 97 end
98 98
99 resources :keys 99 resources :keys
  100 + match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ }
  101 +
  102 +
100 103
101 # 104 #
102 # Dashboard Area 105 # Dashboard Area