[71262] branches/gsoc10-mpwa/mpwa

jrozner at macports.org jrozner at macports.org
Tue Sep 7 00:22:27 PDT 2010


Revision: 71262
          http://trac.macports.org/changeset/71262
Author:   jrozner at macports.org
Date:     2010-09-07 00:22:24 -0700 (Tue, 07 Sep 2010)
Log Message:
-----------
finished rails 3 port and replaced recaptcha with rack-recaptcha

Modified Paths:
--------------
    branches/gsoc10-mpwa/mpwa/Gemfile
    branches/gsoc10-mpwa/mpwa/Gemfile.lock
    branches/gsoc10-mpwa/mpwa/app/controllers/application_controller.rb
    branches/gsoc10-mpwa/mpwa/app/controllers/comments_controller.rb
    branches/gsoc10-mpwa/mpwa/app/helpers/ports_helper.rb
    branches/gsoc10-mpwa/mpwa/app/views/layouts/application.html.erb
    branches/gsoc10-mpwa/mpwa/app/views/partials/_nav.html.erb
    branches/gsoc10-mpwa/mpwa/app/views/ports/show.html.erb
    branches/gsoc10-mpwa/mpwa/config/application.rb
    branches/gsoc10-mpwa/mpwa/config/routes.rb

Modified: branches/gsoc10-mpwa/mpwa/Gemfile
===================================================================
--- branches/gsoc10-mpwa/mpwa/Gemfile	2010-09-07 06:50:33 UTC (rev 71261)
+++ branches/gsoc10-mpwa/mpwa/Gemfile	2010-09-07 07:22:24 UTC (rev 71262)
@@ -2,9 +2,10 @@
 
 gem 'rails', '3.0.0'
 
-gem 'recaptcha', :require => "recaptcha/rails"
+gem 'rack-recaptcha', :require => 'rack/recaptcha'
 gem 'will_paginate', '3.0.pre2'
 
 group :development, :test do
+  gem 'thin'
   gem 'sqlite3'
 end

Modified: branches/gsoc10-mpwa/mpwa/Gemfile.lock
===================================================================
--- branches/gsoc10-mpwa/mpwa/Gemfile.lock	2010-09-07 06:50:33 UTC (rev 71261)
+++ branches/gsoc10-mpwa/mpwa/Gemfile.lock	2010-09-07 07:22:24 UTC (rev 71262)
@@ -31,11 +31,14 @@
     arel (1.0.1)
       activesupport (~> 3.0.0)
     builder (2.1.2)
+    daemons (1.1.0)
     erubis (2.6.6)
       abstract (>= 1.0.0)
+    eventmachine (0.12.10)
     ffi (0.6.3)
       rake (>= 0.8.7)
     i18n (0.4.1)
+    json (1.4.6)
     mail (2.2.5)
       activesupport (>= 2.3.6)
       mime-types
@@ -45,6 +48,8 @@
     rack (1.2.1)
     rack-mount (0.6.13)
       rack (>= 1.0.0)
+    rack-recaptcha (0.2.2)
+      json
     rack-test (0.5.4)
       rack (>= 1.0)
     rails (3.0.0)
@@ -61,9 +66,12 @@
       rake (>= 0.8.4)
       thor (~> 0.14.0)
     rake (0.8.7)
-    recaptcha (0.2.3)
     sqlite3 (0.1.1)
       ffi (>= 0.6.3)
+    thin (1.2.7)
+      daemons (>= 1.0.9)
+      eventmachine (>= 0.12.6)
+      rack (>= 1.0.0)
     thor (0.14.0)
     treetop (1.4.8)
       polyglot (>= 0.3.1)
@@ -74,7 +82,8 @@
   ruby
 
 DEPENDENCIES
+  rack-recaptcha
   rails (= 3.0.0)
-  recaptcha
   sqlite3
+  thin
   will_paginate (= 3.0.pre2)

Modified: branches/gsoc10-mpwa/mpwa/app/controllers/application_controller.rb
===================================================================
--- branches/gsoc10-mpwa/mpwa/app/controllers/application_controller.rb	2010-09-07 06:50:33 UTC (rev 71261)
+++ branches/gsoc10-mpwa/mpwa/app/controllers/application_controller.rb	2010-09-07 07:22:24 UTC (rev 71262)
@@ -1,6 +1,7 @@
 # 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'
+#require 'recaptcha'
+include Rack::Recaptcha::Helpers
 
 class ApplicationController < ActionController::Base
   helper :all # include all helpers, all the time

