Class: Ditz::HtmlView
- Defined in:
- lib/views.rb,
lib/plugins/git.rb,
lib/plugins/issue-claiming.rb
Constant Summary collapse
- SUPPORT_FILES =
%w(style.css blue-check.png red-check.png green-check.png green-bar.png yellow-bar.png)
Instance Method Summary collapse
-
#initialize(project, config, dir) ⇒ HtmlView
constructor
A new instance of HtmlView.
- #render_all ⇒ Object
Methods inherited from View
add_to_view, view_additions_for
Constructor Details
#initialize(project, config, dir) ⇒ HtmlView
Returns a new instance of HtmlView.
60 61 62 63 64 65 |
# File 'lib/views.rb', line 60 def initialize project, config, dir @project = project @config = config @dir = dir @template_dir = File.dirname Ditz::find_ditz_file("index.rhtml") end |
Instance Method Details
#render_all ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/views.rb', line 67 def render_all Dir.mkdir @dir unless File.exists? @dir SUPPORT_FILES.each { |f| FileUtils.cp File.join(@template_dir, f), @dir } ## build up links links = {} @project.releases.each { |r| links[r] = "release-#{r.name}.html" } @project.issues.each { |i| links[i] = "issue-#{i.id}.html" } @project.components.each { |c| links[c] = "component-#{c.name}.html" } links["unassigned"] = "unassigned.html" # special case: unassigned links["index"] = "index.html" # special case: index @project.issues.each do |issue| fn = File.join @dir, links[issue] #puts "Generating #{fn}..." extra_summary = self.class.view_additions_for(:issue_summary).map { |b| b[issue, @config] }.compact extra_details = self.class.view_additions_for(:issue_details).map { |b| b[issue, @config] }.compact erb = ErbHtml.new(@template_dir, links, :issue => issue, :release => (issue.release ? @project.release_for(issue.release) : nil), :component => @project.component_for(issue.component), :project => @project) extra_summary_html = extra_summary.map { |string, extra_binding| erb.render_string string, extra_binding }.join extra_details_html = extra_details.map { |string, extra_binding| erb.render_string string, extra_binding }.join File.open(fn, "w") { |f| f.puts erb.render_template("issue", { :extra_summary_html => extra_summary_html, :extra_details_html => extra_details_html }) } end @project.releases.each do |r| fn = File.join @dir, links[r] #puts "Generating #{fn}..." File.open(fn, "w") do |f| f.puts ErbHtml.new(@template_dir, links, :release => r, :issues => @project.issues_for_release(r), :project => @project). render_template("release") end end @project.components.each do |c| fn = File.join @dir, links[c] #puts "Generating #{fn}..." File.open(fn, "w") do |f| f.puts ErbHtml.new(@template_dir, links, :component => c, :issues => @project.issues_for_component(c), :project => @project). render_template("component") end end fn = File.join @dir, links["unassigned"] #puts "Generating #{fn}..." File.open(fn, "w") do |f| f.puts ErbHtml.new(@template_dir, links, :issues => @project.unassigned_issues, :project => @project). render_template("unassigned") end past_rels, upcoming_rels = @project.releases.partition { |r| r.released? } fn = File.join @dir, links["index"] #puts "Generating #{fn}..." File.open(fn, "w") do |f| f.puts ErbHtml.new(@template_dir, links, :project => @project, :past_releases => past_rels, :upcoming_releases => upcoming_rels, :components => @project.components). render_template("index") end puts "Local generated URL: file://#{File.(fn)}" end |