Commit c29b49de668c4f6adc271516242249a9cec6e223
1 parent
5a5845e4
Exists in
master
and in
4 other branches
project dashboard
Showing
5 changed files
with
69 additions
and
13 deletions
Show diff stats
app/controllers/projects_controller.rb
| ... | ... | @@ -6,7 +6,7 @@ class ProjectsController < ApplicationController |
| 6 | 6 | before_filter :authorize_read_project!, :except => [:index, :new, :create] |
| 7 | 7 | before_filter :authorize_admin_project!, :only => [:edit, :update, :destroy] |
| 8 | 8 | |
| 9 | - before_filter :require_non_empty_project, :only => [:blob, :tree] | |
| 9 | + before_filter :require_non_empty_project, :only => [:blob, :tree, :show] | |
| 10 | 10 | |
| 11 | 11 | def index |
| 12 | 12 | @projects = current_user.projects.all |
| ... | ... | @@ -60,15 +60,13 @@ class ProjectsController < ApplicationController |
| 60 | 60 | end |
| 61 | 61 | |
| 62 | 62 | def show |
| 63 | - @repo = project.repo | |
| 64 | - @commit = @repo.commits.first | |
| 65 | - @tree = @commit.tree | |
| 66 | - @tree = @tree / params[:path] if params[:path] | |
| 63 | + @date = Date.today - 7.days | |
| 64 | + @heads = @project.repo.heads | |
| 65 | + @commits = @heads.map do |h| | |
| 66 | + @project.repo.log(h.name, nil, :since => @date) | |
| 67 | + end.flatten.uniq { |c| c.id } | |
| 67 | 68 | |
| 68 | - rescue Grit::NoSuchPathError => ex | |
| 69 | - respond_to do |format| | |
| 70 | - format.html {render "projects/empty"} | |
| 71 | - end | |
| 69 | + @messages = project.notes.last_week.limit(40).order("created_at DESC") | |
| 72 | 70 | end |
| 73 | 71 | |
| 74 | 72 | # | ... | ... |
app/helpers/projects_helper.rb
| ... | ... | @@ -3,4 +3,16 @@ module ProjectsHelper |
| 3 | 3 | cookies["project_view"] ||= "tile" |
| 4 | 4 | cookies["project_view"] == type ? nil : "display:none" |
| 5 | 5 | end |
| 6 | + | |
| 7 | + def noteable_link(id, type, project) | |
| 8 | + case type | |
| 9 | + when "Issue" | |
| 10 | + link_to "Issue ##{id}", project_issue_path(project, id) | |
| 11 | + when "Commit" | |
| 12 | + commit = project.repo.commits(id).first | |
| 13 | + link_to truncate(commit.id,:length => 10), project_commit_path(project, id) | |
| 14 | + else | |
| 15 | + link_to "Wall", wall_project_path(project) | |
| 16 | + end | |
| 17 | + end | |
| 6 | 18 | end | ... | ... |
app/models/note.rb
| ... | ... | @@ -22,6 +22,8 @@ class Note < ActiveRecord::Base |
| 22 | 22 | |
| 23 | 23 | scope :common, where(:noteable_id => nil) |
| 24 | 24 | |
| 25 | + scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days)) | |
| 26 | + | |
| 25 | 27 | mount_uploader :attachment, AttachmentUploader |
| 26 | 28 | end |
| 27 | 29 | # == Schema Information | ... | ... |
app/views/projects/_top_menu.html.haml
| 1 | 1 | %div.top_project_menu |
| 2 | 2 | -#%span= link_to @project.code.capitalize, @project, :class => current_page?(:controller => "projects", :action => "show", :id => @project) ? "current" : nil |
| 3 | 3 | - if @project.repo_exists? |
| 4 | - %span= link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "show", :id => @project) || current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil | |
| 4 | + %span= link_to image_tag("home.png", :width => 20), project_path(@project), :class => current_page?(:controller => "projects", :action => "show", :id => @project) ? "current" : nil | |
| 5 | + %span= link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil | |
| 5 | 6 | %span= link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil |
| 6 | 7 | %span |
| 7 | 8 | = link_to team_project_path(@project), :class => current_page?(:controller => "projects", :action => "team", :id => @project) ? "current" : nil do | ... | ... |
app/views/projects/show.html.haml
| 1 | -%div | |
| 2 | - %div#tree-holder | |
| 3 | - = render :partial => "tree", :locals => {:repo => @repo, :commit => @commit, :tree => @commit.tree} | |
| 1 | +.span-12 | |
| 2 | + %h2 Recent commits | |
| 3 | + %hr | |
| 4 | + - @commits.each do |commit| | |
| 5 | + %div.commit | |
| 6 | + - if commit.author.email | |
| 7 | + = image_tag gravatar_icon(commit.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" | |
| 8 | + - else | |
| 9 | + = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" | |
| 10 | + %p{:style => "margin-bottom: 3px;"} | |
| 11 | + %strong | |
| 12 | + = link_to truncate_commit_message(commit, 60), project_commit_path(@project, :id => commit.id) | |
| 13 | + | |
| 14 | + %span | |
| 15 | + %span | |
| 16 | + [ #{commit.author} ] | |
| 17 | + %cite | |
| 18 | + = time_ago_in_words(commit.committed_date) | |
| 19 | + ago | |
| 20 | + %br | |
| 21 | +.span-11 | |
| 22 | + %h2 Recent Messages | |
| 23 | + %hr | |
| 24 | + - @messages.group_by{ |x| [x.noteable_id, x.noteable_type]}.each do |item, notes| | |
| 25 | + %h3 | |
| 26 | + = noteable_link(item[0], item[1], @project) | |
| 27 | + - notes.each do |note| | |
| 28 | + %div.message | |
| 29 | + .span-2 | |
| 30 | + | |
| 31 | + = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" | |
| 32 | + %p{:style => "margin-bottom: 3px;"} | |
| 33 | + = link_to truncate(note.note, :length => 50), "#" | |
| 34 | + - if note.attachment.url | |
| 35 | + %br | |
| 36 | + Attachment: | |
| 37 | + = link_to note.attachment_identifier, note.attachment.url | |
| 38 | + %br | |
| 39 | + %span | |
| 40 | + %span | |
| 41 | + [ #{note.author.name} ] | |
| 42 | + %cite | |
| 43 | + = time_ago_in_words(note.created_at) | |
| 44 | + ago | |
| 45 | + %br | |
| 46 | + | ... | ... |