Modified: branches/gsoc10-mpwa/mpwa/app/controllers/comments_controller.rb
===================================================================
--- branches/gsoc10-mpwa/mpwa/app/controllers/comments_controller.rb	2010-09-07 06:50:33 UTC (rev 71261)
+++ branches/gsoc10-mpwa/mpwa/app/controllers/comments_controller.rb	2010-09-07 07:22:24 UTC (rev 71262)
@@ -5,7 +5,7 @@
     @comment = Port.find(params[:port_id]).comments.build(params[:comment])
 
     respond_to do |format|
-      if verify_recaptcha
+      if recaptcha_valid?
         if @comment.save
           format.html { redirect_to category_port_path(@comment.port.category, @comment.port) }
         end

Modified: branches/gsoc10-mpwa/mpwa/app/helpers/ports_helper.rb
===================================================================
--- branches/gsoc10-mpwa/mpwa/app/helpers/ports_helper.rb	2010-09-07 06:50:33 UTC (rev 71261)
+++ branches/gsoc10-mpwa/mpwa/app/helpers/ports_helper.rb	2010-09-07 07:22:24 UTC (rev 71262)
@@ -6,7 +6,7 @@
       vals.split(" ").each do |val|
         links += "#{link_to val, search_path(member, val)} "
       end
-      return links
+      return raw(links)
     else
       return nil
     end

Modified: branches/gsoc10-mpwa/mpwa/app/views/layouts/application.html.erb
===================================================================
--- branches/gsoc10-mpwa/mpwa/app/views/layouts/application.html.erb	2010-09-07 06:50:33 UTC (rev 71261)
+++ branches/gsoc10-mpwa/mpwa/app/views/layouts/application.html.erb	2010-09-07 07:22:24 UTC (rev 71262)
@@ -1,7 +1,7 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 <head>
-    <title></title>
+    <title>The MacPorts Project - <%= controller_name.titleize %></title>
     <meta name="author" content="Jim Mock (mij at macports.org)" />
     <meta name="author" content="Juan Manuel Palacios (jmpp at macports.org)" />
     <meta name="author" content="Chris Pickel (sfiera at macports.org)" />
@@ -14,12 +14,12 @@
 </head>
 <body>
 
-  <h1><%= link_to '<span class="accessibility">The MacPorts Project</span>', root_url %></h1>
+  <h1><%= link_to raw('<span class="accessibility">The MacPorts Project</span>'), root_url %></h1>
 
   <p class="accessibility"><%= link_to 'Skip to Content', '#content' %></p>
 
   <div id="header">
-    <%= link_to '<span class="accessibility">Download MacPorts</span>', install_path, {:id => 'download'} %>
+    <%= link_to raw('<span class="accessibility">Download MacPorts</span>'), install_path, {:id => 'download'} %>
   </div>
 
   <%= render :partial => '/partials/nav' %>

Modified: branches/gsoc10-mpwa/mpwa/app/views/partials/_nav.html.erb
===================================================================
--- branches/gsoc10-mpwa/mpwa/app/views/partials/_nav.html.erb	2010-09-07 06:50:33 UTC (rev 71261)
+++ branches/gsoc10-mpwa/mpwa/app/views/partials/_nav.html.erb	2010-09-07 07:22:24 UTC (rev 71262)
@@ -7,7 +7,7 @@
         <li><%= link_to 'Installing MacPorts', install_path %></li>
         <li><%= link_to 'Available Ports', categories_path %></li>
         <li><%= link_to 'Documentation', $guide_url %></li>
-        <li><%= link_to 'Support &amp; Development', $trac_url %></li>
+        <li><%= link_to 'Support & Development', $trac_url %></li>
         <li><%= link_to 'Contact Us', contact_path %></li>
         <li><%= link_to 'News', "#{$trac_url}news" %></li>
       </ul>

Modified: branches/gsoc10-mpwa/mpwa/app/views/ports/show.html.erb
===================================================================
--- branches/gsoc10-mpwa/mpwa/app/views/ports/show.html.erb	2010-09-07 06:50:33 UTC (rev 71261)
+++ branches/gsoc10-mpwa/mpwa/app/views/ports/show.html.erb	2010-09-07 07:22:24 UTC (rev 71262)
@@ -1,21 +1,21 @@
 <div id="content">
   <p>
-    <strong>Name:</strong> <%=h @port.name %>
+    <strong>Name:</strong> <%= @port.name %>
   </p>
 
   <p>
-    <strong>Current Version:</strong> <%=h @port.version %>
+    <strong>Current Version:</strong> <%= @port.version %>
   </p>
 
   <% unless @port.description.nil? %>
     <p>
