From 07fac90986e27cea0c62e5283f20554042867811 Mon Sep 17 00:00:00 2001 From: Tomasz Gieniusz Date: Mon, 22 Oct 2012 19:50:31 +0200 Subject: [PATCH] seperate pages instead of tabs --- config/locales/en.yml | 2 +- lib/git_stats.rb | 1 + lib/git_stats/git_data/author.rb | 4 + lib/git_stats/stats_view/template.rb | 2 +- lib/git_stats/stats_view/view.rb | 46 ++++++- lib/git_stats/stats_view/view_data.rb | 10 +- spec/git_data/commit_spec.rb | 6 +- spec/stats_view/view_spec.rb | 9 ++ templates/activity.haml | 1 - templates/{ => activity}/_activity.haml | 81 ++++++------- templates/activity/by_date.haml | 1 + templates/activity/day_of_week.haml | 1 + templates/activity/hour_of_day.haml | 1 + templates/activity/hour_of_week.haml | 1 + templates/activity/month_of_year.haml | 1 + templates/activity/year.haml | 1 + templates/activity/year_month.haml | 1 + templates/authors.haml | 112 ------------------ templates/authors/_authors.haml | 87 ++++++++++++++ templates/authors/best_authors.haml | 1 + .../authors/changed_lines_by_author.haml | 1 + .../changed_lines_by_author_by_date.haml | 1 + .../authors/commits_count_by_author.haml | 1 + .../commits_sum_by_author_by_date.haml | 1 + templates/authors/deletions_by_author.haml | 1 + .../authors/deletions_by_author_by_date.haml | 1 + templates/authors/insertions_by_author.haml | 1 + .../authors/insertions_by_author_by_date.haml | 1 + templates/files.haml | 18 --- templates/files/_files.haml | 15 +++ templates/files/by_date.haml | 1 + templates/files/by_extension.haml | 1 + templates/layout.haml | 34 ++---- templates/lines.haml | 18 --- templates/lines/_lines.haml | 15 +++ templates/lines/by_date.haml | 1 + templates/lines/by_extension.haml | 1 + 37 files changed, 247 insertions(+), 234 deletions(-) create mode 100644 spec/stats_view/view_spec.rb delete mode 100644 templates/activity.haml rename templates/{ => activity}/_activity.haml (50%) create mode 100644 templates/activity/by_date.haml create mode 100644 templates/activity/day_of_week.haml create mode 100644 templates/activity/hour_of_day.haml create mode 100644 templates/activity/hour_of_week.haml create mode 100644 templates/activity/month_of_year.haml create mode 100644 templates/activity/year.haml create mode 100644 templates/activity/year_month.haml delete mode 100644 templates/authors.haml create mode 100644 templates/authors/_authors.haml create mode 100644 templates/authors/best_authors.haml create mode 100644 templates/authors/changed_lines_by_author.haml create mode 100644 templates/authors/changed_lines_by_author_by_date.haml create mode 100644 templates/authors/commits_count_by_author.haml create mode 100644 templates/authors/commits_sum_by_author_by_date.haml create mode 100644 templates/authors/deletions_by_author.haml create mode 100644 templates/authors/deletions_by_author_by_date.haml create mode 100644 templates/authors/insertions_by_author.haml create mode 100644 templates/authors/insertions_by_author_by_date.haml delete mode 100644 templates/files.haml create mode 100644 templates/files/_files.haml create mode 100644 templates/files/by_date.haml create mode 100644 templates/files/by_extension.haml delete mode 100644 templates/lines.haml create mode 100644 templates/lines/_lines.haml create mode 100644 templates/lines/by_date.haml create mode 100644 templates/lines/by_extension.haml diff --git a/config/locales/en.yml b/config/locales/en.yml index a65d7840d..420ce7fd0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -49,6 +49,6 @@ en: first_commit: First_commit last_commit: Last commit author: Author - show_more: Show more + show_more: More close: Close more_data_not_available: More data not available \ No newline at end of file diff --git a/lib/git_stats.rb b/lib/git_stats.rb index c5bc56a48..86fbe0168 100644 --- a/lib/git_stats.rb +++ b/lib/git_stats.rb @@ -6,6 +6,7 @@ require 'action_pack' require 'action_view' require 'fileutils' require 'tilt' +require 'pathname' #require 'lazy_high_charts' require 'launchy' require 'i18n' diff --git a/lib/git_stats/git_data/author.rb b/lib/git_stats/git_data/author.rb index b307505bf..ec6200728 100644 --- a/lib/git_stats/git_data/author.rb +++ b/lib/git_stats/git_data/author.rb @@ -49,6 +49,10 @@ module GitStats @activity ||= Activity.new(commits) end + def dirname + @name.underscore.split.join '_' + end + def to_s "#{self.class} #@name <#@email>" end diff --git a/lib/git_stats/stats_view/template.rb b/lib/git_stats/stats_view/template.rb index 52426836b..0bc9840ba 100644 --- a/lib/git_stats/stats_view/template.rb +++ b/lib/git_stats/stats_view/template.rb @@ -9,7 +9,7 @@ module GitStats def render(data, params={}) if @layout - @layout.render(data, :active_page => @name, :all_templates => params[:all_templates]) { @template.render(data, params) } + @layout.render(data, :active_page => params[:active_page] || @name, :links => params[:links]) { @template.render(data, params) } else @template.render(data, params) end diff --git a/lib/git_stats/stats_view/view.rb b/lib/git_stats/stats_view/view.rb index 5d4fa7370..c59cdee90 100644 --- a/lib/git_stats/stats_view/view.rb +++ b/lib/git_stats/stats_view/view.rb @@ -3,25 +3,59 @@ module GitStats class View def initialize(view_data, out_path) @view_data, @out_path = view_data, out_path + @layout = Tilt.new("templates/layout.haml") end def render_all prepare_static_content prepare_assets - layout = Tilt.new("templates/layout.haml") - all_templates.each do |template| - output = Template.new(template, layout).render(@view_data, all_templates: all_templates) - File.open("#@out_path/#{template}.html", 'w') { |f| f.write output } + output = Template.new(template, @layout).render(@view_data, author: @view_data.repo, links: links) + write(output, "#@out_path/#{template}.html") + end + + render_authors_activity + end + + def render_authors_activity + 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| + output = Template.new(template, @layout).render(@view_data, + author: author, + links: links, + active_page: "/authors/#{author.dirname}/#{template}") + write(output, "#@out_path/authors/#{author.dirname}/#{template}.html") + end end end + def all_templates(root = '') + Dir["templates/#{root}**/[^_]*.haml"].map { + |f| Pathname.new(f) + }.map { |f| + f.relative_path_from(Pathname.new('templates')).sub_ext('') + }.map(&:to_s) - %w(layout) + end private - def all_templates - %w(general activity authors files lines) + def write(output, write_file) + FileUtils.mkdir_p(File.dirname(write_file)) + File.open(write_file, 'w') { |f| f.write output } + end + + def links + { + 'General' => 'general.html', + 'Activity' => 'activity/by_date.html', + 'Authors' => 'authors/best_authors.html', + 'Files' => 'files/by_date.html', + 'Lines' => 'lines/by_date.html' + } end def prepare_static_content diff --git a/lib/git_stats/stats_view/view_data.rb b/lib/git_stats/stats_view/view_data.rb index 992365837..41b419772 100644 --- a/lib/git_stats/stats_view/view_data.rb +++ b/lib/git_stats/stats_view/view_data.rb @@ -13,10 +13,18 @@ module GitStats @charts ||= Charts::All.new(repo) end - def render(template_name, params = {}) + def render_partial(template_name, params = {}) Template.new(template_name).render(self, params) end + def asset_path(asset, active_page) + Pathname.new("/assets/#{asset}").relative_path_from(Pathname.new("/#{active_page}").dirname) + end + + def link_to(href, active_page) + Pathname.new("/#{href}").relative_path_from(Pathname.new("/#{active_page}").dirname) + end + end end end \ No newline at end of file diff --git a/spec/git_data/commit_spec.rb b/spec/git_data/commit_spec.rb index 723be38ff..7854cc29f 100644 --- a/spec/git_data/commit_spec.rb +++ b/spec/git_data/commit_spec.rb @@ -8,7 +8,7 @@ describe GitStats::GitData::Commit do before { commit.repo.should_receive(:run).with('git ls-tree -r abc').and_return("100644 blob 5ade7ad51a75ee7db4eb06cecd3918d38134087d lib/git_stats/git_data/commit.rb 100644 blob db01e94677a8f72289848e507a52a43de2ea109a lib/git_stats/git_data/repo.rb -100644 blob 1463eacb3ac9f95f21f360f1eb935a84a9ee0895 templates/activity.haml +100644 blob 1463eacb3ac9f95f21f360f1eb935a84a9ee0895 templates/index.haml 100644 blob 31d8b960a67f195bdedaaf9e7aa70b2389f3f1a8 templates/assets/bootstrap/css/bootstrap.min.css ") } @@ -16,7 +16,7 @@ describe GitStats::GitData::Commit do commit.files.should == [ GitStats::GitData::Blob.new(repo: commit.repo, sha: "5ade7ad51a75ee7db4eb06cecd3918d38134087d", filename: "lib/git_stats/git_data/commit.rb"), GitStats::GitData::Blob.new(repo: commit.repo, sha: "db01e94677a8f72289848e507a52a43de2ea109a", filename: "lib/git_stats/git_data/repo.rb"), - GitStats::GitData::Blob.new(repo: commit.repo, sha: "1463eacb3ac9f95f21f360f1eb935a84a9ee0895", filename: "templates/activity.haml"), + GitStats::GitData::Blob.new(repo: commit.repo, sha: "1463eacb3ac9f95f21f360f1eb935a84a9ee0895", filename: "templates/index.haml"), GitStats::GitData::Blob.new(repo: commit.repo, sha: "31d8b960a67f195bdedaaf9e7aa70b2389f3f1a8", filename: "templates/assets/bootstrap/css/bootstrap.min.css"), ] end @@ -26,7 +26,7 @@ describe GitStats::GitData::Commit do GitStats::GitData::Blob.new(repo: commit.repo, sha: "5ade7ad51a75ee7db4eb06cecd3918d38134087d", filename: "lib/git_stats/git_data/commit.rb"), GitStats::GitData::Blob.new(repo: commit.repo, sha: "db01e94677a8f72289848e507a52a43de2ea109a", filename: "lib/git_stats/git_data/repo.rb") ], '.haml' => [ - GitStats::GitData::Blob.new(repo: commit.repo, sha: "1463eacb3ac9f95f21f360f1eb935a84a9ee0895", filename: "templates/activity.haml") + GitStats::GitData::Blob.new(repo: commit.repo, sha: "1463eacb3ac9f95f21f360f1eb935a84a9ee0895", filename: "templates/index.haml") ], '.css' => [ GitStats::GitData::Blob.new(repo: commit.repo, sha: "31d8b960a67f195bdedaaf9e7aa70b2389f3f1a8", filename: "templates/assets/bootstrap/css/bootstrap.min.css") ] diff --git a/spec/stats_view/view_spec.rb b/spec/stats_view/view_spec.rb new file mode 100644 index 000000000..9c6f4a2b7 --- /dev/null +++ b/spec/stats_view/view_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +describe GitStats::StatsView::View do + let(:view) { GitStats::StatsView::View.new(double('view_data'), 'out_path') } + + it 'should find all haml except partials and layout in templates directory' do + view.all_templates.should =~ %w(files activity/index general authors lines) + end +end \ No newline at end of file diff --git a/templates/activity.haml b/templates/activity.haml deleted file mode 100644 index 74c98672f..000000000 --- a/templates/activity.haml +++ /dev/null @@ -1 +0,0 @@ -= render '_activity', author: repo \ No newline at end of file diff --git a/templates/_activity.haml b/templates/activity/_activity.haml similarity index 50% rename from templates/_activity.haml rename to templates/activity/_activity.haml index 8605dba4d..e69fe8384 100644 --- a/templates/_activity.haml +++ b/templates/activity/_activity.haml @@ -1,30 +1,29 @@ .tabbable.tabs-left %ul.nav.nav-tabs - %li.active - %a{:href => "#activity_by_date-#{author.hash}", 'data-toogle' => 'tab'}= :activity_by_date.t - %li - %a{:href => "#hour_of_day-#{author.hash}", 'data-toogle' => 'tab'}= :hour_of_day.t - %li - %a{:href => "#day_of_week-#{author.hash}", 'data-toogle' => 'tab'}= :day_of_week.t - %li - %a{:href => "#hour_of_week-#{author.hash}", 'data-toogle' => 'tab'}= :hour_of_week.t - %li - %a{:href => "#month_of_year-#{author.hash}", 'data-toogle' => 'tab'}= :month_of_year.t - %li - %a{:href => "#year-#{author.hash}", 'data-toogle' => 'tab'}= :year.t - %li - %a{:href => "#year_month-#{author.hash}", 'data-toogle' => 'tab'}= :year_month.t + %li{class: page == :activity_by_date ? "active" : "" } + %a{href: "by_date.html"}= :activity_by_date.t + %li{class: page == :hour_of_day ? "active" : "" } + %a{href: "hour_of_day.html"}= :hour_of_day.t + %li{class: page == :day_of_week ? "active" : "" } + %a{href: "day_of_week.html"}= :day_of_week.t + %li{class: page == :hour_of_week ? "active" : "" } + %a{href: "hour_of_week.html"}= :hour_of_week.t + %li{class: page == :month_of_year ? "active" : "" } + %a{href: "month_of_year.html"}= :month_of_year.t + %li{class: page == :year ? "active" : "" } + %a{href: "year.html"}= :year.t + %li{class: page == :year_month ? "active" : "" } + %a{href: "year_month.html"}= :year_month.t .tab-content - .tab-pane.active{id: "activity_by_date-#{author.hash}"} - .page-header - %h1.pagination-centered= :activity_by_date.t - = high_stock("charts.activity_by_date-#{author.hash}", charts.activity_by_date(author)) + .tab-pane.active + .page-header.pagination-centered + %h1= page.t + %h3= author.respond_to?(:name) ? author.name : "" + - if page == :activity_by_date + = high_stock("charts.activity_by_date", charts.activity_by_date(author)) - - .tab-pane{id: "hour_of_day-#{author.hash}"} - .page-header - %h1.pagination-centered= :hour_of_day.t + - elsif page == :hour_of_day %table{:class => "table table-bordered table-condensed"} %tr %th= :hour.t @@ -38,11 +37,9 @@ %th= :percentage.t - author.activity.by_hour_array.each do |commits| %td= (commits * 100.0 / author.activity.by_hour_array.sum).round(1) - = high_chart("charts.activity_by_hour-#{author.hash}", charts.activity_by_hour(author)) + = high_chart("charts.activity_by_hour", charts.activity_by_hour(author)) - .tab-pane{id: "day_of_week-#{author.hash}"} - .page-header - %h1.pagination-centered= :day_of_week.t + - elsif page == :day_of_week %table{:class => "table table-bordered table-condensed"} %tr %th= :day.t @@ -56,32 +53,26 @@ %th= :percentage.t - author.activity.by_wday_array.each do |commits| %td= (commits * 100.0 / author.activity.by_wday_array.sum).round(1) - = high_chart("charts.activity_by_wday-#{author.hash}", charts.activity_by_wday(author)) + = high_chart("charts.activity_by_wday", charts.activity_by_wday(author)) - - .tab-pane{id: "hour_of_week-#{author.hash}"} - .page-header - %h1.pagination-centered= :hour_of_week.t + - elsif page == :hour_of_week %table{:class => "table table-bordered table-condensed"} %tr %th - (0..23).each do |h| %th= h - - max = author.activity.by_wday_hour.values.map {|h| h.values.max }.max + - max = author.activity.by_wday_hour.values.map {|h| h.values.empty? ? 0 : h.values.max }.max - (0..6).each do |day| %tr %th= Date::ABBR_DAYNAMES[day] - (0..23).each do |hour| - - color = "%02x" % (255 - author.activity.by_wday_hour[day][hour] * 100 / max) + - color = max ? "%02x" % (255 - author.activity.by_wday_hour[day][hour] * 100 / max) : "FF" %td{style: "background-color: ##{color}#{color}#{color};"}= author.activity.by_wday_hour[day][hour] - - .tab-pane{id: "month_of_year-#{author.hash}"} - .page-header - %h1.pagination-centered= :month_of_year.t + - elsif page == :month_of_year %table{:class => "table table-bordered table-condensed"} %tr - %th= :day.t + %th= :month.t - Date::ABBR_MONTHNAMES[1..-1].each do |m| %th= m %tr @@ -92,18 +83,12 @@ %th= :percentage.t - author.activity.by_month_array.each do |commits| %td= (commits * 100.0 / author.activity.by_month_array.sum).round(1) - = high_chart("charts.activity_by_month-#{author.hash}", charts.activity_by_month(author)) + = high_chart("charts.activity_by_month", charts.activity_by_month(author)) + - elsif page == :year + = high_chart("charts.activity_by_year", charts.activity_by_year(author)) - .tab-pane{id: "year-#{author.hash}"} - .page-header - %h1.pagination-centered= :year.t - = high_chart("charts.activity_by_year-#{author.hash}", charts.activity_by_year(author)) - - - .tab-pane{id: "year_month-#{author.hash}"} - .page-header - %h1.pagination-centered= :year_month.t + - elsif page == :year_month %table{:class => "table table-bordered table-condensed"} %tr %th diff --git a/templates/activity/by_date.haml b/templates/activity/by_date.haml new file mode 100644 index 000000000..748b897e4 --- /dev/null +++ b/templates/activity/by_date.haml @@ -0,0 +1 @@ += render_partial('activity/_activity', page: :activity_by_date, author: author) \ No newline at end of file diff --git a/templates/activity/day_of_week.haml b/templates/activity/day_of_week.haml new file mode 100644 index 000000000..20b595dc4 --- /dev/null +++ b/templates/activity/day_of_week.haml @@ -0,0 +1 @@ += render_partial('activity/_activity', page: :day_of_week, author: author) \ No newline at end of file diff --git a/templates/activity/hour_of_day.haml b/templates/activity/hour_of_day.haml new file mode 100644 index 000000000..2852c2087 --- /dev/null +++ b/templates/activity/hour_of_day.haml @@ -0,0 +1 @@ += render_partial('activity/_activity', page: :hour_of_day, author: author) \ No newline at end of file diff --git a/templates/activity/hour_of_week.haml b/templates/activity/hour_of_week.haml new file mode 100644 index 000000000..7f1946732 --- /dev/null +++ b/templates/activity/hour_of_week.haml @@ -0,0 +1 @@ += render_partial('activity/_activity', page: :hour_of_week, author: author) \ No newline at end of file diff --git a/templates/activity/month_of_year.haml b/templates/activity/month_of_year.haml new file mode 100644 index 000000000..f7f6ba44f --- /dev/null +++ b/templates/activity/month_of_year.haml @@ -0,0 +1 @@ += render_partial('activity/_activity', page: :month_of_year, author: author) \ No newline at end of file diff --git a/templates/activity/year.haml b/templates/activity/year.haml new file mode 100644 index 000000000..689c4899c --- /dev/null +++ b/templates/activity/year.haml @@ -0,0 +1 @@ += render_partial('activity/_activity', page: :year, author: author) \ No newline at end of file diff --git a/templates/activity/year_month.haml b/templates/activity/year_month.haml new file mode 100644 index 000000000..68bc2de35 --- /dev/null +++ b/templates/activity/year_month.haml @@ -0,0 +1 @@ += render_partial('activity/_activity', page: :year_month, author: author) \ No newline at end of file diff --git a/templates/authors.haml b/templates/authors.haml deleted file mode 100644 index 4bb7366dd..000000000 --- a/templates/authors.haml +++ /dev/null @@ -1,112 +0,0 @@ -.tabbable.tabs-left - %ul.nav.nav-tabs - %li.active - %a{:href => '#best_authors', 'data-toogle' => 'tab'}= :best_authors.t - %li - %a{:href => '#commits_count_by_author', 'data-toogle' => 'tab'}= :commits_count_by_author.t - %li - %a{:href => '#changed_lines_by_author', 'data-toogle' => 'tab'}= :changed_lines_by_author.t - %li - %a{:href => '#insertions_by_author', 'data-toogle' => 'tab'}= :insertions_by_author.t - %li - %a{:href => '#deletions_by_author', 'data-toogle' => 'tab'}= :deletions_by_author.t - %li - %a{:href => '#commits_sum_by_author_by_date', 'data-toogle' => 'tab'}= :commits_sum_by_author_by_date.t - %li - %a{:href => '#changed_lines_by_author_by_date', 'data-toogle' => 'tab'}= :changed_lines_by_author_by_date.t - %li - %a{:href => '#insertions_by_author_by_date', 'data-toogle' => 'tab'}= :insertions_by_author_by_date.t - %li - %a{:href => '#deletions_by_author_by_date', 'data-toogle' => 'tab'}= :deletions_by_author_by_date.t - - .tab-content - .tab-pane.active{id: 'best_authors'} - .page-header - %h1.pagination-centered= :best_authors.t - %table{:class => "table table-bordered table-condensed table-hover"} - %tr - %th= :author.t - %th= :commits.t - %th= :insertions.t - %th= :deletions.t - %th= :first_commit.t - %th= :last_commit.t - %th - - sorted_authors = repo.authors.sort_by { |a| -a.commits.size} - - sorted_authors.each_with_index do |author, i| - %tr - %th= author.name - %td= author.commits.size - %td= author.insertions - %td= author.deletions - %td= author.commits.first.try(:date).try(:to_formatted_s, :long) - %td= author.commits.last.try(:date).try(:to_formatted_s, :long) - %td - - if i <= 4 - %a.btn{:href => "##{author.hash}-modal", :role => "button", 'data-toggle'=>"modal"}= :show_more.t - - else - = :more_data_not_available.t - - sorted_authors[0..4].each do |author| - .modal.hide{:id => "#{author.hash}-modal", :role => "dialog", :style => "width: 1140px; margin-left:-570px; top: 35%; "} - .modal-header - %h1.pagination-centered= "#{author.name} <#{author.email}>" - .modal-body{:style => "height: 620px; max-height: 80%;"} - = render '_activity', author: author - .modal-footer - %a.btn{'data-dismiss' => "modal"}= :close.t - - .tab-pane{id: 'commits_count_by_author'} - .page-header - %h1.pagination-centered= :commits_count_by_author.t - = high_chart("charts.commits_count_by_author", charts.commits_count_by_author) - %small - %center= "5 #{:best_authors_shown.t}" - - .tab-pane{id: 'changed_lines_by_author'} - .page-header - %h1.pagination-centered= :changed_lines_by_author.t - = high_chart("charts.changed_lines_by_author", charts.changed_lines_by_author) - %small - %center= "5 #{:best_authors_shown.t}" - - .tab-pane{id: 'insertions_by_author'} - .page-header - %h1.pagination-centered= :insertions_by_author.t - = high_chart("charts.insertions_by_author", charts.insertions_by_author) - %small - %center= "5 #{:best_authors_shown.t}" - - .tab-pane{id: 'deletions_by_author'} - .page-header - %h1.pagination-centered= :deletions_by_author.t - = high_chart("charts.deletions_by_author", charts.deletions_by_author) - %small - %center= "5 #{:best_authors_shown.t}" - - .tab-pane{id: 'commits_sum_by_author_by_date'} - .page-header - %h1.pagination-centered= :commits_sum_by_author_by_date.t - = high_stock("charts.commits_sum_by_author_by_date", charts.commits_sum_by_author_by_date) - %small - %center= "5 #{:best_authors_shown.t}" - - .tab-pane{id: 'insertions_by_author_by_date'} - .page-header - %h1.pagination-centered= :insertions_by_author_by_date.t - = high_stock("charts.insertions_by_author_by_date", charts.insertions_by_author_by_date) - %small - %center= "5 #{:best_authors_shown.t}" - - .tab-pane{id: 'changed_lines_by_author_by_date'} - .page-header - %h1.pagination-centered= :changed_lines_by_author_by_date.t - = high_stock("charts.changed_lines_by_author_by_date", charts.changed_lines_by_author_by_date) - %small - %center= "5 #{:best_authors_shown.t}" - - .tab-pane{id: 'deletions_by_author_by_date'} - .page-header - %h1.pagination-centered= :deletions_by_author_by_date.t - = high_stock("charts.deletions_by_author_by_date", charts.deletions_by_author_by_date) - %small - %center= "5 #{:best_authors_shown.t}" diff --git a/templates/authors/_authors.haml b/templates/authors/_authors.haml new file mode 100644 index 000000000..08d3027b2 --- /dev/null +++ b/templates/authors/_authors.haml @@ -0,0 +1,87 @@ +.tabbable.tabs-left + %ul.nav.nav-tabs + %li{class: page == :best_authors ? "active" : ""} + %a{href: 'best_authors.html'}= :best_authors.t + %li{class: page == :commits_count_by_author ? "active" : ""} + %a{href: 'commits_count_by_author.html'}= :commits_count_by_author.t + %li{class: page == :changed_lines_by_author ? "active" : ""} + %a{href: 'changed_lines_by_author.html'}= :changed_lines_by_author.t + %li{class: page == :insertions_by_author ? "active" : ""} + %a{href: 'insertions_by_author.html'}= :insertions_by_author.t + %li{class: page == :deletions_by_author ? "active" : ""} + %a{href: 'deletions_by_author.html'}= :deletions_by_author.t + %li{class: page == :commits_sum_by_author_by_date ? "active" : ""} + %a{href: 'commits_sum_by_author_by_date.html'}= :commits_sum_by_author_by_date.t + %li{class: page == :changed_lines_by_author_by_date ? "active" : ""} + %a{href: 'changed_lines_by_author_by_date.html'}= :changed_lines_by_author_by_date.t + %li{class: page == :insertions_by_author_by_date ? "active" : ""} + %a{href: 'insertions_by_author_by_date.html'}= :insertions_by_author_by_date.t + %li{class: page == :deletions_by_author_by_date ? "active" : ""} + %a{href: 'deletions_by_author_by_date.html'}= :deletions_by_author_by_date.t + + .tab-content + .tab-pane.active + .page-header + %h1.pagination-centered= page.t + + - if page == :best_authors + %table{:class => "table table-bordered table-condensed table-hover"} + %tr + %th= :author.t + %th= :commits.t + %th= :insertions.t + %th= :deletions.t + %th= :first_commit.t + %th= :last_commit.t + %th + - sorted_authors = repo.authors.sort_by { |a| -a.commits.size} + - sorted_authors.each_with_index do |author, i| + %tr + %th= author.name + %td= author.commits.size + %td= author.insertions + %td= author.deletions + %td= author.commits.first.try(:date).try(:to_formatted_s, :long) + %td= author.commits.last.try(:date).try(:to_formatted_s, :long) + %td + %a.btn{:href => "#{author.dirname}/activity/by_date.html"}= :show_more.t + + -elsif page == :commits_count_by_author + = high_chart("charts.commits_count_by_author", charts.commits_count_by_author) + %small + %center= "5 #{:best_authors_shown.t}" + + -elsif page == :changed_lines_by_author + = high_chart("charts.changed_lines_by_author", charts.changed_lines_by_author) + %small + %center= "5 #{:best_authors_shown.t}" + + -elsif page == :insertions_by_author + = high_chart("charts.insertions_by_author", charts.insertions_by_author) + %small + %center= "5 #{:best_authors_shown.t}" + + -elsif page == :deletions_by_author + = high_chart("charts.deletions_by_author", charts.deletions_by_author) + %small + %center= "5 #{:best_authors_shown.t}" + + -elsif page == :commits_sum_by_author_by_date + = high_stock("charts.commits_sum_by_author_by_date", charts.commits_sum_by_author_by_date) + %small + %center= "5 #{:best_authors_shown.t}" + + -elsif page == :changed_lines_by_author_by_date + = high_stock("charts.changed_lines_by_author_by_date", charts.changed_lines_by_author_by_date) + %small + %center= "5 #{:best_authors_shown.t}" + + -elsif page == :insertions_by_author_by_date + = high_stock("charts.insertions_by_author_by_date", charts.insertions_by_author_by_date) + %small + %center= "5 #{:best_authors_shown.t}" + + -elsif page == :deletions_by_author_by_date + = high_stock("charts.deletions_by_author_by_date", charts.deletions_by_author_by_date) + %small + %center= "5 #{:best_authors_shown.t}" diff --git a/templates/authors/best_authors.haml b/templates/authors/best_authors.haml new file mode 100644 index 000000000..5b07ead3f --- /dev/null +++ b/templates/authors/best_authors.haml @@ -0,0 +1 @@ += render_partial('authors/_authors', page: :best_authors) \ No newline at end of file diff --git a/templates/authors/changed_lines_by_author.haml b/templates/authors/changed_lines_by_author.haml new file mode 100644 index 000000000..69c21c715 --- /dev/null +++ b/templates/authors/changed_lines_by_author.haml @@ -0,0 +1 @@ += render_partial('authors/_authors', page: :changed_lines_by_author) \ No newline at end of file diff --git a/templates/authors/changed_lines_by_author_by_date.haml b/templates/authors/changed_lines_by_author_by_date.haml new file mode 100644 index 000000000..e310a7994 --- /dev/null +++ b/templates/authors/changed_lines_by_author_by_date.haml @@ -0,0 +1 @@ += render_partial('authors/_authors', page: :changed_lines_by_author_by_date) \ No newline at end of file diff --git a/templates/authors/commits_count_by_author.haml b/templates/authors/commits_count_by_author.haml new file mode 100644 index 000000000..4b5a6c796 --- /dev/null +++ b/templates/authors/commits_count_by_author.haml @@ -0,0 +1 @@ += render_partial('authors/_authors', page: :commits_count_by_author) \ No newline at end of file diff --git a/templates/authors/commits_sum_by_author_by_date.haml b/templates/authors/commits_sum_by_author_by_date.haml new file mode 100644 index 000000000..bc7eaf1cc --- /dev/null +++ b/templates/authors/commits_sum_by_author_by_date.haml @@ -0,0 +1 @@ += render_partial('authors/_authors', page: :commits_sum_by_author_by_date) \ No newline at end of file diff --git a/templates/authors/deletions_by_author.haml b/templates/authors/deletions_by_author.haml new file mode 100644 index 000000000..d919b5784 --- /dev/null +++ b/templates/authors/deletions_by_author.haml @@ -0,0 +1 @@ += render_partial('authors/_authors', page: :deletions_by_author) \ No newline at end of file diff --git a/templates/authors/deletions_by_author_by_date.haml b/templates/authors/deletions_by_author_by_date.haml new file mode 100644 index 000000000..cda92974f --- /dev/null +++ b/templates/authors/deletions_by_author_by_date.haml @@ -0,0 +1 @@ += render_partial('authors/_authors', page: :deletions_by_author_by_date) \ No newline at end of file diff --git a/templates/authors/insertions_by_author.haml b/templates/authors/insertions_by_author.haml new file mode 100644 index 000000000..4f5d6f57c --- /dev/null +++ b/templates/authors/insertions_by_author.haml @@ -0,0 +1 @@ += render_partial('authors/_authors', page: :insertions_by_author) \ No newline at end of file diff --git a/templates/authors/insertions_by_author_by_date.haml b/templates/authors/insertions_by_author_by_date.haml new file mode 100644 index 000000000..6157ffb36 --- /dev/null +++ b/templates/authors/insertions_by_author_by_date.haml @@ -0,0 +1 @@ += render_partial('authors/_authors', page: :insertions_by_author_by_date) \ No newline at end of file diff --git a/templates/files.haml b/templates/files.haml deleted file mode 100644 index 3b4c62a03..000000000 --- a/templates/files.haml +++ /dev/null @@ -1,18 +0,0 @@ -.tabbable.tabs-left - %ul.nav.nav-tabs - %li.active - %a{:href => '#files_by_date', 'data-toogle' => 'tab'}= :files_by_date.t - %li - %a{:href => '#files_by_extension', 'data-toogle' => 'tab'}= :files_by_extension.t - - .tab-content - .tab-pane.active{id: 'files_by_date'} - .page-header - %h1.pagination-centered= :files_by_date.t - = high_stock("charts.files_by_date", charts.files_by_date) - - - .tab-pane{id: 'files_by_extension'} - .page-header - %h1.pagination-centered= :files_by_extension.t - = high_chart("charts.files_by_extension", charts.files_by_extension) diff --git a/templates/files/_files.haml b/templates/files/_files.haml new file mode 100644 index 000000000..fd234f55e --- /dev/null +++ b/templates/files/_files.haml @@ -0,0 +1,15 @@ +.tabbable.tabs-left + %ul.nav.nav-tabs + %li{class: page == :files_by_date ? "active" : ""} + %a{:href => 'by_date.html'}= :files_by_date.t + %li{class: page == :files_by_extension ? "active" : ""} + %a{:href => 'by_extension.html'}= :files_by_extension.t + + .tab-content + .tab-pane.active + .page-header + %h1.pagination-centered= page.t + - if page == :files_by_date + = high_stock("files_by_date", charts.files_by_date) + - elsif page == :files_by_extension + = high_chart("files_by_extension", charts.files_by_extension) diff --git a/templates/files/by_date.haml b/templates/files/by_date.haml new file mode 100644 index 000000000..5dd0ef022 --- /dev/null +++ b/templates/files/by_date.haml @@ -0,0 +1 @@ += render_partial('files/_files', page: :files_by_date) \ No newline at end of file diff --git a/templates/files/by_extension.haml b/templates/files/by_extension.haml new file mode 100644 index 000000000..c622455a0 --- /dev/null +++ b/templates/files/by_extension.haml @@ -0,0 +1 @@ += render_partial('files/_files', page: :files_by_extension) \ No newline at end of file diff --git a/templates/layout.haml b/templates/layout.haml index b05b4de02..a486fb16e 100644 --- a/templates/layout.haml +++ b/templates/layout.haml @@ -3,30 +3,14 @@ %html %head %title= "GitStats - #{repo.project_name}" - %link{:rel => "stylesheet", :href => "assets/bootstrap/css/bootstrap.min.css", :type => "text/css"} + %link{:rel => "stylesheet", :href => asset_path('bootstrap/css/bootstrap.min.css', active_page), :type => "text/css"} %style :plain body { padding-top: 60px; } - %link{:rel => "stylesheet", :href => "assets/bootstrap/css/bootstrap-responsive.min.css", :type => "text/css"} - %script{:src => "assets/jquery.min.js", :type => "text/javascript"} - %script{:src => "assets/bootstrap/js/bootstrap.min.js", :type => "text/javascript"} - %script{:src => "assets/highstock.js", :type => "text/javascript"} - %script - :plain - $(function() { - $('.tabbable ul a').click(function (e) { - e.preventDefault(); - $(this).tab('show'); - var ev = document.createEvent('Event'); - ev.initEvent('resize', true, true); - window.dispatchEvent(ev); - }); - $('.modal').on('shown', function (e) { - var ev = document.createEvent('Event'); - ev.initEvent('resize', true, true); - window.dispatchEvent(ev); - }); - }); + %link{:rel => "stylesheet", :href => asset_path('bootstrap/css/bootstrap-responsive.min.css', active_page), :type => "text/css"} + %script{:src => asset_path('jquery.min.js', active_page), :type => "text/javascript"} + %script{:src => asset_path('bootstrap/js/bootstrap.min.js', active_page), :type => "text/javascript"} + %script{:src => asset_path('highstock.js', active_page), :type => "text/javascript"} %body %div.navbar.navbar-fixed-top %div.navbar-inner @@ -35,11 +19,11 @@ %span.icon-bar %span.icon-bar %span.icon-bar - %a.brand{:href => "index.html"}= "GitStats - #{repo.project_name}" + %a.brand{:href => link_to("index.html", active_page)}= "GitStats - #{repo.project_name}" %div.nav-collapse.collapse %ul.nav - - all_templates.each do |link| - %li{:class => active_page == link ? "active" : ""} - %a{:href => "#{link}.html"}= link.capitalize + - links.each do |name, href| + %li{:class => active_page[name.underscore] ? "active" : ""} + %a{:href => link_to(href, active_page)}= name %div.container = yield diff --git a/templates/lines.haml b/templates/lines.haml deleted file mode 100644 index d809fd1ab..000000000 --- a/templates/lines.haml +++ /dev/null @@ -1,18 +0,0 @@ -.tabbable.tabs-left - %ul.nav.nav-tabs - %li.active - %a{:href => '#lines_by_date', 'data-toogle' => 'tab'}= :lines_by_date.t - %li - %a{:href => '#lines_by_extension', 'data-toogle' => 'tab'}= :lines_by_extension.t - - .tab-content - .tab-pane.active{id: 'lines_by_date'} - .page-header - %h1.pagination-centered= :lines_by_date.t - = high_stock("charts.lines_by_date", charts.lines_by_date) - - - .tab-pane{id: 'lines_by_extension'} - .page-header - %h1.pagination-centered= :lines_by_extension.t - = high_chart("charts.lines_by_extension", charts.lines_by_extension) diff --git a/templates/lines/_lines.haml b/templates/lines/_lines.haml new file mode 100644 index 000000000..81292e105 --- /dev/null +++ b/templates/lines/_lines.haml @@ -0,0 +1,15 @@ +.tabbable.tabs-left + %ul.nav.nav-tabs + %li{class: page == :lines_by_date ? "active" : ""} + %a{:href => 'by_date.html'}= :lines_by_date.t + %li{class: page == :lines_by_extension ? "active" : ""} + %a{:href => 'by_extension.html'}= :lines_by_extension.t + + .tab-content + .tab-pane.active + .page-header + %h1.pagination-centered= page.t + - if page == :lines_by_date + = high_stock("lines_by_date", charts.lines_by_date) + - elsif page == :lines_by_extension + = high_chart("lines_by_extension", charts.lines_by_extension) diff --git a/templates/lines/by_date.haml b/templates/lines/by_date.haml new file mode 100644 index 000000000..f85cdfa8d --- /dev/null +++ b/templates/lines/by_date.haml @@ -0,0 +1 @@ += render_partial('lines/_lines', page: :lines_by_date) \ No newline at end of file diff --git a/templates/lines/by_extension.haml b/templates/lines/by_extension.haml new file mode 100644 index 000000000..117603454 --- /dev/null +++ b/templates/lines/by_extension.haml @@ -0,0 +1 @@ += render_partial('lines/_lines', page: :lines_by_extension) \ No newline at end of file