diff --git a/Gemfile b/Gemfile index 26fbd10..a2ed6a0 100644 --- a/Gemfile +++ b/Gemfile @@ -3,12 +3,12 @@ source 'https://rubygems.org' gem 'rails', '3.2.8' group :development do - gem 'sqlite3' + gem 'sqlite3' end group :production do - gem 'thin' - gem 'pg' + gem 'thin' + gem 'pg' end # Gems used only for assets and not required @@ -27,4 +27,4 @@ gem 'jquery-rails' gem 'amazon_flex_pay' # Configuration File -gem 'rails_config' \ No newline at end of file +gem 'rails_config' diff --git a/app/assets/javascripts/preorder.js.coffee b/app/assets/javascripts/preorder.js.coffee index 3919e25..c6c6339 100644 --- a/app/assets/javascripts/preorder.js.coffee +++ b/app/assets/javascripts/preorder.js.coffee @@ -20,9 +20,3 @@ Selfstarter = $ -> Selfstarter.init() $("#email").focus() - - - - - - diff --git a/app/assets/stylesheets/homepage/call_to_action.css.scss b/app/assets/stylesheets/homepage/call_to_action.css.scss index edb154b..078f6c5 100644 --- a/app/assets/stylesheets/homepage/call_to_action.css.scss +++ b/app/assets/stylesheets/homepage/call_to_action.css.scss @@ -1,4 +1,4 @@ -#reserve_container +#reserve_container { float: left; padding-top: 20px; @@ -8,13 +8,13 @@ box-shadow: 0 -1px 0 #cbcbcb; /* drop shadow */ margin-top: 30px; text-align: center; - p + p { color: #8b8a8a; font-size: 18px; line-height: 1.4; } - #ship_date + #ship_date { color: #4c4c4c; font-size: 22px; @@ -24,7 +24,7 @@ margin: 0 auto; width: 300px; } - #price + #price { color: #4c4c4c; font-size: 22px; @@ -35,7 +35,7 @@ width: 300px; } } -.reserve +.reserve { margin: 0 auto; margin-top: 20px; @@ -45,7 +45,7 @@ font-size: 32px; } -#middle_reserve +#middle_reserve { padding: 60px; h2 @@ -53,4 +53,3 @@ margin-bottom: 26px; } } - diff --git a/app/assets/stylesheets/homepage/press.css.scss b/app/assets/stylesheets/homepage/press.css.scss index c18b38e..9cc907b 100644 --- a/app/assets/stylesheets/homepage/press.css.scss +++ b/app/assets/stylesheets/homepage/press.css.scss @@ -4,7 +4,7 @@ -moz-box-shadow: 0px 1px 3px 0px #acacac; -webkit-box-shadow: 0px 1px 3px 0px #acacac; box-shadow: 0px 1px 3px 0px #acacac; - li + li { float: left; margin: 0 16px; @@ -39,9 +39,3 @@ width: 81px; } } - - - - - - diff --git a/app/assets/stylesheets/homepage/stats.css.scss b/app/assets/stylesheets/homepage/stats.css.scss index 42d16b3..2c2c6b7 100644 --- a/app/assets/stylesheets/homepage/stats.css.scss +++ b/app/assets/stylesheets/homepage/stats.css.scss @@ -1,47 +1,47 @@ -#backing +#backing { float: left; width: 383px; margin: 20px 0 0 40px; - #backers - { - border-left: none; - padding-left: 0; - ul - { - float: left; - } - } - #days { - border-right: none; - padding-right: 0; - } - ul { - text-align: center; - } - .stats - { - margin: 0 auto; - color: #3f3f3f; - font-size: 24px; - display: block; - display: inline-block; - font-family: $primary_font, $secondary_font, $tertiary_font; - border-right: 1px solid #cbcbcb; - padding-right: 26px; - padding-left: 26px; - text-align: left; - span - { - color: #868686; - font-size: 18px; - margin-top: 5px; - display: block; - font-family: $primary_font, $secondary_font, $tertiary_font; - } - } + #backers + { + border-left: none; + padding-left: 0; + ul + { + float: left; + } + } + #days { + border-right: none; + padding-right: 0; + } + ul { + text-align: center; + } + .stats + { + margin: 0 auto; + color: #3f3f3f; + font-size: 24px; + display: block; + display: inline-block; + font-family: $primary_font, $secondary_font, $tertiary_font; + border-right: 1px solid #cbcbcb; + padding-right: 26px; + padding-left: 26px; + text-align: left; + span + { + color: #868686; + font-size: 18px; + margin-top: 5px; + display: block; + font-family: $primary_font, $secondary_font, $tertiary_font; + } + } } -#progress_bg +#progress_bg { margin-top: 20px; float: left; @@ -54,7 +54,7 @@ border-radius: 30px; width: 383px; background: #dbdbdb; - #progress + #progress { height: 40px; -moz-box-shadow: 0 1px 1px rgba(0,0,0,.59); /* drop shadow */ @@ -74,23 +74,23 @@ display: inline-block; } #progress_text - { - margin: 0 auto; - width: 100%; - font-size: 14pt; - display: inline-block; - color: white; - text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.37); - text-align: center; - position: relative; - top: -35px; - } + { + margin: 0 auto; + width: 100%; + font-size: 14pt; + display: inline-block; + color: white; + text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.37); + text-align: center; + position: relative; + top: -35px; + } } .small { - height: 20px !important; - #progress - { - height: 20px !important; - } -} \ No newline at end of file + height: 20px !important; + #progress + { + height: 20px !important; + } +} diff --git a/app/controllers/preorder_controller.rb b/app/controllers/preorder_controller.rb index 2367fc0..db819b6 100644 --- a/app/controllers/preorder_controller.rb +++ b/app/controllers/preorder_controller.rb @@ -2,41 +2,38 @@ class PreorderController < ApplicationController skip_before_filter :verify_authenticity_token, :only => :ipn def index - end def checkout - end def prefill - @user = User.find_or_create_by_email!(params[:email]) - @order = Order.prefill!(:name => Settings.product_name, :price => Settings.price, :user_id => @user.id) + @user = User.find_or_create_by_email!(params[:email]) + @order = Order.prefill!(:name => Settings.product_name, :price => Settings.price, :user_id => @user.id) - # This is where all the magic happens. We create a multi-use token with Amazon, letting us charge the user's Amazon account - # Then, if they confirm the payment, Amazon POSTs us their shipping details and phone number - # From there, we save it, and voila, we got ourselves a preorder! + # This is where all the magic happens. We create a multi-use token with Amazon, letting us charge the user's Amazon account + # Then, if they confirm the payment, Amazon POSTs us their shipping details and phone number + # From there, we save it, and voila, we got ourselves a preorder! @pipeline = AmazonFlexPay.multi_use_pipeline(@order.uuid, :transaction_amount => Settings.price, :global_amount_limit => Settings.charge_limit, :collect_shipping_address => "True", :payment_reason => Settings.payment_description) - redirect_to @pipeline.url("#{request.scheme}://#{request.host}/preorder/postfill") + redirect_to @pipeline.url("#{request.scheme}://#{request.host}/preorder/postfill") end def postfill - unless params[:callerReference].blank? - @order = Order.postfill!(params) - end - # "A" means the user cancelled the preorder before clicking "Confirm" on Amazon Payments. - if params['status'] != 'A' && @order.present? - redirect_to :action => :share, :uuid => @order.uuid - else - redirect_to root_url - end + unless params[:callerReference].blank? + @order = Order.postfill!(params) + end + # "A" means the user cancelled the preorder before clicking "Confirm" on Amazon Payments. + if params['status'] != 'A' && @order.present? + redirect_to :action => :share, :uuid => @order.uuid + else + redirect_to root_url + end end def share - @order = Order.find_by_uuid(params[:uuid]) + @order = Order.find_by_uuid(params[:uuid]) end def ipn end - end diff --git a/app/helpers/preorder_helper.rb b/app/helpers/preorder_helper.rb index 8372d05..d46028a 100644 --- a/app/helpers/preorder_helper.rb +++ b/app/helpers/preorder_helper.rb @@ -1,17 +1,17 @@ module PreorderHelper - def like_button(width = 70, show_faces = false) - raw "
" - end - def pin_it_button - image_url = URI.encode("#{request.scheme}://#{request.host}#{image_path(Settings.product_image_url)}") - raw "" - end - def tweet_button - tweet_text = "I'm #{Settings.primary_stat_verb} number #{number_with_delimiter @order.number, :delimiter => ","} #{Settings.tweet_text}!" - raw "Tweet" - end + def like_button(width = 70, show_faces = false) + raw "
" + end + def pin_it_button + image_url = URI.encode("#{request.scheme}://#{request.host}#{image_path(Settings.product_image_url)}") + raw "" + end + def tweet_button + tweet_text = "I'm #{Settings.primary_stat_verb} number #{number_with_delimiter @order.number, :delimiter => ","} #{Settings.tweet_text}!" + raw "Tweet" + end - def encoded_root_url - raw URI.encode "#{request.scheme}://#{request.host}/preorder" - end + def encoded_root_url + raw URI.encode "#{request.scheme}://#{request.host}/preorder" + end end diff --git a/app/models/order.rb b/app/models/order.rb index 8821428..b7c9687 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -2,51 +2,50 @@ class Order < ActiveRecord::Base attr_accessible :address_one, :address_two, :city, :country, :number, :state, :status, :token, :transaction_id, :zip, :shipping, :tracking_number, :name, :price, :phone, :expiration attr_readonly :uuid before_validation :generate_uuid!, :on => :create - belongs_to :user + belongs_to :user self.primary_key = 'uuid' - # This is where we create our Caller Reference for Amazon Payments, and prefill some other information. def self.prefill!(options = {}) - @order = Order.new - @order.name = options[:name] - @order.user_id = options[:user_id] - @order.price = options[:price] - @order.number = Order.next_order_number || 1 - @order.save! + @order = Order.new + @order.name = options[:name] + @order.user_id = options[:user_id] + @order.price = options[:price] + @order.number = Order.next_order_number || 1 + @order.save! - return @order + @order end # After authenticating with Amazon, we get the rest of the details def self.postfill!(options = {}) - @order = Order.find_by_uuid!(options[:callerReference]) - @order.token = options[:tokenID] - if !@order.token.blank? - @order.address_one = options[:addressLine1] - @order.address_two = options[:addressLine2] - @order.city = options[:city] - @order.state = options[:state] + @order = Order.find_by_uuid!(options[:callerReference]) + @order.token = options[:tokenID] + if @order.token.present? + @order.address_one = options[:addressLine1] + @order.address_two = options[:addressLine2] + @order.city = options[:city] + @order.state = options[:state] @order.status = options[:status] - @order.zip = options[:zip] - @order.phone = options[:phoneNumber] - @order.country = options[:country] + @order.zip = options[:zip] + @order.phone = options[:phoneNumber] + @order.country = options[:country] @order.expiration = Date.parse(options[:expiry]) - @order.save! + @order.save! - @order - end + @order + end end def self.next_order_number - Order.order("number DESC").limit(1).first.number.to_i + 1 if Order.count > 0 + Order.order("number DESC").limit(1).first.number.to_i + 1 if Order.count > 0 end def generate_uuid! - self.uuid = SecureRandom.hex(16) + self.uuid = SecureRandom.hex(16) end - # Implement these three methods to + # Implement these three methods to def self.goal Settings.project_goal end diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index 635aa49..1ff4f44 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -1,22 +1,22 @@ \ No newline at end of file +
+ +