-      <strong>Description:</strong> <%=h @port.description %>
+      <strong>Description:</strong> <%= @port.description %>
     </p>
   <% end %>
 
   <% unless @port.licenses.nil? %>
     <p>
-      <strong>Licenses:</strong> <%=h @port.licenses %>
+      <strong>Licenses:</strong> <%= @port.licenses %>
     </p>
   <% end %>
 
@@ -55,14 +55,13 @@
   <div>
     <h3>Comments</h3>
     <%= form_for([@port.category, @port, @comment]) do |f| %>
-      <%= f.error_messages %>
 
       <p>
-        <%= f.label :body, "<strong>Comment</strong>" %><br />
+        <%= f.label :body, raw("<strong>Comment</strong>") %><br />
         <%= f.text_area :body, {:rows => 5, :cols => 80} %>
       </p>
       <p>
-        <%= recaptcha_tags :display => {:theme => 'clean'} %>
+        <%= raw(recaptcha_tag :challenge, :display => {:theme => 'clean'}) %>
       </p>
       <p>
         <%= f.submit 'Create' %>
@@ -70,7 +69,7 @@
     <% end %>
 
     <% @port.comments.each do |comment| %>
-      <div><%= h comment.body %></div>
+      <div><%= comment.body %></div>
     <% end %>
   </div>
 

Modified: branches/gsoc10-mpwa/mpwa/config/application.rb
===================================================================
--- branches/gsoc10-mpwa/mpwa/config/application.rb	2010-09-07 06:50:33 UTC (rev 71261)
+++ branches/gsoc10-mpwa/mpwa/config/application.rb	2010-09-07 07:22:24 UTC (rev 71262)
@@ -24,5 +24,7 @@
 
     # Configure sensitive parameters which will be filtered from the log file.
     config.filter_parameters += [:password]
+
+    config.middleware.use Rack::Recaptcha, :public_key => '', :private_key => ''
   end
 end

Modified: branches/gsoc10-mpwa/mpwa/config/routes.rb
===================================================================
--- branches/gsoc10-mpwa/mpwa/config/routes.rb	2010-09-07 06:50:33 UTC (rev 71261)
+++ branches/gsoc10-mpwa/mpwa/config/routes.rb	2010-09-07 07:22:24 UTC (rev 71262)
@@ -1,19 +1,20 @@
 ActionController::Routing::Routes.draw do |map|
-  map.resources :categories, :only => [:index] do |category|
-    category.resources :ports, :only => [:index, :show] do |port|
-      port.resources :comments, :only => [:new, :create]
+  resources :categories, :only => [:index] do
+    resources :ports, :only => [:index, :show] do
+      resources :comments, :only => [:create, :destroy]
     end
-    category.connect '/ports/page/:page', :controller => :ports, :action => :index, :page => :page
+
+    match '/ports/page/:page', :to => 'ports#index', :as => :ports, :page => :page
   end
 
-  map.connect '/ports/page/:page', :controller => :ports, :action => :index, :page => :page
-  map.resources :ports, :only => [:index, :search]
-  map.search_generate 'ports/search', :controller => :ports, :action => :search_generate
-  map.connect '/ports/search/:criteria/:val/page/:page', :controller => :ports, :action => :search, :criteria => :criteria, :val => :val, :page => :page
-  map.search '/ports/search/:criteria/:val', :controller => :ports, :action => :search, :criteria => :criteria, :val => :val
+  match '/ports/page/:page', :to => 'ports#index', :page => :page
+  resources :ports, :only => [:index, :search]
+  match '/ports/search', :to => 'ports#search_generate', :as => :search_generate
+  match '/ports/search/:criteria/:val/page/:page', :to => 'ports#search', :criteria => :criteria, :val => :val, :page => :page
+  match '/ports/search/:criteria/:val', :to => 'ports#search', :criteria => :criteria, :val => :val, :as => :search
 
-  map.index 'index', :controller => :pages, :action => :show, :page => :index
-  map.install 'install', :controller => :pages, :action => :show, :page => :install
-  map.contact 'contact', :controller => :pages, :action => :show, :page => :contact
-  map.root :controller => :pages, :action => :show, :page => :index
+  match '/index', :to => 'pages#show', :page => :index, :as => :index
+  match '/install', :to => 'pages#show', :page => :install, :as => :install
+  match '/contact', :to => 'pages#show', :page => :contact, :as => :contact
+  root :to => 'pages#show', :page => :index
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100907/842415ac/attachment.html>


More information about the macports-changes mailing list