<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>dynamic_reports-0.0.0.gem</filename>
    </added>
    <added>
      <filename>examples/rails/all_visitors_report.rb</filename>
    </added>
    <added>
      <filename>examples/rails/sales_report.rb.rb</filename>
    </added>
    <added>
      <filename>examples/rails/sample_controller.rb.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -2,7 +2,7 @@ require &quot;rake/testtask&quot;
 
 task :default =&gt; [&quot;test:all&quot;]
 task :test    =&gt; [&quot;test:all&quot;]
-namespace :test do 
+namespace :test do
   desc &quot;Run Test Suite&quot;
   Rake::TestTask.new(&quot;all&quot;) do |test|
     test.pattern = &quot;test/dynamic_reports.rb&quot;
@@ -13,32 +13,32 @@ end
 
 desc &quot;Build the dynamic_reports gem and then install it.&quot;
 task :gem do
-    puts `gem uninstall dynamic_reports ; rm -f dynamic_reports-0.0.0.gem; gem build gemspec.rb ; gem install ./dynamic_reports-0.0.0.gem --no-ri -l`
+  puts `gem uninstall dynamic_reports ; rm -f dynamic_reports-0.0.0.gem; gem build gemspec.rb ; gem install ./dynamic_reports-0.0.0.gem --no-ri -l`
 end
-namespace :gem do 
+namespace :gem do
   desc &quot;Build the dynamic_reports gem.&quot;
-  task :build do 
+  task :build do
     puts `gem build gemspec.rb`
   end
 
   desc &quot;Install the dynamic_reports gem.&quot;
-  task :install do 
+  task :install do
     %x{gem install dynamic_reports*.gem --no-rdoc --no-ri -l}
   end
 end
 
 begin
