From 70690e1971f6d009da9a37782764ae7446f69636 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 22 Jan 2013 19:05:01 +0200 Subject: base implementation --- .../stylesheets/gitlab_bootstrap/common.scss | 1 + app/assets/stylesheets/sections/header.scss | 2 +- app/controllers/users_controller.rb | 7 ++++ app/helpers/events_helper.rb | 7 ++-- app/views/users/show.html.haml | 44 ++++++++++++++++++++++ config/routes.rb | 3 ++ 6 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 app/controllers/users_controller.rb create mode 100644 app/views/users/show.html.haml diff --git a/app/assets/stylesheets/gitlab_bootstrap/common.scss b/app/assets/stylesheets/gitlab_bootstrap/common.scss index 6f439c9eaed..f6b4881658c 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/common.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/common.scss @@ -95,6 +95,7 @@ img.avatar { float: left; margin-right: 12px; width: 40px; border: 1px solid #dd img.avatar.s16 { width: 16px; height: 16px; margin-right: 6px; } img.avatar.s24 { width: 24px; height: 24px; margin-right: 8px; } img.avatar.s32 { width: 32px; height: 32px; margin-right: 10px; } +img.avatar.s90 { width: 90px; height: 90px; margin-right: 15px; } img.lil_av { padding-left: 4px; padding-right: 3px; } img.small { width: 80px; } diff --git a/app/assets/stylesheets/sections/header.scss b/app/assets/stylesheets/sections/header.scss index 048a3ffcbb2..5fe18131828 100644 --- a/app/assets/stylesheets/sections/header.scss +++ b/app/assets/stylesheets/sections/header.scss @@ -13,7 +13,7 @@ header { color: $style_color; text-shadow: 0 1px 0 #fff; font-size: 18px; - padding: 11px; + padding: 12px; } /** NAV block with links and profile **/ diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 00000000000..4d106dc7a21 --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,7 @@ +class UsersController < ApplicationController + def show + @user = User.find_by_username(params[:username]) + @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id)) + @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20) + end +end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index f4d9b17bce5..38374e3394d 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -1,10 +1,9 @@ module EventsHelper def link_to_author(event) - project = event.project - tm = project.team_member_by_id(event.author_id) if project + author = event.author - if tm - link_to event.author_name, project_team_member_path(project, tm) + if author + link_to author.name, user_path(author.username) else event.author_name end diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml new file mode 100644 index 00000000000..613ff358a87 --- /dev/null +++ b/app/views/users/show.html.haml @@ -0,0 +1,44 @@ +.row + .span8 + %h3.page_title + = image_tag gravatar_icon(@user.email, 90), class: "avatar s90" + = @user.name + %span.light (@#{@user.username}) + .clearfix + %hr + %h5 Recent events + = render @events + .span4 + .ui-box + %h5.title Profile + %ul.well-list + %li + %strong Email + %span.right= mail_to @user.email + - unless @user.skype.blank? + %li + %strong Skype + %span.right= @user.skype + - unless @user.linkedin.blank? + %li + %strong LinkedIn + %span.right= @user.linkedin + - unless @user.twitter.blank? + %li + %strong Twitter + %span.right= @user.twitter + - unless @user.bio.blank? + %li + %strong Bio + %span.right= @user.bio + .ui-box + %h5.title Projects + %ul.well-list + - @projects.each do |project| + %li + = link_to project_path(project), class: dom_class(project) do + - if project.namespace + = project.namespace.human_name + \/ + %strong.well-title + = truncate(project.name, length: 45) diff --git a/config/routes.rb b/config/routes.rb index 00ff3f63752..c48d66a78e8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -97,6 +97,9 @@ Gitlab::Application.routes.draw do end resources :keys + match "/u/:username" => "users#show", as: :user + + # # Dashboard Area -- cgit v1.2.1 From 96d97c4857cd2497108c8e5740ac8134cd439546 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 22 Jan 2013 19:45:13 +0200 Subject: Fix routing. Finalize user show page --- app/controllers/users_controller.rb | 2 +- app/models/team.rb | 4 ++++ app/views/users/_projects.html.haml | 20 ++++++++++++++++++++ app/views/users/show.html.haml | 17 +++++------------ config/routes.rb | 2 +- 5 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 app/views/users/_projects.html.haml diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4d106dc7a21..e027057fe65 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,6 +1,6 @@ class UsersController < ApplicationController def show - @user = User.find_by_username(params[:username]) + @user = User.find_by_username!(params[:username]) @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id)) @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20) end diff --git a/app/models/team.rb b/app/models/team.rb index f235d20ebdb..51f4ff68d7b 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -21,6 +21,10 @@ class Team end end + def get_tm user_id + project.users_projects.find_by_user_id(user_id) + end + def add_user(user, access) add_users_ids([user.id], access) end diff --git a/app/views/users/_projects.html.haml b/app/views/users/_projects.html.haml new file mode 100644 index 00000000000..f46a0ed1161 --- /dev/null +++ b/app/views/users/_projects.html.haml @@ -0,0 +1,20 @@ +.ui-box + %h5.title Projects + %ul.well-list + - @projects.each do |project| + %li + = link_to project_path(project), class: dom_class(project) do + - if project.namespace + = project.namespace.human_name + \/ + %strong.well-title + = truncate(project.name, length: 45) + %span.right.light + - if project.owner == @user + %i.icon-wrench + - tm = project.team.get_tm(@user.id) + - if tm + = tm.project_access_human +%p.light + %i.icon-wrench + – user is a project owner diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 613ff358a87..2a77c6bfa3d 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -3,7 +3,10 @@ %h3.page_title = image_tag gravatar_icon(@user.email, 90), class: "avatar s90" = @user.name - %span.light (@#{@user.username}) + %br + %small @#{@user.username} + %br + %small member since #{@user.created_at.stamp("Nov 12, 2031")} .clearfix %hr %h5 Recent events @@ -31,14 +34,4 @@ %li %strong Bio %span.right= @user.bio - .ui-box - %h5.title Projects - %ul.well-list - - @projects.each do |project| - %li - = link_to project_path(project), class: dom_class(project) do - - if project.namespace - = project.namespace.human_name - \/ - %strong.well-title - = truncate(project.name, length: 45) + = render 'projects' diff --git a/config/routes.rb b/config/routes.rb index c48d66a78e8..c7e81b6fe5a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -97,7 +97,7 @@ Gitlab::Application.routes.draw do end resources :keys - match "/u/:username" => "users#show", as: :user + match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ } -- cgit v1.2.1 From 0ed7f32db3114ea3b0e07acdfff7054904057af5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 22 Jan 2013 19:54:45 +0200 Subject: changelog --- CHANGELOG | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 2d05a51e77d..4510b6d5cd9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +v 4.2.0 + - User show page. Via /u/username + - Show help contents on pages for better navigation + v 4.1.0 - Optional Sign-Up - Discussions -- cgit v1.2.1