Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

#6 Show Lines For Any User

  • Loading branch information...
commit 926617e28360b16fe5bbb59fd9727325eea0562b 1 parent 18b3f8d
@tomgi authored
View
6 config/locales/en.yml
@@ -53,4 +53,8 @@ en:
close: Close
binary: Binary
text: Text
- general: General
+ general: General
+ details: Details
+ insertions_by_date: Lines added by date
+ deletions_by_date: Lines deleted by date
+ changed_lines_by_date: Changed lines by date
View
8 lib/git_stats/stats_view/charts/authors_charts.rb
@@ -7,10 +7,10 @@ def initialize(authors)
@authors = authors
end
- def commits_sum_by_author_by_date(limit = 4)
+ def commits_sum_by_author_by_date(limit = 4, authors = nil)
Chart.new do |f|
f.multi_date_chart(
- data: @authors.sort_by { |author| -author.commits.size }[0..limit].map { |author| {name: author.name, data: author.commits_sum_by_date} },
+ data: (authors || @authors.sort_by { |author| -author.commits.size }[0..limit]).map { |author| {name: author.name, data: author.commits_sum_by_date} },
title: :lines_by_date.t,
y_text: :lines.t
)
@@ -18,10 +18,10 @@ def commits_sum_by_author_by_date(limit = 4)
end
[:insertions, :deletions, :changed_lines].each do |method|
- define_method "#{method}_by_author_by_date" do |limit = 4|
+ define_method "#{method}_by_author_by_date" do |limit = 4, authors = nil|
Chart.new do |f|
f.multi_date_chart(
- data: @authors.sort_by { |author| -author.send(method) }[0..limit].map { |author| {name: author.name, data: author.send("#{method}_by_date")} },
+ data: (authors || @authors.sort_by { |author| -author.send(method) }[0..limit]).map { |author| {name: author.name, data: author.send("#{method}_by_date")} },
title: :lines_by_date.t,
y_text: :lines.t
)
View
12 lib/git_stats/stats_view/view.rb
@@ -11,20 +11,20 @@ def render_all
prepare_static_content
prepare_assets
- all_templates.each do |template|
+ all_templates.reject {|t| t =~ /author_details/}.each do |template|
output = Template.new(template, @layout).render(@view_data, author: @view_data.repo, links: links)
write(output, "#@out_path/#{template}.html")
end
- render_authors_activity
+ render_authors
end
- def render_authors_activity
+ def render_authors
done = []
@view_data.repo.authors.sort_by { |a| -a.commits.size }.each do |author|
next if done.include? author.dirname
done << author.dirname
- all_templates('activity/').each do |template|
+ (all_templates('activity/') + all_templates('author_details')).each do |template|
output = Template.new(template, @layout).render(@view_data,
author: author,
links: links,
@@ -35,11 +35,11 @@ def render_authors_activity
end
def all_templates(root = '')
- Dir["../../../../templates/#{root}**/[^_]*.haml".absolute_path].map {
+ (Dir["../../../../templates/#{root}**/[^_]*.haml".absolute_path].map {
|f| Pathname.new(f)
}.map { |f|
f.relative_path_from(Pathname.new('../../../../templates'.absolute_path)).sub_ext('')
- }.map(&:to_s) - %w(layout)
+ }.map(&:to_s) - %w(layout))
end
private
View
35 templates/author_details/_author_details.haml
@@ -0,0 +1,35 @@
+.tabbable.tabs-left
+ %ul.nav.nav-tabs
+ %li{class: page == :commits_by_date ? "active" : ""}
+ %a{href: 'commits_by_date.html'}= :commits_by_date.t
+ %li{class: page == :changed_lines_by_date ? "active" : ""}
+ %a{href: 'changed_lines_by_date.html'}= :changed_lines_by_date.t
+ %li{class: page == :insertions_by_date ? "active" : ""}
+ %a{href: 'insertions_by_date.html'}= :insertions_by_date.t
+ %li{class: page == :deletions_by_date ? "active" : ""}
+ %a{href: 'deletions_by_date.html'}= :deletions_by_date.t
+
+ .tab-content
+ .tab-pane.active
+ .page-header
+ %h1.pagination-centered= page.t
+
+ -if page == :commits_by_date
+ = high_stock("charts.commits_sum_by_author_by_date", charts.commits_sum_by_author_by_date(4, [author]))
+ %small
+ %center= "5 #{:best_authors_shown.t}"
+
+ -elsif page == :changed_lines_by_date
+ = high_stock("charts.changed_lines_by_author_by_date", charts.changed_lines_by_author_by_date(4, [author]))
+ %small
+ %center= "5 #{:best_authors_shown.t}"
+
+ -elsif page == :insertions_by_date
+ = high_stock("charts.insertions_by_author_by_date", charts.insertions_by_author_by_date(4, [author]))
+ %small
+ %center= "5 #{:best_authors_shown.t}"
+
+ -elsif page == :deletions_by_date
+ = high_stock("charts.deletions_by_author_by_date", charts.deletions_by_author_by_date(4, [author]))
+ %small
+ %center= "5 #{:best_authors_shown.t}"
View
1  templates/author_details/changed_lines_by_date.haml
@@ -0,0 +1 @@
+= render_partial('author_details/_author_details', page: :changed_lines_by_date, author: author)
View
1  templates/author_details/commits_by_date.haml
@@ -0,0 +1 @@
+= render_partial('author_details/_author_details', page: :commits_by_date, author: author)
View
1  templates/author_details/deletions_by_date.haml
@@ -0,0 +1 @@
+= render_partial('author_details/_author_details', page: :deletions_by_date, author: author)
View
1  templates/author_details/insertions_by_date.haml
@@ -0,0 +1 @@
+= render_partial('author_details/_author_details', page: :insertions_by_date, author: author)
View
4 templates/authors/_authors.haml
@@ -38,7 +38,9 @@
%td= I18n.localize(author.commits.first.try(:date), format: :long) rescue ""
%td= I18n.localize(author.commits.last.try(:date), format: :long) rescue ""
%td
- %a.btn{:href => "#{author.dirname}/activity/by_date.html"}= :show_more.t
+ %a.btn{:href => "#{author.dirname}/activity/by_date.html"}= :activity.t
+ %td
+ %a.btn{:href => "#{author.dirname}/author_details/commits_by_date.html"}= :details.t
-elsif page == :commits_count_by_author
= high_chart("charts.commits_count_by_author", charts.commits_count_by_author(4))
Please sign in to comment.
Something went wrong with that request. Please try again.