[69040] branches/gsoc10-mpwa

jrozner at macports.org jrozner at macports.org
Mon Jun 21 14:56:09 PDT 2010


Revision: 69040
          http://trac.macports.org/changeset/69040
Author:   jrozner at macports.org
Date:     2010-06-21 14:56:08 -0700 (Mon, 21 Jun 2010)
Log Message:
-----------
Added recaptcha support for posting comments

Modified Paths:
--------------
    branches/gsoc10-mpwa/app/controllers/application_controller.rb
    branches/gsoc10-mpwa/app/controllers/comments_controller.rb
    branches/gsoc10-mpwa/app/views/ports/show.html.erb
    branches/gsoc10-mpwa/config/environment.rb

Modified: branches/gsoc10-mpwa/app/controllers/application_controller.rb
===================================================================
--- branches/gsoc10-mpwa/app/controllers/application_controller.rb	2010-06-21 21:53:08 UTC (rev 69039)
+++ branches/gsoc10-mpwa/app/controllers/application_controller.rb	2010-06-21 21:56:08 UTC (rev 69040)
@@ -1,5 +1,6 @@
 # Filters added to this controller apply to all controllers in the application.
 # Likewise, all the methods added will be available for all controllers.
+require 'recaptcha'
 
 class ApplicationController < ActionController::Base
   helper :all # include all helpers, all the time
@@ -12,7 +13,7 @@
   $svn_url = 'http://svn.macports.org/repository/macports/'
   $downloads_url = 'http://distfiles.macports.org/MacPorts/'
   $guide_url = 'http://guide.macports.org'
-  $latest_version = '1.8.2'
+  $latest_version = '1.9.1'
   $snowleopard_dmg = "#{$downloads_url}Macports-#{$latest_version}-10.6-SnowLeopard.dmg"
   $leopard_dmg = "#{$downloads_url}Macports-#{$latest_version}-10.5-Leopard.dmg"
   $tiger_dmg = "#{$downloads_url}Macports-#{$latest_version}-10.4-Tiger.dmg"

Modified: branches/gsoc10-mpwa/app/controllers/comments_controller.rb
===================================================================
--- branches/gsoc10-mpwa/app/controllers/comments_controller.rb	2010-06-21 21:53:08 UTC (rev 69039)
+++ branches/gsoc10-mpwa/app/controllers/comments_controller.rb	2010-06-21 21:56:08 UTC (rev 69040)
@@ -7,10 +7,13 @@
     @comment = Port.find(params[:port_id]).comments.build(params[:comment])
 
     respond_to do |format|
-      if @comment.save
-        format.html { redirect_to(@comment.port, :notice => 'Comment was successfully created.') }
+      if verify_recaptcha
+        if @comment.save
+          format.html { redirect_to @comment.port }
+        end
       else
-        format.html { render :action => "new" }
+        flash[:error] = "There was an error with the recaptcha code below. Please re-enter the code and click submit." 
+        format.html { redirect_to @comment.port }
       end
     end
   end

Modified: branches/gsoc10-mpwa/app/views/ports/show.html.erb
===================================================================
--- branches/gsoc10-mpwa/app/views/ports/show.html.erb	2010-06-21 21:53:08 UTC (rev 69039)
+++ branches/gsoc10-mpwa/app/views/ports/show.html.erb	2010-06-21 21:56:08 UTC (rev 69040)
@@ -12,10 +12,6 @@
   </p>
 
   <p>
-    <strong>Categories:</strong> <%=h @port.categories %>
-  </p>
-
-  <p>
     <strong>Variants:</strong> <%=h @port.variants %>
   </p>
 
@@ -42,10 +38,17 @@
       <%= f.text_area :body %>
     </p>
     <p>
+      <%= recaptcha_tags %>
+    </p>
+    <p>
       <%= f.submit 'Create' %>
     </p>
   <% end %>
 
+  <% @port.comments.each do |comment| %>
+    <div><%= h comment.body %></div>
+  <% end %>
+
   <%= link_to 'Edit', edit_port_path(@port) %> |
   <%= link_to 'Back', ports_path %>
 </div>
\ No newline at end of file

Modified: branches/gsoc10-mpwa/config/environment.rb
===================================================================
--- branches/gsoc10-mpwa/config/environment.rb	2010-06-21 21:53:08 UTC (rev 69039)
+++ branches/gsoc10-mpwa/config/environment.rb	2010-06-21 21:56:08 UTC (rev 69040)
@@ -7,5 +7,7 @@
 require File.join(File.dirname(__FILE__), 'boot')
 
 Rails::Initializer.run do |config|
+  config.gem "recaptcha", :lib => "recaptcha/rails"
+
   config.time_zone = 'UTC'
 end
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100621/03aca4c2/attachment.html>


More information about the macports-changes mailing list