diff options
-rw-r--r-- | lib/postrunner/Activity.rb | 2 | ||||
-rw-r--r-- | lib/postrunner/ActivityView.rb | 13 | ||||
-rw-r--r-- | lib/postrunner/FlexiTable.rb | 21 |
3 files changed, 29 insertions, 7 deletions
diff --git a/lib/postrunner/Activity.rb b/lib/postrunner/Activity.rb index 3fe0bfd..56dabbf 100644 --- a/lib/postrunner/Activity.rb +++ b/lib/postrunner/Activity.rb @@ -83,7 +83,7 @@ module PostRunner def show @fit_activity = load_fit_file unless @fit_activity - ActivityView.new(self) unless File.exists?(@html_file) + ActivityView.new(self) #unless File.exists?(@html_file) cmd = "#{ENV['BROWSER'] || 'firefox'} \"#{@html_file}\" &" unless system(cmd) diff --git a/lib/postrunner/ActivityView.rb b/lib/postrunner/ActivityView.rb index 43e8461..17c0c70 100644 --- a/lib/postrunner/ActivityView.rb +++ b/lib/postrunner/ActivityView.rb @@ -115,6 +115,19 @@ module PostRunner float: right; width: 600px; } +.flexitable { + width: 100%; + background-color: #CCCCCC +} +.ft_head_row { + background-color: #DEDEDE +} +.ft_even_row { + background-color: #FCFCFC +} +.ft_odd_row { + background-color: #F1F1F1 +} EOT ) end diff --git a/lib/postrunner/FlexiTable.rb b/lib/postrunner/FlexiTable.rb index 47b5583..0b8ab38 100644 --- a/lib/postrunner/FlexiTable.rb +++ b/lib/postrunner/FlexiTable.rb @@ -82,8 +82,10 @@ module PostRunner end def to_html(doc) + text_align = get_attribute(:halign) doc.td(@content.respond_to?('to_html') ? - @content.to_html(doc) : @content.to_s) + @content.to_html(doc) : @content.to_s, + text_align ? { :style => "text-align: #{text_align.to_s}" } : {}) end private @@ -91,7 +93,8 @@ module PostRunner def get_attribute(name) @attributes[name] || @row.attributes[name] || - @table.column_attributes[@column_index][name] + (@table.column_attributes[@column_index] ? + @table.column_attributes[@column_index][name] : nil) end end @@ -100,8 +103,9 @@ module PostRunner attr_reader :attributes - def initialize(table) + def initialize(table, section) @table = table + @section = section @attributes = Attributes.new super() end @@ -113,6 +117,7 @@ module PostRunner end def set_indicies(col_idx, row_idx) + @index = row_idx self[col_idx].set_indicies(col_idx, row_idx) end @@ -132,7 +137,9 @@ module PostRunner end def to_html(doc) - doc.tr { + css_class = @section == :head ? 'ft_head_row' : + @index % 2 == 0 ? 'ft_even_row' : 'ft_odd_row' + doc.tr({ :class => css_class }) { each { |c| c.to_html(doc) } } end @@ -184,7 +191,7 @@ module PostRunner @foot_rows else raise "Unknown section #{@current_section}" - end << (@current_row = Row.new(self)) + end << (@current_row = Row.new(self, @current_section)) end @current_row.cell(content, attributes) end @@ -229,7 +236,9 @@ module PostRunner end def to_html(doc) - doc.table { + index_table + + doc.table({ :class => 'flexitable' }) { @head_rows.each { |r| r.to_html(doc) } @body_rows.each { |r| r.to_html(doc) } @foot_rows.each { |r| r.to_html(doc) } |