From f87f0201f0e3386d1e0408a217650b545f57029a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 6 Nov 2011 22:21:48 +0200 Subject: [PATCH 1/3] link to author on tree view item --- app/assets/stylesheets/projects.css.scss | 9 +++++++++ app/helpers/application_helper.rb | 4 ++++ app/views/commits/_commits.html.haml | 2 +- app/views/projects/_tree_item.html.haml | 7 +++++-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index c31f795a..7dfd8b29 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -667,6 +667,15 @@ table.highlighttable pre{ .cred { color:#D12F19; } .cgreen { color:#44aa22; } +body.project-page table .commit { + a.tree-commit-link { + color:gray; + &:hover { + text-decoration:underline; + } + } +} + body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} body.project-page #notes-list .note img{float: left; margin-right: 10px;} diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 70984804..70047c41 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,6 +4,10 @@ module ApplicationHelper "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(user_email)}?s=40&d=identicon" end + def fixed_mode? + @view_mode == :fixed + end + def body_class(default_class = nil) main = content_for(:body_class).blank? ? default_class : diff --git a/app/views/commits/_commits.html.haml b/app/views/commits/_commits.html.haml index 2d393993..f47252ab 100644 --- a/app/views/commits/_commits.html.haml +++ b/app/views/commits/_commits.html.haml @@ -17,7 +17,7 @@ = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" %span.commit-title %strong - = truncate(commit.safe_message, :length => 60) + = truncate(commit.safe_message, :length => fixed_mode? ? 60 : 120) %span.commit-author %strong= commit.author_name = time_ago_in_words(commit.committed_date) diff --git a/app/views/projects/_tree_item.html.haml b/app/views/projects/_tree_item.html.haml index 53c05d5a..d15c379b 100644 --- a/app/views/projects/_tree_item.html.haml +++ b/app/views/projects/_tree_item.html.haml @@ -11,5 +11,8 @@ %td = time_ago_in_words(content_commit.committed_date) ago - %td - = link_to truncate(content_commit.safe_message, :length => 40), project_commit_path(@project, content_commit) + %td.commit + = link_to truncate(content_commit.safe_message, :length => fixed_mode? ? 40 : 80), project_commit_path(@project, content_commit), :class => "tree-commit-link" + - user = @project.users.find_by_email(content_commit.author_email) + - if user + = link_to "[#{user.name}]", project_team_member_path(@project, @project.users_projects.find_by_user_id(user.id)) From b4868a897284940a3e5e8e6ebcc246f21fb17fbe Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 6 Nov 2011 22:38:08 +0200 Subject: [PATCH 2/3] Improved commit author detection --- app/models/project.rb | 5 +++++ app/views/projects/_tree_item.html.haml | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index de68f451..a5b6224b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -50,6 +50,11 @@ class Project < ActiveRecord::Base code end + def team_member_by_name_or_email(email = nil, name = nil) + user = users.where("email like ? or name like ?", email, name).first + users_projects.find_by_user_id(user.id) if user + end + def common_notes notes.where(:noteable_type => ["", nil]) end diff --git a/app/views/projects/_tree_item.html.haml b/app/views/projects/_tree_item.html.haml index d15c379b..273d0272 100644 --- a/app/views/projects/_tree_item.html.haml +++ b/app/views/projects/_tree_item.html.haml @@ -13,6 +13,6 @@ ago %td.commit = link_to truncate(content_commit.safe_message, :length => fixed_mode? ? 40 : 80), project_commit_path(@project, content_commit), :class => "tree-commit-link" - - user = @project.users.find_by_email(content_commit.author_email) - - if user - = link_to "[#{user.name}]", project_team_member_path(@project, @project.users_projects.find_by_user_id(user.id)) + - tm = @project.team_member_by_name_or_email(content_commit.author_email, content_commit.author_name) + - if tm + = link_to "[#{tm.user_name}]", project_team_member_path(@project, tm) From e29a25662dac63c2f1ef0041eeb7b6fd24d3896e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 6 Nov 2011 22:53:36 +0200 Subject: [PATCH 3/3] fixed 1click repo url selection --- app/views/layouts/project.html.haml | 46 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/app/views/layouts/project.html.haml b/app/views/layouts/project.html.haml index ee6581ec..984ff4d0 100644 --- a/app/views/layouts/project.html.haml +++ b/app/views/layouts/project.html.haml @@ -16,29 +16,29 @@ .project-container .project-sidebar .fixed - %input.git-url.text{:id => "", :name => "", :readonly => "", :type => "text", :value => @project.url_to_repo} - %aside - = link_to "History", project_path(@project), :class => current_page?(:controller => "projects", :action => "show", :id => @project) ? "current" : nil - = link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil - = link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil - = link_to team_project_path(@project), :class => (current_page?(:controller => "projects", :action => "team", :id => @project) || controller.controller_name == "team_members") ? "current" : nil do - Team - - if @project.users_projects.count > 0 - %span{ :class => "number" }= @project.users_projects.count - = link_to project_issues_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do - Issues - - if @project.issues.opened.count > 0 - %span{ :class => "number" }= @project.issues.opened.count - = link_to wall_project_path(@project), :class => current_page?(:controller => "projects", :action => "wall", :id => @project) ? "current" : nil do - Wall - - if @project.common_notes.count > 0 - %span{ :class => "number" }= @project.common_notes.count - = link_to project_snippets_path(@project), :class => (controller.controller_name == "snippets") ? "current" : nil do - Snippets - - if @project.snippets.count > 0 - %span{ :class => "number" }= @project.snippets.non_expired.count - - if @commit - = link_to truncate(commit_name(@project,@commit), :length => 15), project_commit_path(@project, :id => @commit.id), :class => current_page?(:controller => "commits", :action => "show", :project_id => @project, :id => @commit.id) ? "current" : nil + %input.git-url.text{:id => "", :name => "", :readonly => "", :type => "text", :value => @project.url_to_repo, :class => "one_click_select"} + %aside + = link_to "History", project_path(@project), :class => current_page?(:controller => "projects", :action => "show", :id => @project) ? "current" : nil + = link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil + = link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil + = link_to team_project_path(@project), :class => (current_page?(:controller => "projects", :action => "team", :id => @project) || controller.controller_name == "team_members") ? "current" : nil do + Team + - if @project.users_projects.count > 0 + %span{ :class => "number" }= @project.users_projects.count + = link_to project_issues_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do + Issues + - if @project.issues.opened.count > 0 + %span{ :class => "number" }= @project.issues.opened.count + = link_to wall_project_path(@project), :class => current_page?(:controller => "projects", :action => "wall", :id => @project) ? "current" : nil do + Wall + - if @project.common_notes.count > 0 + %span{ :class => "number" }= @project.common_notes.count + = link_to project_snippets_path(@project), :class => (controller.controller_name == "snippets") ? "current" : nil do + Snippets + - if @project.snippets.count > 0 + %span{ :class => "number" }= @project.snippets.non_expired.count + - if @commit + = link_to truncate(commit_name(@project,@commit), :length => 15), project_commit_path(@project, :id => @commit.id), :class => current_page?(:controller => "commits", :action => "show", :project_id => @project, :id => @commit.id) ? "current" : nil .project-content = yield