© 2009-2012 Apigy Inc. All rights reserved. Patents pending.

+
+ diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index d2436b0..5b359de 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,14 +1,14 @@ - - -<%= Settings.product_name %> - <%= stylesheet_link_tag "application" %> - <%= javascript_include_tag "application" %> - - - <%= render 'header' %> - <%= yield %> - <%= render 'footer' %> - + + + <%= Settings.product_name %> + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application" %> + + + <%= render 'header' %> + <%= yield %> + <%= render 'footer' %> + diff --git a/app/views/preorder/_footer.html.erb b/app/views/preorder/_footer.html.erb index e62031a..80d3555 100644 --- a/app/views/preorder/_footer.html.erb +++ b/app/views/preorder/_footer.html.erb @@ -1,6 +1,6 @@ -<%= render 'google_analytics' %> \ No newline at end of file +<%= render 'google_analytics' %> diff --git a/app/views/preorder/_google_analytics.html.erb b/app/views/preorder/_google_analytics.html.erb index 740b4d0..8a520e0 100644 --- a/app/views/preorder/_google_analytics.html.erb +++ b/app/views/preorder/_google_analytics.html.erb @@ -1,5 +1,4 @@ \ No newline at end of file + diff --git a/app/views/preorder/checkout.html.erb b/app/views/preorder/checkout.html.erb index b42d2aa..880f89c 100644 --- a/app/views/preorder/checkout.html.erb +++ b/app/views/preorder/checkout.html.erb @@ -5,8 +5,8 @@

