<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>features/spam.feature</filename>
    </added>
    <added>
      <filename>features/steps/spam.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -10,6 +10,7 @@ class Comment
   property :text,       Text,    :nullable =&gt; false
   property :html_text,  Text
   property :created_at, DateTime
+  property :spam,       Boolean, :default =&gt; false
 
   # ==== Associations
   belongs_to :entry</diff>
      <filename>app/models/comment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -59,6 +59,25 @@ class Entry
     Entry.all(:order =&gt; [:created_at.desc], :limit =&gt; 10)
   end
 
+  # Returns a list of comments, which are per default not spam
+  #
+  # ==== Parameters
+  # display_spam&lt;Boolean&gt;:: 
+  #   Flag which indicates whether spammy comments should be displayed or not
+  #
+  # ==== Returns
+  # Array[Comment]::
+  #   A list of comments is returned, which are not spam per default
+  # ---
+  # @public
+  def public_comments(display_spam=false)
+    if display_spam
+      self.comments
+    else
+      self.comments.all(:spam =&gt; false)
+    end
+  end
+
   private
   # Groups the sorted_array by the given block
   #</diff>
      <filename>app/models/entry.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,11 @@
   &lt;h4&gt;&lt;%= comment_title(comment) %&gt;&lt;/h4&gt;
   &lt;%= comment.html_text %&gt;
   &lt;% admin do %&gt;
+    &lt;%= form_for(comment, :action =&gt; url(:entry_comment, comment.entry_id, comment.id), :class =&gt; &quot;comment_form&quot;) do %&gt;
+      &lt;%= check_box :spam, :label =&gt; &quot;Spam&quot; %&gt;
+      &lt;br style=&quot;clear: both;&quot;/&gt;
+      &lt;%= submit 'Update' %&gt;
+    &lt;% end =%&gt;
     &lt;a 
       id=&quot;commment_&lt;%= comment.id %&gt;_edit&quot; 
       href=&quot;&lt;%= url(:edit_entry_comment, comment.entry_id, comment.id) %&gt;&quot;</diff>
      <filename>app/views/entries/_comment.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-&lt;i&gt;&lt;%= entry.created_at.strftime(&quot;%m.%d.%Y %H:%M&quot;) %&gt; | Comments (&lt;%= entry.comments.size %&gt;)&lt;/i&gt;
+&lt;i&gt;&lt;%= entry.created_at.strftime(&quot;%m.%d.%Y %H:%M&quot;) %&gt; | Comments (&lt;%= entry.public_comments(logged_in?).size %&gt;)&lt;/i&gt;
 &lt;h2&gt;&lt;a href=&quot;&lt;%= url(:permalink_entry, entry.id, entry.permalink) %&gt;&quot; id=&quot;entry_&lt;%= entry.id %&gt;&quot;&gt;&lt;%= entry.title %&gt;&lt;/a&gt;&lt;/h2&gt;
 &lt;div class=&quot;entry&quot;&gt;
   &lt;%= entry.html_text %&gt;</diff>
      <filename>app/views/entries/_entry.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 &lt;%= partial 'entry', :with =&gt; @entry %&gt;
 &lt;div id=&quot;comments&quot;&gt;
-  &lt;%= partial 'comment', :with =&gt; @entry.comments %&gt;
+  &lt;%= partial 'comment', :with =&gt; @entry.public_comments(logged_in?) %&gt;
   &lt;br /&gt;
   &lt;br /&gt;
   &lt;%= error_messages_for :comment %&gt;</diff>
      <filename>app/views/entries/show.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -134,6 +134,8 @@ function insert_preview(elem) {
 }
 
 function ajaxify_create(elem) {
+  var f = $$('#comments form').first();
+  if (f.getAttribute('class') == 'comment_form') return;
   insert_preview(elem);
   Event.observe(elem, 'click', function(e) {
     var form = $$('#comments form')[0];
@@ -154,6 +156,27 @@ function ajaxify_create(elem) {
   })
 }
 
+function ajaxify_check_box(form) {
+  $(form).select('input[type=&quot;submit&quot;]').each(function(e) {
+    e.hide();
+  });
+
+  var link = form.getAttribute('action');
+  $(form).select('input[type=&quot;checkbox&quot;]').each(function(e) {
+    Event.observe(e, 'click', function(ev) {
+      var content = Form.serialize(form);
+      new Ajax.Request(form.getAttribute('action') + '.js', {
+        method: 'put', 
+        parameters: content, 
+        evalJS: false,
+        onSuccess: function(result) {
+          new Effect.Highlight(form);
+        }
+      });
+    });
+  });
+}
+
 Event.observe(window, 'load', function() {
   $$('.delete').each(function(elem) {
     Event.observe(elem, 'click', function(e) {
@@ -175,5 +198,6 @@ Event.observe(window, 'load', function() {
 
   $$('#comments input[type=&quot;submit&quot;]').each(ajaxify_create);
   $$('#comments a').each(ajaxify_edit);
+  $$('.comment_form').each(ajaxify_check_box);
 });
 </diff>
      <filename>public/javascripts/application.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>61a4cb84c916738561ce66061c2c7d33e4dfa9a0</id>
    </parent>
  </parents>
  <author>
    <name>Michael Opitz</name>
    <email>opitz.michael@gmail.com</email>
  </author>
  <url>http://github.com/mop/mini-blog/commit/4f0ba8ae89ae4ebb94ee5c878328509e31a7f11f</url>
  <id>4f0ba8ae89ae4ebb94ee5c878328509e31a7f11f</id>
  <committed-date>2009-02-13T12:34:07-08:00</committed-date>
  <authored-date>2009-02-13T12:34:07-08:00</authored-date>
  <message>Implemented GUI for marking elements as spam</message>
  <tree>d36f155d02a44570508852b3ed1f6afb69beaa07</tree>
  <committer>
    <name>Michael Opitz</name>
    <email>opitz.michael@gmail.com</email>
  </committer>
</commit>