-require &quot;rake/rdoctask&quot;
-require &quot;rdoc/generator&quot;
-Rake::RDocTask.new do |rdoc|
-  rdoc.rdoc_dir = &quot;doc&quot;
-  rdoc.title    = &quot;Dynamic Reports&quot;
-  rdoc.options &lt;&lt; &quot;--line-numbers&quot;
-  rdoc.options &lt;&lt; &quot;--charset&quot; &lt;&lt; &quot;utf-8&quot;
-  rdoc.rdoc_files.include(&quot;README.rdoc&quot;, &quot;HISTORY&quot;)
-  rdoc.rdoc_files.include(&quot;lib/*.rb&quot;)
-  rdoc.rdoc_files.include(&quot;lib/dynamic_reports/*.rb&quot;)
-end
+  require &quot;rake/rdoctask&quot;
+  require &quot;rdoc/generator&quot;
+  Rake::RDocTask.new do |rdoc|
+    rdoc.rdoc_dir = &quot;doc&quot;
+    rdoc.title    = &quot;Dynamic Reports&quot;
+    rdoc.options &lt;&lt; &quot;--line-numbers&quot;
+    rdoc.options &lt;&lt; &quot;--charset&quot; &lt;&lt; &quot;utf-8&quot;
+    rdoc.rdoc_files.include(&quot;README.rdoc&quot;, &quot;HISTORY&quot;)
+    rdoc.rdoc_files.include(&quot;lib/*.rb&quot;)
+    rdoc.rdoc_files.include(&quot;lib/dynamic_reports/*.rb&quot;)
+  end
 
 rescue
   puts &quot;Skipping loading of rdoc tasks, missing rdoc gem.&quot;</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -8,7 +8,7 @@ module DynamicReports
   class Report
     @@default_engine = &quot;erb&quot;
 
-    attr_accessor :name, :title, :sub_title, :columns, :charts, :records, :template, :class_name, :styles
+    attr_accessor :name, :title, :sub_title, :columns, :charts, :records, :template, :class_name, :styles, :links
 
     # views accessor, array of view paths.
     def views
@@ -160,6 +160,29 @@ module DynamicReports
         chart_options = chart_options.shift || {}
         charts(Chart.configure(name, chart_options, &amp;block))
       end
+      
+      # Return an array of links defined for the report.
+      def links(object=nil)
+        options[:links] ||= []
+        options[:links] &lt;&lt; object if object
+        options[:links]
+      end
+      
+      # Define a link for the report
+      #
+      # Pass parameters within {}.  Parameters are replaced with the row values 
+      # from passed records.  You do NOT need to include a parameter value as a 
+      # report column for it to be used in a link. For example, you might 
+      # want to generate a link with an ID field in it but not display that id 
+      # in the actual report.  Just include {id} to do this.
+      #
+      # Example:
+      #
+      # link :visits, '/reports/{visit}/details?date={recorded_at}'
+      #
+      def link(column, url, link_options=nil)
+        links({:column =&gt; column, :url =&gt; url, :link_options =&gt; link_options})
+      end
 
       # Method for instanciating a report instance on a set of given records.
       #</diff>
      <filename>lib/dynamic_reports/reports.rb</filename>
    </modified>
    <modified>
      <diff>@@ -32,7 +32,7 @@ module DynamicReports
 
     # TODO: Add Report Helpers for injection
     def titleize(object)
-      object.to_s.split('_').each{ |word| word.capitalize! }.join(' ') 
+      object.to_s.split('_').each{ |word| word.capitalize! }.join(' ')
     end
 
     def commify(object)
@@ -43,9 +43,49 @@ module DynamicReports
       end
     end
 
+    def linkcheck(record, column_object)
+      val = ''
+
+      if column_object.is_a?(Hash)
+        column = column_object[:column]
+      else
+        column = column_object
+      end
+
+      report.links.each do |link|
+        if link[:column] == column
+          url = link[:url]
+          url.scan(/\{(\w+)\}/).each do |parameter|
+            parameter = parameter.to_s
+            url = url.gsub(&quot;{#{parameter}}&quot;, CGI::escape(get_record_value(record, parameter.to_sym).to_s))
+          end
+
+          url_attribute_str = []
+          link[:link_options].keys.each do |key|
+            url_attribute_str &lt;&lt; &quot;#{key}='#{link[:link_options][key]}'&quot;
+          end if link[:link_options]
+          
+          val = &quot;&lt;a href='#{url}' #{url_attribute_str.join(' ')}&gt;#{get_record_value(record,column)}&lt;/a&gt;&quot;
+          break
+        end if link[:column]
+      end if report.links
+
+      val.blank? ? get_record_value(record,column) : val
+    end
+
+    def get_record_value(record, column)
+      if record.is_a?(Hash)
+        record[column]
+      elsif record.respond_to?(column.to_sym)
+        record.send(column.to_sym)
+      else
+        column
+      end
+    end
+
     def chart_url(chart,report)
       columns = chart.columns ? chart.columns : report.columns
-      chart_type = chart.type.nil? ?  :line : chart.type.to_sym 
+      chart_type = chart.type.nil? ?  :line : chart.type.to_sym
       case chart_type
       when :line
         Charts.line_chart(chart,columns,report)
@@ -62,7 +102,7 @@ module DynamicReports
     end
 
     private
-    
+
     def render(engine, template, options={}, locals={})
       # merge app-level options
       options = self.class.send(engine).merge(options) if self.class.respond_to?(engine)
@@ -74,7 +114,7 @@ module DynamicReports
       content_type = options.delete(:content_type)
       locals = options.delete(:locals) || locals || {}
       locals.merge!(:report =&gt; @report, :options =&gt; options || {})
-      
+
       # render template
       data, options[:filename], options[:line] = lookup_template(engine, template, views, content_type)
       output = __send__(&quot;render_#{engine}&quot;, template, data, options, locals)
@@ -101,7 +141,7 @@ module DynamicReports
           lookup_template(engine, cached[:template], views, content_type, cached[:filename], cached[:line])
         else
           filename = &quot;#{template}.#{content_type}.#{engine}&quot;
-          dir = views.to_a.detect do |view| 
+          dir = views.to_a.detect do |view|
             ::File.exists?(::File.join(view, filename))
           end
           if dir
@@ -172,7 +212,7 @@ module DynamicReports
       require engine.downcase
     end
 
- 
-    
+
+
   end
 end</diff>
      <filename>lib/dynamic_reports/templates.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,11 +12,11 @@
     }
     \.dynamic_report table tr th {
     color: white;
-    background: gray;
+    background: #666666;
     padding:5px;
     }
     \.dynamic_report table tr td {
-    border: 1px solid black;
+    border: 1px solid #333333;
     padding:3px 15px;
     }
     \.dynamic_report .report_charts {
@@ -25,6 +25,21 @@
     \.dynamic_report .report_chart {
     margin:15px;
     }
+    \.dynamic_report .subreport_row td {
+    padding: 10px 10px 10px 20px;
+    background-color: #FFFFCC;
+    font-size: 90%;
+    }
+    \.dynamic_report .subreport table tr td {
+    border: 1px dotted #CCCC99;
+    padding:3px 5px;
+    background-color: white;
+    }    
+    \.dynamic_report .subreport table tr th {
+    color: black;
+    background: #CCCCCC;
+    padding:3px;
+    }
 
 .dynamic_report{ :id =&gt; report.class_name }
   - if report.title
@@ -40,18 +55,22 @@
       %tr.report_header_row
         - report.columns.each do |column|
           %th
-            = options[:titleize] ? titleize(column) : column
+            - if column.is_a?(Hash) 
+              - if column.keys.include?(:heading)            
+                = options[:titleize] ? titleize(column[:heading]) : column[:heading]
+              -else
+                = options[:titleize] ? titleize(column[:column]) : column[:column]                
+            -else
+              = options[:titleize] ? titleize(column) : column
     %tbody.report_body
       - report.records.each do |record|
         %tr.report_row
           - report.columns.each do |column|
             %td
-              - if record.is_a?(Hash)
-                = (options[:commas] == true) ? commify(record[column]) : record[column]
-              - elsif record.respond_to?(column.to_sym)
-                = (options[:commas] == true) ? commify(record.send(column.to_sym)) : record.send(column.to_sym)
-              - else
-                = column
+              = (options[:commas] == true) ? commify(linkcheck(record,column)) : linkcheck(record,column)
+        %tr.subreport_row{:style =&gt; &quot;display:none&quot;}
+          %td{:colspan =&gt; report.columns.size}
+            .subreport
 
   - if report.charts &amp;&amp; report.charts.class === Hash
     - report.charts.each_pair do |name, chart|</diff>
      <filename>lib/dynamic_reports/views/default_report.html.haml</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>612c44a46306dcc18485d802e406e1ec738db036</id>
    </parent>
  </parents>
  <author>
    <name>Joshua Lippiner</name>
    <email>jlippiner@joshua-lippiners-macbook-pro.local</email>
  </author>
  <url>http://github.com/wayneeseguin/dynamic_reports/commit/72dd50f0f2e43ecf70021eeeffd527c24cdda5f8</url>
  <id>72dd50f0f2e43ecf70021eeeffd527c24cdda5f8</id>
  <committed-date>2009-07-15T11:54:18-07:00</committed-date>
  <authored-date>2009-07-15T11:54:18-07:00</authored-date>
  <message>Added support for headings, linked reports and sub reports</message>
  <tree>83854f4eea4f91a8c23081c802832aa311e2413d</tree>
  <committer>
    <name>Joshua Lippiner</name>
    <email>jlippiner@joshua-lippiners-macbook-pro.local</email>
  </committer>
</commit>