Let your backers know how their payment information will be handled.
-
- Enter your email address below. +
+ Enter your email address below.

<%= form_tag "/preorder/prefill", :id => "checkout" do %> <%= email_field_tag "email", nil, :placeholder => "hello@lockitron.com", :required => "required", :id => "email" %> @@ -17,4 +17,4 @@ <%= render 'preorder/checkout/sidebar' %> - \ No newline at end of file + diff --git a/app/views/preorder/homepage/_faqs.html.erb b/app/views/preorder/homepage/_faqs.html.erb index 25290c5..0f595bf 100644 --- a/app/views/preorder/homepage/_faqs.html.erb +++ b/app/views/preorder/homepage/_faqs.html.erb @@ -1,71 +1,69 @@
-
-

Frequently Asked Questions

- - -
+
+

Frequently Asked Questions

+ + +
- \ No newline at end of file diff --git a/app/views/preorder/homepage/_key_points.html.erb b/app/views/preorder/homepage/_key_points.html.erb index ecce453..9a4d64d 100644 --- a/app/views/preorder/homepage/_key_points.html.erb +++ b/app/views/preorder/homepage/_key_points.html.erb @@ -48,4 +48,4 @@

- \ No newline at end of file + diff --git a/app/views/preorder/homepage/_middle_reserve.html.erb b/app/views/preorder/homepage/_middle_reserve.html.erb index 6cf1a3c..c789606 100644 --- a/app/views/preorder/homepage/_middle_reserve.html.erb +++ b/app/views/preorder/homepage/_middle_reserve.html.erb @@ -3,4 +3,4 @@

