<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,3 +2,5 @@ config/database.yml
 tmp/*
 log/*
 public/cache
+public/index.html
+public/page</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 class Entries &lt; Application
   provides :xml, :js, :yaml, :text
   before :authenticate, :only =&gt; [:edit, :update, :destroy]
-  # cache_action :index
+
   cache :index
 
   def index
@@ -17,15 +17,22 @@ class Entries &lt; Application
       conditions = 'status != &quot;hidden&quot;'
       #@entries = Entry.find(:all, :order =&gt; 'created_at DESC', :limit =&gt; @limit, :offset =&gt; @offset, :conditions =&gt; 'status != &quot;hidden&quot;')
       # conditions = &quot;status = 'confirmed' OR status = 'pending'&quot;      
-      @entries = Entry.find(:all, :order =&gt; 'created_at ASC', :limit =&gt; @limit, :offset =&gt; @offset, :conditions =&gt; conditions, :include =&gt; [:flags])
+      @entries = Entry.find(:all, :order =&gt; 'created_at ASC', :limit =&gt; @limit, :offset =&gt; @offset, :conditions =&gt; conditions)
     end
+    
     #Flag.find(:all, :conditions =&gt; &quot;entry_id in (#{@entries.map_by_id.join(',')})&quot;)
     display @entries
   end
   
-  def xml # FIXME should be raw XML, use .rss
+  def blacklist
+    @entries = Entry.find_all_by_status('confirmed')
+    render :template =&gt; 'entries/index.text'
+  end
+  
+  def rss # FIXME should be raw XML, use .rss
     @entries = Entry.find(:all, :order =&gt; 'updated_at DESC', :limit =&gt; 12)
-    display @xml
+    # display @xml
+    render :template =&gt; 'entries/index.xml'
   end
     
   
@@ -197,7 +204,10 @@ class Entries &lt; Application
   # TODO: should actually be in a FlagsController yo
   def flags_for_ip
     only_provides :js
+
+    params[:ip] ||= request.remote_ip
     flags = Flag.find_all_by_ip(params[:ip]).map(&amp;:entry_id)
+    
     render &quot;var flags = [#{flags.join(',')}];&quot;, :layout =&gt; false
   end
   </diff>
      <filename>app/controllers/entries.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,8 +6,13 @@ class Entry &lt; ActiveRecord::Base
   validates_uniqueness_of :url, :on =&gt; :create, :message =&gt; &quot;must be unique&quot;
   
   # interesting bits
-  def confirmations; flags.select { |u| u.name == 'confirm:true' }; end
-  def disputes; flags.select { |u| u.name == 'confirm:false' }; end
+  def confirmations
+    Flag.count(:conditions =&gt; &quot;entry_id = #{self.id} AND name = 'confirm:true'&quot;)
+  end
+  
+  def disputes
+    Flag.count(:conditions =&gt; &quot;entry_id = #{self.id} AND name = 'confirm:false'&quot;)
+  end
   
   # % of votes needed before it is confirmed (rounded down)
   def confirmation_threshold
@@ -17,8 +22,9 @@ class Entry &lt; ActiveRecord::Base
     12
   end
   def confirmed?
-    if flags.length &gt;= minimum_vote_count and status != 'hidden'
-      return confirmations.length &gt; (flags.length * confirmation_threshold).floor
+    flag_count = flags.count
+    if flag_count &gt;= minimum_vote_count and status != 'hidden'
+      return confirmations &gt; (flag_count * confirmation_threshold).floor
     else
       return false
     end
@@ -37,9 +43,9 @@ class Entry &lt; ActiveRecord::Base
 
   # how disputed is this entry?
   def controversy
-    if disputes.length != confirmations.length
-      ratio = disputes.length.to_f/flags.length.to_f
-      ratio = 1.0 if ratio.to_f.nan? or confirmations.length == 0 # exceptions, not proper
+    if disputes != confirmations
+      ratio = disputes.to_f/flags.count.to_f
+      ratio = 1.0 if ratio.to_f.nan? or confirmations == 0 # exceptions, not proper
     else
       ratio = 0.5
     end</diff>
      <filename>app/models/entry.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,23 @@
 class Flag &lt; ActiveRecord::Base
   belongs_to :entry
   belongs_to :user
+
+  def confirmation?
+    self.name == 'confirm:true'
+  end
+  
+  def dispute?
+    self.name == 'confirm:false'
+  end
+  
+  # after_create :update_entry_counters
+  # def update_entry_counters
+  #   if self.confirmation?
+  #     entry.confirm_count += 1
+  #   else
+  #     entry.dispute_count += 1
+  #   end
+  #   entry.save!
+  # end
+  
 end
\ No newline at end of file</diff>
      <filename>app/models/flag.rb</filename>
    </modified>
    <modified>
      <diff>@@ -44,7 +44,7 @@
 			    &lt;% else %&gt;
 			      &lt;strong&gt;confirmations:&lt;/strong&gt;
 			    &lt;% end %&gt;
-			    &lt;strong class=&quot;count&quot;&gt;&lt;%= entry.confirmations.length %&gt;&lt;/strong&gt;
+			    &lt;strong class=&quot;count&quot;&gt;&lt;%= entry.confirmations %&gt;&lt;/strong&gt;
 		    &lt;/span&gt;
 				&lt;span class=&quot;dispute&quot;&gt;&lt;code&gt;-&lt;/code&gt; 
 				  &lt;% if new_voter %&gt;
@@ -52,7 +52,7 @@
   				&lt;% else %&gt;
   				  &lt;strong&gt;disputes:&lt;/strong&gt;
   				&lt;% end %&gt;
-				  &lt;strong class=&quot;count&quot;&gt;&lt;%= entry.disputes.length %&gt;&lt;/strong&gt;
+				  &lt;strong class=&quot;count&quot;&gt;&lt;%= entry.disputes %&gt;&lt;/strong&gt;
 				&lt;/span&gt;			
 				&lt;br class=&quot;clear&quot; /&gt;
 			&lt;/div&gt; &lt;!-- /.flags --&gt;
@@ -66,7 +66,7 @@
 
 
 			&lt;div class=&quot;stats&quot;&gt;
-				&lt;% confirms = entry.confirmations.length; disputes = entry.disputes.length %&gt;
+				&lt;% confirms = entry.confirmations; disputes = entry.disputes %&gt;
 				&lt;% width = 300; height = 10 #FIXME %&gt;
 				&lt;div style=&quot;float: right; display: inline; width: &lt;%= width - 1%&gt;px; height: 3px; background-color: #aaa;&quot;&gt;&amp;nbsp;&lt;/div&gt;
 				&lt;div style=&quot;background-color: #fbb; float: right; clear: right; display: inline; width: &lt;%= (entry.controversy * width).to_i %&gt;px; height: &lt;%= height %&gt;px;&quot;&gt;&amp;nbsp;&lt;%#= (&quot;%.2f&quot; % entry.controversy) %&gt;&lt;/div&gt;</diff>
      <filename>app/views/entries/index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -14,7 +14,7 @@ content = RSS::Maker.make(&quot;2.0&quot;) { |m|
     i.link = entry_url(entry)
     last_flag = entry.flags.last
     i.description = 
-		&quot;#{entry.confirmations.length} confirmations, #{entry.disputes.length} disputes &lt;br /&gt;
+		&quot;#{entry.confirmations} confirmations, #{entry.disputes} disputes &lt;br /&gt;
     blacklisted? #{entry.confirmed? ? 'yep' : 'nope'}
 		&lt;p&gt;#{link_to '&amp;raquo; Comments &lt;br /&gt; &lt;img src=&quot;'+entry.thumbnail+'&quot; alt=&quot;&quot; title=&quot;&quot; /&gt;', entry_url(entry)}&lt;/p&gt;&quot;
     # i.date = last_flag.timestamp rescue Time.now</diff>
      <filename>app/views/entries/index.xml.erb</filename>
    </modified>
    <modified>
      <diff>@@ -23,7 +23,8 @@
   &lt;script src=&quot;/javascripts/jquery.dimensions.js&quot; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;
   &lt;!--&lt;script src=&quot;/javascripts/jquery.pagination.js&quot; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;--&gt;
   &lt;script src=&quot;/javascripts/rickblock.js&quot; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;
-	&lt;script src=&quot;/flags.js&quot; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;
+
+	&lt;!-- &lt;script src=&quot;/flags.js&quot; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt; --&gt;
 &lt;/head&gt;
 
 &lt;body&gt;</diff>
      <filename>app/views/layout/application.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -7,9 +7,18 @@ Merb::Config.use { |c|
   c[:log_auto_flush ] = true  
 }
 
+# dev
 Merb::BootLoader.after_app_loads do
   Merb::Cache.setup do
     register(:default, Merb::Cache::AdhocStore.new)
   end
 end
 
+# prod
+# Merb::BootLoader.after_app_loads do
+#   Merb::Cache.setup do
+#     register(:page_store, Merb::Cache::PageStore[Merb::Cache::FileStore], :dir =&gt; Merb.root / &quot;public&quot;)
+#     register(:action_store, Merb::Cache::ActionStore[Merb::Cache::FileStore], :dir =&gt; Merb.root / &quot;tmp&quot;)
+#     register(:default, Merb::Cache::AdhocStore[:page_store, :action_store])
+#   end
+# end
\ No newline at end of file</diff>
      <filename>config/environments/development.rb</filename>
    </modified>
    <modified>
      <diff>@@ -32,10 +32,12 @@ Merb::Router.prepare do |r|
   end
   r.match('/page/:page').to(:controller =&gt; 'entries', :action =&gt;'index')
   
-  # specific routes  
-  r.match('/ricklist.txt').to(:controller =&gt; 'entries', :action =&gt; 'index', :format =&gt; 'text')
-  r.match('/rickblock.txt').to(:controller =&gt; 'entries', :action =&gt; 'index', :format =&gt; 'text', :rickblock =&gt; 'true')
-  r.match(/\/(rss|atom|feed)/).to(:controller =&gt; 'entries', :action =&gt; 'index', :format =&gt; 'xml')
+  # specific routes
+  # FIXME: merb-cache interfering with .xml/.txt... AGH
+  # r.match(/\/(rss|atom|feed)(\.xml)?/).to(:controller =&gt; 'entries', :action =&gt; 'rss', :format =&gt; 'xml')  
+  r.match('/feed.xml').to(:controller =&gt; 'entries', :action =&gt; 'rss', :format =&gt; 'xml')    
+  r.match('/blacklist.txt').to(:controller =&gt; 'entries', :action =&gt; 'blacklist', :format =&gt; 'text')
+
   
   # JSON version of all of a user's flags
   r.match('/flags.js').to(:controller =&gt; 'entries', :action =&gt; 'flags_for_ip', :format =&gt; 'js')</diff>
      <filename>config/router.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1c151a1d3961ee77e8a802935638ff3ff8f11a13</id>
    </parent>
  </parents>
  <author>
    <name>Jamie Wilkinson</name>
    <email>jamie@tramchase.com</email>
  </author>
  <url>http://github.com/jamiew/rickrolldb/commit/2404bdeb3f7ff8437b0a63d241efb470c26d6673</url>
  <id>2404bdeb3f7ff8437b0a63d241efb470c26d6673</id>
  <committed-date>2009-05-15T08:00:53-07:00</committed-date>
  <authored-date>2009-05-15T08:00:53-07:00</authored-date>
  <message>caching hacks -- merb-cache doesn't respect formats. quickly broke RSS &amp; .txt rendering into different controller methods. also refactor Flag counting into actual counting -- was getting whole objects before. doing it in n+1 queries but +caching should help speed substantially.</message>
  <tree>9e8c4f0a68a190ad5e91d0b20c9eb855b2b3f5ef</tree>
  <committer>
    <name>Jamie Wilkinson</name>
    <email>jamie@tramchase.com</email>
  </committer>
</commit>
