Commit 1a03b17ab5055babaf006c99306f7c27b6e2ddaa
1 parent
dbd69d1d
Exists in
master
and in
4 other branches
dsaboard
Showing
7 changed files
with
120 additions
and
51 deletions
Show diff stats
app/assets/stylesheets/projects.css.scss
... | ... | @@ -552,3 +552,26 @@ tbody tr:nth-child(2n) td, tbody tr.even td { |
552 | 552 | height: 12px; |
553 | 553 | padding: 10px; |
554 | 554 | } |
555 | + | |
556 | +.recent_message_parent { | |
557 | + img { | |
558 | + padding-right:10px; | |
559 | + } | |
560 | + background: #fff !important; | |
561 | + background: -webkit-gradient(linear,left top,left bottom,from(#fff),to(#EAEAEA)) !important; | |
562 | + background: -moz-linear-gradient(top,#fff,#EAEAEA) !important; | |
563 | + background: transparent 9 !important; | |
564 | + | |
565 | + float: left; | |
566 | + margin: 0 20px 20px 0px; | |
567 | + padding: 5px 5px;; | |
568 | + width: 420px; | |
569 | + | |
570 | + h4 { | |
571 | + margin-bottom:3px; | |
572 | + } | |
573 | + | |
574 | + span { | |
575 | + | |
576 | + } | |
577 | +} | ... | ... |
app/controllers/projects_controller.rb
... | ... | @@ -60,17 +60,21 @@ class ProjectsController < ApplicationController |
60 | 60 | end |
61 | 61 | |
62 | 62 | def show |
63 | - @date = Date.today - 7.days | |
63 | + @date = case params[:view] | |
64 | + when "week" then Date.today - 7.days | |
65 | + else Date.today | |
66 | + end | |
67 | + | |
64 | 68 | @heads = @project.repo.heads |
65 | 69 | @commits = @heads.map do |h| |
66 | - @project.repo.log(h.name, nil, :since => @date) | |
70 | + @project.repo.log(h.name, nil, :since => @date - 1.day) | |
67 | 71 | end.flatten.uniq { |c| c.id } |
68 | 72 | |
69 | 73 | @commits.sort! do |x, y| |
70 | 74 | y.committed_date <=> x.committed_date |
71 | 75 | end |
72 | 76 | |
73 | - @messages = project.notes.last_week.limit(40).order("created_at DESC") | |
77 | + @messages = project.notes.since(@date).limit(40).order("created_at DESC") | |
74 | 78 | end |
75 | 79 | |
76 | 80 | # | ... | ... |
app/helpers/projects_helper.rb
... | ... | @@ -4,15 +4,14 @@ module ProjectsHelper |
4 | 4 | cookies["project_view"] == type ? nil : "display:none" |
5 | 5 | end |
6 | 6 | |
7 | - def noteable_link(id, type, project) | |
7 | + def load_note_parent(id, type, project) | |
8 | 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) | |
9 | + when "Issue" then @project.issues.find(id) | |
10 | + when "Commit" then @project.repo.commits(id).first | |
14 | 11 | else |
15 | - link_to "Wall", wall_project_path(project) | |
12 | + true | |
16 | 13 | end |
14 | + rescue | |
15 | + nil | |
17 | 16 | end |
18 | 17 | end | ... | ... |
app/models/note.rb
... | ... | @@ -23,6 +23,7 @@ class Note < ActiveRecord::Base |
23 | 23 | scope :common, where(:noteable_id => nil) |
24 | 24 | |
25 | 25 | scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days)) |
26 | + scope :since, lambda { |day| where("created_at >= :date", :date => (day)) } | |
26 | 27 | |
27 | 28 | mount_uploader :attachment, AttachmentUploader |
28 | 29 | end | ... | ... |
... | ... | @@ -0,0 +1,18 @@ |
1 | +- @commits.each do |commit| | |
2 | + %div.commit | |
3 | + - if commit.author.email | |
4 | + = image_tag gravatar_icon(commit.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" | |
5 | + - else | |
6 | + = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" | |
7 | + %p{:style => "margin-bottom: 3px;"} | |
8 | + %strong | |
9 | + = link_to truncate_commit_message(commit, 60), project_commit_path(@project, :id => commit.id) | |
10 | + | |
11 | + %span | |
12 | + %span | |
13 | + [ #{commit.author} ] | |
14 | + %cite | |
15 | + = time_ago_in_words(commit.committed_date) | |
16 | + ago | |
17 | + %br | |
18 | + | ... | ... |
... | ... | @@ -0,0 +1,48 @@ |
1 | +- @messages.group_by{ |x| [x.noteable_id, x.noteable_type]}.each do |item, notes| | |
2 | + - id, type = item[0], item[1] | |
3 | + - parent = load_note_parent(id, type, @project) | |
4 | + - next unless parent | |
5 | + | |
6 | + - case type | |
7 | + - when "Issue" | |
8 | + - issue = parent | |
9 | + - item_code = issue.author.email | |
10 | + - link_item_name = truncate(issue.title, :length => 50) | |
11 | + - link_to_item = project_issue_path(@project, issue) | |
12 | + - when "Commit" | |
13 | + - commit = parent | |
14 | + - item_code = commit.author.email | |
15 | + - link_item_name = truncate_commit_message(commit, 50) | |
16 | + - link_to_item = project_commit_path(@project, :id => commit.id) | |
17 | + - else | |
18 | + - item_code = @project.name | |
19 | + - link_item_name = "Project Wall" | |
20 | + - link_to_item = wall_project_path(@project) | |
21 | + | |
22 | + %div.recent_message_parent | |
23 | + = image_tag gravatar_icon(item_code), :class => "left", :width => 40 | |
24 | + %h4 | |
25 | + = link_to(link_item_name, link_to_item) | |
26 | + %span | |
27 | + = type | |
28 | + .clear | |
29 | + - notes.sort {|x,y| x.updated_at <=> y.updated_at }.each do |note| | |
30 | + %div.message | |
31 | + = image_tag gravatar_icon(note.author.email), :class => "left", :width => 24, :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 | + .append-bottom | |
47 | + | |
48 | + .clear | ... | ... |
app/views/projects/show.html.haml
1 | -.span-12 | |
2 | - %h2 Recent commits | |
1 | +%div | |
2 | + %h2.left Recent history | |
3 | + .right | |
4 | + = form_tag project_path(@project), :method => :get do | |
5 | + .span-2 | |
6 | + = radio_button_tag :view, "day", (params[:view] || "day") == "day", :onclick => "this.form.submit()", :id => "day_view" | |
7 | + = label_tag "day_view","Day" | |
8 | + .span-2 | |
9 | + = radio_button_tag :view, "week", params[:view] == "week", :onclick => "this.form.submit()", :id => "week_view" | |
10 | + = label_tag "week_view","Week" | |
11 | + .clear | |
3 | 12 | %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 | 13 | .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 | - = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" | |
30 | - %p{:style => "margin-bottom: 3px;"} | |
31 | - = link_to truncate(note.note, :length => 50), "#" | |
32 | - - if note.attachment.url | |
33 | - %br | |
34 | - Attachment: | |
35 | - = link_to note.attachment_identifier, note.attachment.url | |
36 | - %br | |
37 | - %span | |
38 | - %span | |
39 | - [ #{note.author.name} ] | |
40 | - %cite | |
41 | - = time_ago_in_words(note.created_at) | |
42 | - ago | |
43 | - %br | |
14 | + %h3 Commits | |
15 | + =render "projects/recent_commits" | |
16 | + | |
17 | +.span-11.right | |
18 | + %h3 Messages | |
19 | + =render "projects/recent_messages" | |
44 | 20 | ... | ... |