<%= Settings.ships %>

<%= Settings.middle_reserve_text %> - \ No newline at end of file + diff --git a/app/views/preorder/homepage/_other_points.html.erb b/app/views/preorder/homepage/_other_points.html.erb index a54579c..00aa3e5 100644 --- a/app/views/preorder/homepage/_other_points.html.erb +++ b/app/views/preorder/homepage/_other_points.html.erb @@ -17,4 +17,4 @@

Curabitur ac mi elit, nec tempor odio. Nam sollicitudin, sapien sit amet elementum pretium, turpis mi fermentum nisl, ac vehicula purus lacus non velit.

- \ No newline at end of file + diff --git a/app/views/preorder/homepage/_press.html.erb b/app/views/preorder/homepage/_press.html.erb index f837db6..b8d4c74 100644 --- a/app/views/preorder/homepage/_press.html.erb +++ b/app/views/preorder/homepage/_press.html.erb @@ -1,8 +1,8 @@
- -
\ No newline at end of file + + diff --git a/app/views/preorder/share.html.erb b/app/views/preorder/share.html.erb index a4449a4..aea025a 100644 --- a/app/views/preorder/share.html.erb +++ b/app/views/preorder/share.html.erb @@ -4,23 +4,22 @@ Hooray! You've just reserved a <%= Settings.product_name %>!

Congratulations, you're <%= Settings.primary_stat_verb %> number <%= number_with_delimiter @order.number, :delimiter => "," %>, in supporting <%= Settings.product_name %>. Share the great news!

-
-
+
+
-
- <%= pin_it_button %> -
-
- <%= tweet_button %> -
-
- <%= like_button(450, true) %> -
-
-
Reservation ID: <%= @order.uuid %>. You can bookmark or print this page for your records.
+
+ <%= pin_it_button %> +
+
+ <%= tweet_button %> +
+
+ <%= like_button(450, true) %> +
+ +
Reservation ID: <%= @order.uuid %>. You can bookmark or print this page for your records.
- <%= render 'preorder/share/twitter_js' %> -<%= render 'preorder/share/facebook_js' %> \ No newline at end of file +<%= render 'preorder/share/facebook_js' %> diff --git a/config/routes.rb b/config/routes.rb index d1fe958..866c4d9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,11 +1,9 @@ Selfstarter::Application.routes.draw do - root :to => "preorder#index" - - match '/preorder' => 'preorder#index' - get "preorder/checkout" - match '/preorder/share/:uuid' => 'preorder#share', :via => :get - match '/preorder/ipn' => 'preorder#ipn', :via => :post - match '/preorder/prefill' => 'preorder#prefill' - match '/preorder/postfill' => 'preorder#postfill' - + root :to => 'preorder#index' + match '/preorder' => 'preorder#index' + get 'preorder/checkout' + match '/preorder/share/:uuid' => 'preorder#share', :via => :get + match '/preorder/ipn' => 'preorder#ipn', :via => :post + match '/preorder/prefill' => 'preorder#prefill' + match '/preorder/postfill' => 'preorder#postfill' end diff --git a/test/functional/preorder_controller_test.rb b/test/functional/preorder_controller_test.rb index 34c1aec..5615b6d 100644 --- a/test/functional/preorder_controller_test.rb +++ b/test/functional/preorder_controller_test.rb @@ -15,5 +15,4 @@ class PreorderControllerTest < ActionController::TestCase get :get_excited assert_response :success end - end