dsaboard
This commit is contained in:
parent
dbd69d1d0e
commit
1a03b17ab5
|
@ -552,3 +552,26 @@ tbody tr:nth-child(2n) td, tbody tr.even td {
|
||||||
height: 12px;
|
height: 12px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.recent_message_parent {
|
||||||
|
img {
|
||||||
|
padding-right:10px;
|
||||||
|
}
|
||||||
|
background: #fff !important;
|
||||||
|
background: -webkit-gradient(linear,left top,left bottom,from(#fff),to(#EAEAEA)) !important;
|
||||||
|
background: -moz-linear-gradient(top,#fff,#EAEAEA) !important;
|
||||||
|
background: transparent 9 !important;
|
||||||
|
|
||||||
|
float: left;
|
||||||
|
margin: 0 20px 20px 0px;
|
||||||
|
padding: 5px 5px;;
|
||||||
|
width: 420px;
|
||||||
|
|
||||||
|
h4 {
|
||||||
|
margin-bottom:3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -60,17 +60,21 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@date = Date.today - 7.days
|
@date = case params[:view]
|
||||||
|
when "week" then Date.today - 7.days
|
||||||
|
else Date.today
|
||||||
|
end
|
||||||
|
|
||||||
@heads = @project.repo.heads
|
@heads = @project.repo.heads
|
||||||
@commits = @heads.map do |h|
|
@commits = @heads.map do |h|
|
||||||
@project.repo.log(h.name, nil, :since => @date)
|
@project.repo.log(h.name, nil, :since => @date - 1.day)
|
||||||
end.flatten.uniq { |c| c.id }
|
end.flatten.uniq { |c| c.id }
|
||||||
|
|
||||||
@commits.sort! do |x, y|
|
@commits.sort! do |x, y|
|
||||||
y.committed_date <=> x.committed_date
|
y.committed_date <=> x.committed_date
|
||||||
end
|
end
|
||||||
|
|
||||||
@messages = project.notes.last_week.limit(40).order("created_at DESC")
|
@messages = project.notes.since(@date).limit(40).order("created_at DESC")
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -4,15 +4,14 @@ module ProjectsHelper
|
||||||
cookies["project_view"] == type ? nil : "display:none"
|
cookies["project_view"] == type ? nil : "display:none"
|
||||||
end
|
end
|
||||||
|
|
||||||
def noteable_link(id, type, project)
|
def load_note_parent(id, type, project)
|
||||||
case type
|
case type
|
||||||
when "Issue"
|
when "Issue" then @project.issues.find(id)
|
||||||
link_to "Issue ##{id}", project_issue_path(project, id)
|
when "Commit" then @project.repo.commits(id).first
|
||||||
when "Commit"
|
|
||||||
commit = project.repo.commits(id).first
|
|
||||||
link_to truncate(commit.id,:length => 10), project_commit_path(project, id)
|
|
||||||
else
|
else
|
||||||
link_to "Wall", wall_project_path(project)
|
true
|
||||||
end
|
end
|
||||||
|
rescue
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,6 +23,7 @@ class Note < ActiveRecord::Base
|
||||||
scope :common, where(:noteable_id => nil)
|
scope :common, where(:noteable_id => nil)
|
||||||
|
|
||||||
scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days))
|
scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days))
|
||||||
|
scope :since, lambda { |day| where("created_at >= :date", :date => (day)) }
|
||||||
|
|
||||||
mount_uploader :attachment, AttachmentUploader
|
mount_uploader :attachment, AttachmentUploader
|
||||||
end
|
end
|
||||||
|
|
18
app/views/projects/_recent_commits.html.haml
Normal file
18
app/views/projects/_recent_commits.html.haml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
- @commits.each do |commit|
|
||||||
|
%div.commit
|
||||||
|
- if commit.author.email
|
||||||
|
= image_tag gravatar_icon(commit.author.email), :class => "left", :width => 40, :style => "padding-right:5px;"
|
||||||
|
- else
|
||||||
|
= image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;"
|
||||||
|
%p{:style => "margin-bottom: 3px;"}
|
||||||
|
%strong
|
||||||
|
= link_to truncate_commit_message(commit, 60), project_commit_path(@project, :id => commit.id)
|
||||||
|
|
||||||
|
%span
|
||||||
|
%span
|
||||||
|
[ #{commit.author} ]
|
||||||
|
%cite
|
||||||
|
= time_ago_in_words(commit.committed_date)
|
||||||
|
ago
|
||||||
|
%br
|
||||||
|
|
48
app/views/projects/_recent_messages.html.haml
Normal file
48
app/views/projects/_recent_messages.html.haml
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
- @messages.group_by{ |x| [x.noteable_id, x.noteable_type]}.each do |item, notes|
|
||||||
|
- id, type = item[0], item[1]
|
||||||
|
- parent = load_note_parent(id, type, @project)
|
||||||
|
- next unless parent
|
||||||
|
|
||||||
|
- case type
|
||||||
|
- when "Issue"
|
||||||
|
- issue = parent
|
||||||
|
- item_code = issue.author.email
|
||||||
|
- link_item_name = truncate(issue.title, :length => 50)
|
||||||
|
- link_to_item = project_issue_path(@project, issue)
|
||||||
|
- when "Commit"
|
||||||
|
- commit = parent
|
||||||
|
- item_code = commit.author.email
|
||||||
|
- link_item_name = truncate_commit_message(commit, 50)
|
||||||
|
- link_to_item = project_commit_path(@project, :id => commit.id)
|
||||||
|
- else
|
||||||
|
- item_code = @project.name
|
||||||
|
- link_item_name = "Project Wall"
|
||||||
|
- link_to_item = wall_project_path(@project)
|
||||||
|
|
||||||
|
%div.recent_message_parent
|
||||||
|
= image_tag gravatar_icon(item_code), :class => "left", :width => 40
|
||||||
|
%h4
|
||||||
|
= link_to(link_item_name, link_to_item)
|
||||||
|
%span
|
||||||
|
= type
|
||||||
|
.clear
|
||||||
|
- notes.sort {|x,y| x.updated_at <=> y.updated_at }.each do |note|
|
||||||
|
%div.message
|
||||||
|
= image_tag gravatar_icon(note.author.email), :class => "left", :width => 24, :style => "padding-right:5px;"
|
||||||
|
%p{:style => "margin-bottom: 3px;"}
|
||||||
|
= link_to truncate(note.note, :length => 50), "#"
|
||||||
|
- if note.attachment.url
|
||||||
|
%br
|
||||||
|
Attachment:
|
||||||
|
= link_to note.attachment_identifier, note.attachment.url
|
||||||
|
%br
|
||||||
|
%span
|
||||||
|
%span
|
||||||
|
[ #{note.author.name} ]
|
||||||
|
%cite
|
||||||
|
= time_ago_in_words(note.created_at)
|
||||||
|
ago
|
||||||
|
%br
|
||||||
|
.append-bottom
|
||||||
|
|
||||||
|
.clear
|
|
@ -1,44 +1,20 @@
|
||||||
.span-12
|
%div
|
||||||
%h2 Recent commits
|
%h2.left Recent history
|
||||||
|
.right
|
||||||
|
= form_tag project_path(@project), :method => :get do
|
||||||
|
.span-2
|
||||||
|
= radio_button_tag :view, "day", (params[:view] || "day") == "day", :onclick => "this.form.submit()", :id => "day_view"
|
||||||
|
= label_tag "day_view","Day"
|
||||||
|
.span-2
|
||||||
|
= radio_button_tag :view, "week", params[:view] == "week", :onclick => "this.form.submit()", :id => "week_view"
|
||||||
|
= label_tag "week_view","Week"
|
||||||
|
.clear
|
||||||
%hr
|
%hr
|
||||||
- @commits.each do |commit|
|
|
||||||
%div.commit
|
|
||||||
- if commit.author.email
|
|
||||||
= image_tag gravatar_icon(commit.author.email), :class => "left", :width => 40, :style => "padding-right:5px;"
|
|
||||||
- else
|
|
||||||
= image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;"
|
|
||||||
%p{:style => "margin-bottom: 3px;"}
|
|
||||||
%strong
|
|
||||||
= link_to truncate_commit_message(commit, 60), project_commit_path(@project, :id => commit.id)
|
|
||||||
|
|
||||||
%span
|
|
||||||
%span
|
|
||||||
[ #{commit.author} ]
|
|
||||||
%cite
|
|
||||||
= time_ago_in_words(commit.committed_date)
|
|
||||||
ago
|
|
||||||
%br
|
|
||||||
.span-11
|
.span-11
|
||||||
%h2 Recent Messages
|
%h3 Commits
|
||||||
%hr
|
=render "projects/recent_commits"
|
||||||
- @messages.group_by{ |x| [x.noteable_id, x.noteable_type]}.each do |item, notes|
|
|
||||||
%h3
|
.span-11.right
|
||||||
= noteable_link(item[0], item[1], @project)
|
%h3 Messages
|
||||||
- notes.each do |note|
|
=render "projects/recent_messages"
|
||||||
%div.message
|
|
||||||
= image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;"
|
|
||||||
%p{:style => "margin-bottom: 3px;"}
|
|
||||||
= link_to truncate(note.note, :length => 50), "#"
|
|
||||||
- if note.attachment.url
|
|
||||||
%br
|
|
||||||
Attachment:
|
|
||||||
= link_to note.attachment_identifier, note.attachment.url
|
|
||||||
%br
|
|
||||||
%span
|
|
||||||
%span
|
|
||||||
[ #{note.author.name} ]
|
|
||||||
%cite
|
|
||||||
= time_ago_in_words(note.created_at)
|
|
||||||
ago
|
|
||||||
%br
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue