mirror of
https://github.com/tomgi/git_stats.git
synced 2024-09-28 19:51:29 +02:00
pages seperation
This commit is contained in:
parent
32d84e3ddd
commit
2d7a7db33c
@ -10,7 +10,8 @@ module GitStats
|
||||
repo = GitData::Repo.new(@repo_path)
|
||||
view_data = StatsView::ViewData.new(repo)
|
||||
|
||||
StatsView::View.render_all(view_data, @out_path)
|
||||
view = StatsView::View.new(view_data, @out_path)
|
||||
view.render_all
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -7,8 +7,8 @@ module GitStats
|
||||
@template = Tilt.new("templates/#@name.haml")
|
||||
end
|
||||
|
||||
def render(data)
|
||||
@layout.render { @template.render(data) }
|
||||
def render(data, all_templates)
|
||||
@layout.render(data, :active_page => @name, :all_templates => all_templates) { @template.render(data) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,17 +1,29 @@
|
||||
module GitStats
|
||||
module StatsView
|
||||
class View
|
||||
def self.render_all(data, out_path)
|
||||
prepare_assets(out_path)
|
||||
def initialize(view_data, out_path)
|
||||
@view_data, @out_path = view_data, out_path
|
||||
end
|
||||
|
||||
def render_all
|
||||
prepare_assets
|
||||
|
||||
layout = Tilt.new("templates/layout.haml")
|
||||
output = Template.new('index', layout).render(data)
|
||||
File.open("#{out_path}/index.html", 'w') { |f| f.write output }
|
||||
|
||||
all_templates.each do |template|
|
||||
output = Template.new(template, layout).render(@view_data, all_templates)
|
||||
File.open("#@out_path/#{template}.html", 'w') { |f| f.write output }
|
||||
end
|
||||
end
|
||||
|
||||
def self.prepare_assets(out_path)
|
||||
FileUtils.cp_r('templates/assets', out_path)
|
||||
def all_templates
|
||||
@all_templates ||= (Dir["templates/*.haml"] - Dir["templates/layout.haml"]).map { |t| File.basename(t, ".haml") }
|
||||
end
|
||||
|
||||
def prepare_assets
|
||||
FileUtils.cp_r('templates/assets', @out_path)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -24,7 +24,9 @@ describe GitStats::Generator do
|
||||
view_data = double('view_data')
|
||||
GitStats::StatsView::ViewData.should_receive(:new).with(repo).and_return(view_data)
|
||||
|
||||
GitStats::StatsView::View.should_receive(:render_all).with(view_data, out_path)
|
||||
view = double('view')
|
||||
GitStats::StatsView::View.should_receive(:new).with(view_data, out_path).and_return(view)
|
||||
view.should_receive(:render_all)
|
||||
|
||||
generator.generate
|
||||
end
|
||||
|
1
templates/authors.haml
Normal file
1
templates/authors.haml
Normal file
@ -0,0 +1 @@
|
||||
= high_chart("my_id", h)
|
@ -1,4 +1,2 @@
|
||||
%p= repo.project_name
|
||||
%p= repo.project_version
|
||||
|
||||
= high_chart("my_id", h)
|
@ -2,7 +2,7 @@
|
||||
!!!
|
||||
%html
|
||||
%head
|
||||
%title GitStats
|
||||
%title= "GitStats - #{repo.project_name}"
|
||||
%link{:rel => "stylesheet", :href => "assets/bootstrap/css/bootstrap.min.css", :type => "text/css"}
|
||||
%style
|
||||
:plain
|
||||
@ -19,14 +19,11 @@
|
||||
%span.icon-bar
|
||||
%span.icon-bar
|
||||
%span.icon-bar
|
||||
%a.brand{:href => "#"} Project name
|
||||
%a.brand{:href => "index.html"}= "GitStats - #{repo.project_name}"
|
||||
%div.nav-collapse.collapse
|
||||
%ul.nav
|
||||
%li.active
|
||||
%a{:href => "#"} Home
|
||||
%li
|
||||
%a{:href => "#"} Home2
|
||||
%li
|
||||
%a{:href => "#"} Hom3
|
||||
- all_templates.each do |link|
|
||||
%li{:class => active_page == link ? "active" : ""}
|
||||
%a{:href => "#{link}.html"}= link.capitalize
|
||||
%div.container
|
||||
= yield
|
||||
|
Loading…
Reference in New Issue
Block a user