mirror of https://github.com/tomgi/git_stats.git
generating sample page
This commit is contained in:
parent
f322835ba0
commit
ba3eaeae0a
|
@ -18,5 +18,10 @@ Gem::Specification.new do |gem|
|
|||
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
||||
gem.require_paths = ["lib"]
|
||||
|
||||
|
||||
gem.add_dependency('tilt')
|
||||
gem.add_dependency('haml')
|
||||
gem.add_dependency('launchy')
|
||||
|
||||
gem.add_development_dependency('pry')
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class GitStats::Assets
|
||||
def self.prepare(out_path)
|
||||
FileUtils.cp_r('templates/assets', out_path)
|
||||
end
|
||||
end
|
|
@ -1,4 +1,5 @@
|
|||
require "gitstats"
|
||||
require "launchy"
|
||||
|
||||
class GitStats::CLI
|
||||
|
||||
|
@ -10,6 +11,7 @@ class GitStats::CLI
|
|||
repo_path, out_path = args
|
||||
validate(repo_path, out_path)
|
||||
GitStats::Generator.new(repo_path, out_path).generate
|
||||
Launchy.open("#{out_path}/index.html")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,6 +4,10 @@ class GitStats::Generator
|
|||
end
|
||||
|
||||
def generate
|
||||
puts "generating..."
|
||||
data = GitStats::GitData.new(@repo_path)
|
||||
data.gather_all_data
|
||||
GitStats::Assets.prepare(@out_path)
|
||||
output = GitStats::Template.new('index').render(data)
|
||||
File.open("#{@out_path}/index.html", 'w') { |f| f.write output }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
class GitStats::GitData
|
||||
attr_reader :total_authors
|
||||
attr_reader :total_commits
|
||||
|
||||
def initialize(repo_path)
|
||||
@repo_path = repo_path
|
||||
end
|
||||
|
||||
def gather_all_data
|
||||
Dir.chdir(@repo_path) {
|
||||
@total_authors = %x[git shortlog -s HEAD | wc -l]
|
||||
}
|
||||
end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
require 'tilt'
|
||||
|
||||
class GitStats::Template
|
||||
def initialize(name)
|
||||
@name = name
|
||||
@@layout ||= Tilt.new("templates/layout.haml")
|
||||
@template = Tilt.new("templates/#{@name}.haml")
|
||||
end
|
||||
|
||||
def render(data)
|
||||
@@layout.render { @template.render(data) }
|
||||
end
|
||||
end
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,7 @@
|
|||
%table
|
||||
%tr
|
||||
%td= total_authors
|
||||
%td bbb
|
||||
%tr
|
||||
%td cc
|
||||
%td dd
|
|
@ -0,0 +1,28 @@
|
|||
!!! XML
|
||||
!!!
|
||||
%html
|
||||
%head
|
||||
%title GitStats
|
||||
%link{:rel => "stylesheet", :href => "assets/bootstrap/css/bootstrap.min.css", :type => "text/css"}
|
||||
%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"}
|
||||
%body
|
||||
%div.navbar.navbar-inverse.navbar-fixed-top
|
||||
%div.navbar-inner
|
||||
%div.container
|
||||
%a.btn.btn-navbar{'data-toggle' => "collapse", 'data-target' => ".nav-collapse"}
|
||||
%span.icon-bar
|
||||
%span.icon-bar
|
||||
%span.icon-bar
|
||||
%a.brand{:href => "#"} Project name
|
||||
%div.nav-collapse.collapse
|
||||
%ul.nav
|
||||
%li.active
|
||||
%a{:href => "#"} Home
|
||||
%li
|
||||
%a{:href => "#"} Home2
|
||||
%li
|
||||
%a{:href => "#"} Hom3
|
||||
%div.container
|
||||
= yield
|
Loading…
Reference in New Issue