Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

first commit

  • Loading branch information...
commit e0bbc87a92a3bc9be5c09682460c044d1a2e20d7 0 parents
Nov Matake authored May 14, 2011

Showing 72 changed files with 1,338 additions and 0 deletions. Show diff stats Hide diff stats

  1. 5  .gitignore
  2. 29  Gemfile
  3. 108  Gemfile.lock
  4. 256  README
  5. 7  Rakefile
  6. BIN  app/assets/images/.DS_Store
  7. BIN  app/assets/images/money.png
  8. BIN  app/assets/images/rails.png
  9. 6  app/assets/javascripts/application.js
  10. 3  app/assets/javascripts/payments.js.coffee
  11. 3  app/assets/javascripts/top.js.coffee
  12. 50  app/assets/stylesheets/application.css
  13. 10  app/assets/stylesheets/box.css.scss
  14. 167  app/assets/stylesheets/lessframework.css
  15. 5  app/assets/stylesheets/payments.css.scss
  16. 38  app/assets/stylesheets/top.css.scss
  17. 3  app/controllers/application_controller.rb
  18. 6  app/controllers/payments_controller.rb
  19. 4  app/controllers/top_controller.rb
  20. 2  app/helpers/application_helper.rb
  21. 2  app/helpers/payments_helper.rb
  22. 2  app/helpers/top_helper.rb
  23. 0  app/mailers/.gitkeep
  24. 0  app/models/.gitkeep
  25. 6  app/models/payment.rb
  26. 6  app/views/layouts/_footer.html.erb
  27. 9  app/views/layouts/_header.html.erb
  28. 21  app/views/layouts/application.html.erb
  29. 5  app/views/payments/_form.html.erb
  30. 52  app/views/top/index.html.erb
  31. 4  config.ru
  32. 53  config/application.rb
  33. 6  config/boot.rb
  34. 22  config/database.yml
  35. 5  config/environment.rb
  36. 25  config/environments/development.rb
  37. 52  config/environments/production.rb
  38. 39  config/environments/test.rb
  39. 7  config/initializers/backtrace_silencers.rb
  40. 10  config/initializers/inflections.rb
  41. 5  config/initializers/mime_types.rb
  42. 7  config/initializers/secret_token.rb
  43. 8  config/initializers/session_store.rb
  44. 12  config/initializers/wrap_parameters.rb
  45. 25  config/locales/en.yml
  46. 61  config/routes.rb
  47. 8  db/migrate/20110514094452_create_payments.rb
  48. 22  db/schema.rb
  49. 7  db/seeds.rb
  50. 2  doc/README_FOR_APP
  51. 0  log/.gitkeep
  52. 26  public/404.html
  53. 26  public/422.html
  54. 26  public/500.html
  55. 0  public/favicon.ico
  56. 5  public/robots.txt
  57. 6  script/rails
  58. 0  tasks/.gitkeep b/lib/tasks/.gitkeep
  59. 0  test/fixtures/.gitkeep
  60. 11  test/fixtures/payments.yml
  61. 0  test/functional/.gitkeep
  62. 7  test/functional/payments_controller_test.rb
  63. 9  test/functional/top_controller_test.rb
  64. 0  test/integration/.gitkeep
  65. 9  test/performance/browsing_test.rb
  66. 13  test/test_helper.rb
  67. 0  test/unit/.gitkeep
  68. 4  test/unit/helpers/payments_helper_test.rb
  69. 4  test/unit/helpers/top_helper_test.rb
  70. 7  test/unit/payment_test.rb
  71. 0  vendor/assets/stylesheets/.gitkeep
  72. 0  vendor/plugins/.gitkeep
5  .gitignore
... ...
@@ -0,0 +1,5 @@
  1
+.bundle
  2
+.sass-cache
  3
+db/*.sqlite3
  4
+log/*.log
  5
+tmp/
29  Gemfile
... ...
@@ -0,0 +1,29 @@
  1
+source 'http://rubygems.org'
  2
+
  3
+gem 'rails', '3.1.0.beta1'
  4
+
  5
+# Bundle edge Rails instead:
  6
+# gem 'rails',     :git => 'git://github.com/rails/rails.git'
  7
+
  8
+gem 'sqlite3'
  9
+
  10
+# Asset template engines
  11
+gem 'sass'
  12
+gem 'coffee-script'
  13
+gem 'uglifier'
  14
+
  15
+gem 'jquery-rails'
  16
+
  17
+# Use unicorn as the web server
  18
+# gem 'unicorn'
  19
+
  20
+# Deploy with Capistrano
  21
+# gem 'capistrano'
  22
+
  23
+# To use debugger
  24
+# gem 'ruby-debug19', :require => 'ruby-debug'
  25
+
  26
+group :test do
  27
+  # Pretty printed test output
  28
+  gem 'turn', :require => false
  29
+end
108  Gemfile.lock
... ...
@@ -0,0 +1,108 @@
  1
+GEM
  2
+  remote: http://rubygems.org/
  3
+  specs:
  4
+    actionmailer (3.1.0.beta1)
  5
+      actionpack (= 3.1.0.beta1)
  6
+      mail (~> 2.3.0)
  7
+    actionpack (3.1.0.beta1)
  8
+      activemodel (= 3.1.0.beta1)
  9
+      activesupport (= 3.1.0.beta1)
  10
+      builder (~> 3.0.0)
  11
+      erubis (~> 2.7.0)
  12
+      i18n (~> 0.6.0beta1)
  13
+      rack (~> 1.3.0.beta)
  14
+      rack-cache (~> 1.0.1)
  15
+      rack-mount (~> 0.7.2)
  16
+      rack-test (~> 0.6.0)
  17
+      sprockets (~> 2.0.0.beta.2)
  18
+      tzinfo (~> 0.3.27)
  19
+    activemodel (3.1.0.beta1)
  20
+      activesupport (= 3.1.0.beta1)
  21
+      bcrypt-ruby (~> 2.1.4)
  22
+      builder (~> 3.0.0)
  23
+      i18n (~> 0.6.0beta1)
  24
+    activerecord (3.1.0.beta1)
  25
+      activemodel (= 3.1.0.beta1)
  26
+      activesupport (= 3.1.0.beta1)
  27
+      arel (~> 2.1.0)
  28
+      tzinfo (~> 0.3.27)
  29
+    activeresource (3.1.0.beta1)
  30
+      activemodel (= 3.1.0.beta1)
  31
+      activesupport (= 3.1.0.beta1)
  32
+    activesupport (3.1.0.beta1)
  33
+      multi_json (~> 1.0)
  34
+    ansi (1.2.5)
  35
+    arel (2.1.0)
  36
+    bcrypt-ruby (2.1.4)
  37
+    builder (3.0.0)
  38
+    coffee-script (2.2.0)
  39
+      coffee-script-source
  40
+      execjs
  41
+    coffee-script-source (1.1.0)
  42
+    erubis (2.7.0)
  43
+    execjs (0.3.4)
  44
+      multi_json (~> 1.0)
  45
+    hike (1.0.0)
  46
+    i18n (0.6.0beta1)
  47
+    jquery-rails (1.0.2)
  48
+      railties (~> 3.0)
  49
+      thor (~> 0.14)
  50
+    mail (2.3.0)
  51
+      i18n (>= 0.4.0)
  52
+      mime-types (~> 1.16)
  53
+      treetop (~> 1.4.8)
  54
+    mime-types (1.16)
  55
+    multi_json (1.0.2)
  56
+    polyglot (0.3.1)
  57
+    rack (1.3.0.beta)
  58
+    rack-cache (1.0.1)
  59
+      rack (>= 0.4)
  60
+    rack-mount (0.7.4)
  61
+      rack (>= 1.0.0)
  62
+    rack-ssl (1.3.2)
  63
+      rack
  64
+    rack-test (0.6.0)
  65
+      rack (>= 1.0)
  66
+    rails (3.1.0.beta1)
  67
+      actionmailer (= 3.1.0.beta1)
  68
+      actionpack (= 3.1.0.beta1)
  69
+      activerecord (= 3.1.0.beta1)
  70
+      activeresource (= 3.1.0.beta1)
  71
+      activesupport (= 3.1.0.beta1)
  72
+      bundler (~> 1.0)
  73
+      railties (= 3.1.0.beta1)
  74
+    railties (3.1.0.beta1)
  75
+      actionpack (= 3.1.0.beta1)
  76
+      activesupport (= 3.1.0.beta1)
  77
+      rack-ssl (~> 1.3.2)
  78
+      rake (>= 0.8.7)
  79
+      thor (~> 0.14.6)
  80
+    rake (0.8.7)
  81
+    sass (3.1.1)
  82
+    sprockets (2.0.0.beta.2)
  83
+      hike (~> 1.0)
  84
+      rack (~> 1.0)
  85
+      tilt (~> 1.0)
  86
+    sqlite3 (1.3.3)
  87
+    thor (0.14.6)
  88
+    tilt (1.3)
  89
+    treetop (1.4.9)
  90
+      polyglot (>= 0.3.1)
  91
+    turn (0.8.2)
  92
+      ansi (>= 1.2.2)
  93
+    tzinfo (0.3.27)
  94
+    uglifier (0.5.3)
  95
+      execjs (>= 0.3.0)
  96
+      multi_json (>= 1.0.2)
  97
+
  98
+PLATFORMS
  99
+  ruby
  100
+
  101
+DEPENDENCIES
  102
+  coffee-script
  103
+  jquery-rails
  104
+  rails (= 3.1.0.beta1)
  105
+  sass
  106
+  sqlite3
  107
+  turn
  108
+  uglifier
256  README
... ...
@@ -0,0 +1,256 @@
  1
+== Welcome to Rails
  2
+
  3
+Rails is a web-application framework that includes everything needed to create
  4
+database-backed web applications according to the Model-View-Control pattern.
  5
+
  6
+This pattern splits the view (also called the presentation) into "dumb"
  7
+templates that are primarily responsible for inserting pre-built data in between
  8
+HTML tags. The model contains the "smart" domain objects (such as Account,
  9
+Product, Person, Post) that holds all the business logic and knows how to
  10
+persist themselves to a database. The controller handles the incoming requests
  11
+(such as Save New Account, Update Product, Show Post) by manipulating the model
  12
+and directing data to the view.
  13
+
  14
+In Rails, the model is handled by what's called an object-relational mapping
  15
+layer entitled Active Record. This layer allows you to present the data from
  16
+database rows as objects and embellish these data objects with business logic
  17
+methods. You can read more about Active Record in
  18
+link:files/vendor/rails/activerecord/README.html.
  19
+
  20
+The controller and view are handled by the Action Pack, which handles both
  21
+layers by its two parts: Action View and Action Controller. These two layers
  22
+are bundled in a single package due to their heavy interdependence. This is
  23
+unlike the relationship between the Active Record and Action Pack that is much
  24
+more separate. Each of these packages can be used independently outside of
  25
+Rails. You can read more about Action Pack in
  26
+link:files/vendor/rails/actionpack/README.html.
  27
+
  28
+
  29
+== Getting Started
  30
+
  31
+1. At the command prompt, create a new Rails application:
  32
+       <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
  33
+
  34
+2. Change directory to <tt>myapp</tt> and start the web server:
  35
+       <tt>cd myapp; rails server</tt> (run with --help for options)
  36
+
  37
+3. Go to http://localhost:3000/ and you'll see:
  38
+       "Welcome aboard: You're riding Ruby on Rails!"
  39
+
  40
+4. Follow the guidelines to start developing your application. You can find
  41
+the following resources handy:
  42
+
  43
+* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
  44
+* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
  45
+
  46
+
  47
+== Debugging Rails
  48
+
  49
+Sometimes your application goes wrong. Fortunately there are a lot of tools that
  50
+will help you debug it and get it back on the rails.
  51
+
  52
+First area to check is the application log files. Have "tail -f" commands
  53
+running on the server.log and development.log. Rails will automatically display
  54
+debugging and runtime information to these files. Debugging info will also be
  55
+shown in the browser on requests from 127.0.0.1.
  56
+
  57
+You can also log your own messages directly into the log file from your code
  58
+using the Ruby logger class from inside your controllers. Example:
  59
+
  60
+  class WeblogController < ActionController::Base
  61
+    def destroy
  62
+      @weblog = Weblog.find(params[:id])
  63
+      @weblog.destroy
  64
+      logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
  65
+    end
  66
+  end
  67
+
  68
+The result will be a message in your log file along the lines of:
  69
+
  70
+  Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
  71
+
  72
+More information on how to use the logger is at http://www.ruby-doc.org/core/
  73
+
  74
+Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
  75
+several books available online as well:
  76
+
  77
+* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
  78
+* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
  79
+
  80
+These two books will bring you up to speed on the Ruby language and also on
  81
+programming in general.
  82
+
  83
+
  84
+== Debugger
  85
+
  86
+Debugger support is available through the debugger command when you start your
  87
+Mongrel or WEBrick server with --debugger. This means that you can break out of
  88
+execution at any point in the code, investigate and change the model, and then,
  89
+resume execution! You need to install ruby-debug to run the server in debugging
  90
+mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
  91
+
  92
+  class WeblogController < ActionController::Base
  93
+    def index
  94
+      @posts = Post.all
  95
+      debugger
  96
+    end
  97
+  end
  98
+
  99
+So the controller will accept the action, run the first line, then present you
  100
+with a IRB prompt in the server window. Here you can do things like:
  101
+
  102
+  >> @posts.inspect
  103
+  => "[#<Post:0x14a6be8
  104
+          @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
  105
+       #<Post:0x14a6620
  106
+          @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
  107
+  >> @posts.first.title = "hello from a debugger"
  108
+  => "hello from a debugger"
  109
+
  110
+...and even better, you can examine how your runtime objects actually work:
  111
+
  112
+  >> f = @posts.first
  113
+  => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
  114
+  >> f.
  115
+  Display all 152 possibilities? (y or n)
  116
+
  117
+Finally, when you're ready to resume execution, you can enter "cont".
  118
+
  119
+
  120
+== Console
  121
+
  122
+The console is a Ruby shell, which allows you to interact with your
  123
+application's domain model. Here you'll have all parts of the application
  124
+configured, just like it is when the application is running. You can inspect
  125
+domain models, change values, and save to the database. Starting the script
  126
+without arguments will launch it in the development environment.
  127
+
  128
+To start the console, run <tt>rails console</tt> from the application
  129
+directory.
  130
+
  131
+Options:
  132
+
  133
+* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
  134
+  made to the database.
  135
+* Passing an environment name as an argument will load the corresponding
  136
+  environment. Example: <tt>rails console production</tt>.
  137
+
  138
+To reload your controllers and models after launching the console run
  139
+<tt>reload!</tt>
  140
+
  141
+More information about irb can be found at:
  142
+link:http://www.rubycentral.org/pickaxe/irb.html
  143
+
  144
+
  145
+== dbconsole
  146
+
  147
+You can go to the command line of your database directly through <tt>rails
  148
+dbconsole</tt>. You would be connected to the database with the credentials
  149
+defined in database.yml. Starting the script without arguments will connect you
  150
+to the development database. Passing an argument will connect you to a different
  151
+database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
  152
+PostgreSQL and SQLite 3.
  153
+
  154
+== Description of Contents
  155
+
  156
+The default directory structure of a generated Ruby on Rails application:
  157
+
  158
+  |-- app
  159
+  |   |-- controllers
  160
+  |   |-- helpers
  161
+  |   |-- mailers
  162
+  |   |-- models
  163
+  |   `-- views
  164
+  |       `-- layouts
  165
+  |-- config
  166
+  |   |-- environments
  167
+  |   |-- initializers
  168
+  |   `-- locales
  169
+  |-- db
  170
+  |-- doc
  171
+  |-- lib
  172
+  |   `-- tasks
  173
+  |-- log
  174
+  |-- public
  175
+  |   |-- images
  176
+  |   |-- javascripts
  177
+  |   `-- stylesheets
  178
+  |-- script
  179
+  |-- test
  180
+  |   |-- fixtures
  181
+  |   |-- functional
  182
+  |   |-- integration
  183
+  |   |-- performance
  184
+  |   `-- unit
  185
+  |-- tmp
  186
+  |   |-- cache
  187
+  |   |-- pids
  188
+  |   |-- sessions
  189
+  |   `-- sockets
  190
+  `-- vendor
  191
+      `-- plugins
  192
+
  193
+app
  194
+  Holds all the code that's specific to this particular application.
  195
+
  196
+app/controllers
  197
+  Holds controllers that should be named like weblogs_controller.rb for
  198
+  automated URL mapping. All controllers should descend from
  199
+  ApplicationController which itself descends from ActionController::Base.
  200
+
  201
+app/models
  202
+  Holds models that should be named like post.rb. Models descend from
  203
+  ActiveRecord::Base by default.
  204
+
  205
+app/views
  206
+  Holds the template files for the view that should be named like
  207
+  weblogs/index.html.erb for the WeblogsController#index action. All views use
  208
+  eRuby syntax by default.
  209
+
  210
+app/views/layouts
  211
+  Holds the template files for layouts to be used with views. This models the
  212
+  common header/footer method of wrapping views. In your views, define a layout
  213
+  using the <tt>layout :default</tt> and create a file named default.html.erb.
  214
+  Inside default.html.erb, call <% yield %> to render the view using this
  215
+  layout.
  216
+
  217
+app/helpers
  218
+  Holds view helpers that should be named like weblogs_helper.rb. These are
  219
+  generated for you automatically when using generators for controllers.
  220
+  Helpers can be used to wrap functionality for your views into methods.
  221
+
  222
+config
  223
+  Configuration files for the Rails environment, the routing map, the database,
  224
+  and other dependencies.
  225
+
  226
+db
  227
+  Contains the database schema in schema.rb. db/migrate contains all the
  228
+  sequence of Migrations for your schema.
  229
+
  230
+doc
  231
+  This directory is where your application documentation will be stored when
  232
+  generated using <tt>rake doc:app</tt>
  233
+
  234
+lib
  235
+  Application specific libraries. Basically, any kind of custom code that
  236
+  doesn't belong under controllers, models, or helpers. This directory is in
  237
+  the load path.
  238
+
  239
+public
  240
+  The directory available for the web server. Contains subdirectories for
  241
+  images, stylesheets, and javascripts. Also contains the dispatchers and the
  242
+  default HTML files. This should be set as the DOCUMENT_ROOT of your web
  243
+  server.
  244
+
  245
+script
  246
+  Helper scripts for automation and generation.
  247
+
  248
+test
  249
+  Unit and functional tests along with fixtures. When using the rails generate
  250
+  command, template test files will be generated for you and placed in this
  251
+  directory.
  252
+
  253
+vendor
  254
+  External libraries that the application depends on. Also includes the plugins
  255
+  subdirectory. If the app has frozen rails, those gems also go here, under
  256
+  vendor/rails/. This directory is in the load path.
7  Rakefile
... ...
@@ -0,0 +1,7 @@
  1
+#!/usr/bin/env rake
  2
+# Add your own tasks in files placed in lib/tasks ending in .rake,
  3
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
  4
+
  5
+require File.expand_path('../config/application', __FILE__)
  6
+
  7
+PaypalExpressSample::Application.load_tasks
BIN  app/assets/images/.DS_Store
Binary file not shown
BIN  app/assets/images/money.png
BIN  app/assets/images/rails.png
6  app/assets/javascripts/application.js
... ...
@@ -0,0 +1,6 @@
  1
+// FIXME: Tell people that this is a manifest file, real code should go into discrete files
  2
+// FIXME: Tell people how Sprockets and CoffeeScript works
  3
+//
  4
+//= require jquery
  5
+//= require jquery_ujs
  6
+//= require_tree .
3  app/assets/javascripts/payments.js.coffee
... ...
@@ -0,0 +1,3 @@
  1
+# Place all the behaviors and hooks related to the matching controller here.
  2
+# All this logic will automatically be available in application.js.
  3
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3  app/assets/javascripts/top.js.coffee
... ...
@@ -0,0 +1,3 @@
  1
+# Place all the behaviors and hooks related to the matching controller here.
  2
+# All this logic will automatically be available in application.js.
  3
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
50  app/assets/stylesheets/application.css
... ...
@@ -0,0 +1,50 @@
  1
+/*
  2
+ * FIXME: Introduce SCSS & Sprockets
  3
+ *= require_self
  4
+ *= require_tree . 
  5
+*/
  6
+
  7
+body > header {
  8
+  position: relative;
  9
+}
  10
+body > header h1 {
  11
+  font-size: 26px;
  12
+  font-weight: normal;
  13
+  line-height: 33px;
  14
+}
  15
+body > header p {
  16
+  color: #616161;
  17
+}
  18
+body > header .money {
  19
+  opacity: 0.6;
  20
+}
  21
+body > header figure {
  22
+  width: 100%;
  23
+  height: 150px;
  24
+  margin: 25px 0;
  25
+  overflow: hidden;
  26
+  border-radius: 6px;
  27
+}
  28
+
  29
+body > footer {
  30
+  color: #666;
  31
+  font-size: 13px;
  32
+  text-align: right;
  33
+  margin-top: 20px;
  34
+  padding-top: 10px;
  35
+  border-top: 1px solid #ccc;
  36
+}
  37
+body > footer a {
  38
+  color: #666;
  39
+  text-decoration: none;
  40
+}
  41
+body > footer a:hover {
  42
+  color: #333;
  43
+}
  44
+body > footer ul {
  45
+  list-style: none;
  46
+}
  47
+body > footer li {
  48
+  display: inline-block;
  49
+  padding-left: 15px;
  50
+}
10  app/assets/stylesheets/box.css.scss
... ...
@@ -0,0 +1,10 @@
  1
+.boxes {
  2
+  display: -webkit-box;
  3
+  display: -moz-box;
  4
+}
  5
+
  6
+@media only screen and (max-width: 767px) {
  7
+  .boxes {
  8
+    display: block;
  9
+  }
  10
+}
167  app/assets/stylesheets/lessframework.css
... ...
@@ -0,0 +1,167 @@
  1
+/*	Less Framework 4
  2
+	http://lessframework.com
  3
+	by Joni Korpi
  4
+	License: http://creativecommons.org/licenses/MIT/	*/
  5
+
  6
+
  7
+/*	Resets
  8
+	------	*/
  9
+
  10
+html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, 
  11
+p, blockquote, pre, a, abbr, address, cite, code, del, dfn, em, 
  12
+img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, hr, 
  13
+dl, dt, dd, ol, ul, li, fieldset, form, label, legend, 
  14
+table, caption, tbody, tfoot, thead, tr, th, td,
  15
+article, aside, canvas, details, figure, figcaption, hgroup, 
  16
+menu, footer, header, nav, section, summary, time, mark, audio, video {
  17
+	margin: 0;
  18
+	padding: 0;
  19
+	border: 0;
  20
+}
  21
+
  22
+article, aside, canvas, figure, figure img, figcaption, hgroup,
  23
+footer, header, nav, section, audio, video {
  24
+	display: block;
  25
+}
  26
+
  27
+a img {border: 0;}
  28
+
  29
+
  30
+
  31
+/*	Typography presets
  32
+	------------------	*/
  33
+
  34
+.gigantic {
  35
+	font-size: 110px;
  36
+	line-height: 120px;
  37
+	letter-spacing: -2px;
  38
+}
  39
+
  40
+.huge, h1 {
  41
+	font-size: 36px;
  42
+	line-height: 42px;
  43
+	letter-spacing: -1px;
  44
+}
  45
+
  46
+.large, h2 {
  47
+	font-size: 22px;
  48
+	line-height: 30px;
  49
+}
  50
+
  51
+.bigger, h3 {
  52
+	font-size: 20px;
  53
+	line-height: 28px;
  54
+}
  55
+
  56
+.big, h4 {
  57
+	font-size: 18px;
  58
+	line-height: 26px;
  59
+}
  60
+
  61
+body {
  62
+	font: 16px/24px Georgia, serif;
  63
+}
  64
+
  65
+.small, small {
  66
+	font-size: 13px;
  67
+	line-height: 18px;
  68
+}
  69
+
  70
+/* Selection colours (easy to forget) */
  71
+
  72
+::selection 	 	{background: rgb(255,255,158);}
  73
+::-moz-selection 	{background: rgb(255,255,158);}
  74
+img::selection 		{background: transparent;}
  75
+img::-moz-selection	{background: transparent;}
  76
+body {-webkit-tap-highlight-color: rgb(255,255,158);}
  77
+
  78
+
  79
+
  80
+/*		Default Layout: 992px. 
  81
+		Gutters: 24px.
  82
+		Outer margins: 48px.
  83
+		Leftover space for scrollbars @1024px: 32px.
  84
+-------------------------------------------------------------------------------
  85
+cols    1     2      3      4      5      6      7      8      9      10
  86
+px      68    160    252    344    436    528    620    712    804    896    */
  87
+
  88
+body {
  89
+	width: 896px;
  90
+	margin: 0 auto;
  91
+	padding: 72px 48px 84px;
  92
+	background: rgb(232,232,232);
  93
+	color: rgb(60,60,60);
  94
+	-webkit-text-size-adjust: 100%; /* Stops Mobile Safari from auto-adjusting font-sizes */
  95
+}
  96
+
  97
+
  98
+
  99
+/*		Tablet Layout: 768px.
  100
+		Gutters: 24px.
  101
+		Outer margins: 28px.
  102
+		Inherits styles from: Default Layout.
  103
+-----------------------------------------------------------------
  104
+cols    1     2      3      4      5      6      7      8
  105
+px      68    160    252    344    436    528    620    712    */
  106
+
  107
+@media only screen and (min-width: 768px) and (max-width: 991px) {
  108
+	
  109
+	body {
  110
+		width: 712px;
  111
+		padding: 48px 28px 60px;
  112
+	}
  113
+}
  114
+
  115
+
  116
+
  117
+/*		Mobile Layout: 320px.
  118
+		Gutters: 24px.
  119
+		Outer margins: 34px.
  120
+		Inherits styles from: Default Layout.
  121
+---------------------------------------------
  122
+cols    1     2      3
  123
+px      68    160    252    */
  124
+
  125
+@media only screen and (max-width: 767px) {
  126
+	
  127
+	body {
  128
+		width: 252px;
  129
+		padding: 48px 34px 60px;
  130
+	}
  131
+	
  132
+}
  133
+
  134
+
  135
+
  136
+/*		Wide Mobile Layout: 480px.
  137
+		Gutters: 24px.
  138
+		Outer margins: 22px.
  139
+		Inherits styles from: Default Layout, Mobile Layout.
  140
+------------------------------------------------------------
  141
+cols    1     2      3      4      5
  142
+px      68    160    252    344    436    */
  143
+
  144
+@media only screen and (min-width: 480px) and (max-width: 767px) {
  145
+	
  146
+	body {
  147
+		width: 436px;
  148
+		padding: 36px 22px 48px;
  149
+	}
  150
+	
  151
+}
  152
+
  153
+
  154
+/*	Retina media query.
  155
+	Overrides styles for devices with a 
  156
+	device-pixel-ratio of 2+, such as iPhone 4.
  157
+-----------------------------------------------    */
  158
+
  159
+@media 
  160
+	only screen and (-webkit-min-device-pixel-ratio: 2),
  161
+	only screen and (min-device-pixel-ratio: 2) {
  162
+	
  163
+	body {
  164
+	
  165
+	}
  166
+	
  167
+}
5  app/assets/stylesheets/payments.css.scss
... ...
@@ -0,0 +1,5 @@
  1
+/* 
  2
+  Place all the styles related to the matching controller here.
  3
+  They will automatically be included in application.css.
  4
+  You can use Sass (SCSS) here: http://sass-lang.com/
  5
+*/
38  app/assets/stylesheets/top.css.scss
... ...
@@ -0,0 +1,38 @@
  1
+/* 
  2
+  Place all the styles related to the matching controller here.
  3
+  They will automatically be included in application.css.
  4
+  You can use Sass (SCSS) here: http://sass-lang.com/
  5
+*/
  6
+
  7
+.top section {
  8
+  margin: 20px 0;
  9
+}
  10
+.top article {
  11
+  width: 44%;
  12
+  opacity: 0.6;
  13
+  margin: 1%;
  14
+  padding: 2%;
  15
+  border: 1px solid #ddd;
  16
+  border-radius: 6px;
  17
+}
  18
+.top article:hover {
  19
+  opacity: 1;
  20
+  background: #ddd;
  21
+  border: 1px solid #ccc;
  22
+}
  23
+.top article form {
  24
+  text-align: right;
  25
+}
  26
+.top article input[type=submit] {
  27
+  text-indent: -9999px;
  28
+  width: 150px;
  29
+  height: 33px;
  30
+  border: none;
  31
+  background: url(https://www.paypal.com/en_US/i/btn/btn_dg_pay_w_paypal.gif);
  32
+}
  33
+
  34
+@media only screen and (max-width: 767px) {
  35
+  .top article {
  36
+    width: 94%;
  37
+  }
  38
+}
3  app/controllers/application_controller.rb
... ...
@@ -0,0 +1,3 @@
  1
+class ApplicationController < ActionController::Base
  2
+  protect_from_forgery
  3
+end
6  app/controllers/payments_controller.rb
... ...
@@ -0,0 +1,6 @@
  1
+class PaymentsController < ApplicationController
  2
+  def create
  3
+    payment = Payment.create! params[:payment]
  4
+    redirect_to root_url
  5
+  end
  6
+end
4  app/controllers/top_controller.rb
... ...
@@ -0,0 +1,4 @@
  1
+class TopController < ApplicationController
  2
+  def index
  3
+  end
  4
+end
2  app/helpers/application_helper.rb
... ...
@@ -0,0 +1,2 @@
  1
+module ApplicationHelper
  2
+end
2  app/helpers/payments_helper.rb
... ...
@@ -0,0 +1,2 @@
  1
+module PaymentsHelper
  2
+end
2  app/helpers/top_helper.rb
... ...
@@ -0,0 +1,2 @@
  1
+module TopHelper
  2
+end
0  app/mailers/.gitkeep
No changes.
0  app/models/.gitkeep
No changes.
6  app/models/payment.rb
... ...
@@ -0,0 +1,6 @@
  1
+class Payment < ActiveRecord::Base
  2
+  scope :instant,   where(payment_type: 'instant')
  3
+  scope :recurring, where(payment_type: 'recurring')
  4
+  scope :real,      where(goods_type: 'real')
  5
+  scope :digital,   where(goods_type: 'digital')
  6
+end
6  app/views/layouts/_footer.html.erb
... ...
@@ -0,0 +1,6 @@
9  app/views/layouts/_header.html.erb
... ...
@@ -0,0 +1,9 @@
  1
+<header id="masthead">
  2
+  <h1><%= t 'title' %></h1>
  3
+  <p><%= t 'description' %></p>
  4
+  <div class="money">
  5
+    <figure>
  6
+      <%= image_tag 'money.png' %>
  7
+    </figure>
  8
+  </div>
  9
+</header>
21  app/views/layouts/application.html.erb
... ...
@@ -0,0 +1,21 @@
  1
+<!DOCTYPE html>
  2
+<html>
  3
+<head>
  4
+  <meta charset="utf-8"/>
  5
+  <title><%= t 'title' %></title>
  6
+  <!--[if lt IE 9]>
  7
+    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
  8
+  <![endif]-->
  9
+  <%= stylesheet_link_tag 'application' %>
  10
+  <%= javascript_include_tag 'application' %>
  11
+  <%= csrf_meta_tags %>
  12
+  <meta name="viewport" content="width=device-width, initial-scale=1"/>
  13
+</head>
  14
+<body>
  15
+  <%= render 'layouts/header' %>
  16
+  <%= content_tag :section, class: params.values_at(:controller, :action).join(' ') do %>
  17
+    <%= yield %>
  18
+  <% end %>
  19
+  <%= render 'layouts/footer' %>
  20
+</body>
  21
+</html>
5  app/views/payments/_form.html.erb
... ...
@@ -0,0 +1,5 @@
  1
+<%= form_for payment do |f| %>
  2
+  <%= f.hidden_field :goods_type %>
  3
+  <%= f.hidden_field :payment_type %>
  4
+  <%= f.submit 'Pay' %>
  5
+<% end %>
52  app/views/top/index.html.erb
... ...
@@ -0,0 +1,52 @@
  1
+<h1><%= t 'top.title' %></h1>
  2
+
  3
+<section>
  4
+  <h2><%= t 'payment_types.real_goods.title'%></h2>
  5
+  <p><%= t 'payment_types.real_goods.description' %></p>
  6
+  <div class="boxes">
  7
+    <article>
  8
+      <h3><%= t 'payment_types.instant.title' %></h3>
  9
+      <p><%= t 'payment_types.instant.description' %></p>
  10
+      <%= render 'payments/form', :payment => Payment.instant.real.build %>
  11
+    </article>
  12
+    <article>
  13
+      <h3><%= t 'payment_types.recurring.title' %></h3>
  14
+      <p><%= t 'payment_types.recurring.description' %></p>
  15
+      <%= render 'payments/form', :payment => Payment.recurring.real.build %>
  16
+    </article>
  17
+  </div>
  18
+</section>
  19
+
  20
+<section>
  21
+  <h2><%= t 'payment_types.digital_goods.redirect.title'%></h2>
  22
+  <p><%= t 'payment_types.digital_goods.redirect.description' %></p>
  23
+  <div class="boxes">
  24
+    <article>
  25
+      <h3><%= t 'payment_types.instant.title' %></h3>
  26
+      <p><%= t 'payment_types.instant.description' %></p>
  27
+      <%= render 'payments/form', :payment => Payment.instant.digital.build %>
  28
+    </article>
  29
+    <article>
  30
+      <h3><%= t 'payment_types.recurring.title' %></h3>
  31
+      <p><%= t 'payment_types.recurring.description' %></p>
  32
+      <%= render 'payments/form', :payment => Payment.recurring.digital.build %>
  33
+    </article>
  34
+  </div>
  35
+</section>
  36
+
  37
+<section>
  38
+  <h2><%= t 'payment_types.digital_goods.incontext.title'%></h2>
  39
+  <p><%= t 'payment_types.digital_goods.incontext.description' %></p>
  40
+  <div class="boxes">
  41
+    <article>
  42
+      <h3><%= t 'payment_types.instant.title' %></h3>
  43
+      <p><%= t 'payment_types.instant.description' %></p>
  44
+      <%= render 'payments/form', :payment => Payment.instant.digital.build %>
  45
+    </article>
  46
+    <article>
  47
+      <h3><%= t 'payment_types.recurring.title' %></h3>
  48
+      <p><%= t 'payment_types.recurring.description' %></p>
  49
+      <%= render 'payments/form', :payment => Payment.recurring.digital.build %>
  50
+    </article>
  51
+  </div>
  52
+</section>
4  config.ru
... ...
@@ -0,0 +1,4 @@
  1
+# This file is used by Rack-based servers to start the application.
  2
+
  3
+require ::File.expand_path('../config/environment',  __FILE__)
  4
+run PaypalExpressSample::Application
53  config/application.rb
... ...
@@ -0,0 +1,53 @@
  1
+require File.expand_path('../boot', __FILE__)
  2
+
  3
+require 'rails/all'
  4
+
  5
+# If you have a Gemfile, require the gems listed there, including any gems
  6
+# you've limited to :test, :development, or :production.
  7
+Bundler.require(:default, Rails.env) if defined?(Bundler)
  8
+
  9
+module PaypalExpressSample
  10
+  class Application < Rails::Application
  11
+    # Settings in config/environments/* take precedence over those specified here.
  12
+    # Application configuration should go into files in config/initializers
  13
+    # -- all .rb files in that directory are automatically loaded.
  14
+
  15
+    # Custom directories with classes and modules you want to be autoloadable.
  16
+    # config.autoload_paths += %W(#{config.root}/extras)
  17
+
  18
+    # Only load the plugins named here, in the order given (default is alphabetical).
  19
+    # :all can be used as a placeholder for all plugins not explicitly named.
  20
+    # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
  21
+
  22
+    # Activate observers that should always be running.
  23
+    # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
  24
+
  25
+    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
  26
+    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
  27
+    # config.time_zone = 'Central Time (US & Canada)'
  28
+
  29
+    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
  30
+    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
  31
+    # config.i18n.default_locale = :de
  32
+
  33
+    # Please note that JavaScript expansions are *ignored altogether* if the asset
  34
+    # pipeline is enabled (see config.assets.enabled below). Put your defaults in
  35
+    # app/assets/javascripts/application.js in that case.
  36
+    #
  37
+    # JavaScript files you want as :defaults (application.js is always included).
  38
+    # config.action_view.javascript_expansions[:defaults] = %w(prototype prototype_ujs)
  39
+
  40
+
  41
+    # Configure the default encoding used in templates for Ruby 1.9.
  42
+    config.encoding = "utf-8"
  43
+
  44
+    # Configure sensitive parameters which will be filtered from the log file.
  45
+    config.filter_parameters += [:password]
  46
+
  47
+    # Enable IdentityMap for Active Record, to disable set to false or remove the line below.
  48
+    config.active_record.identity_map = true
  49
+
  50
+    # Enable the asset pipeline
  51
+    config.assets.enabled = true
  52
+  end
  53
+end
6  config/boot.rb
... ...
@@ -0,0 +1,6 @@
  1
+require 'rubygems'
  2
+
  3
+# Set up gems listed in the Gemfile.
  4
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
  5
+
  6
+require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
22  config/database.yml
... ...
@@ -0,0 +1,22 @@
  1
+# SQLite version 3.x
  2
+#   gem install sqlite3
  3
+development:
  4
+  adapter: sqlite3
  5
+  database: db/development.sqlite3
  6
+  pool: 5
  7
+  timeout: 5000
  8
+
  9
+# Warning: The database defined as "test" will be erased and
  10
+# re-generated from your development database when you run "rake".
  11
+# Do not set this db to the same as development or production.
  12
+test:
  13
+  adapter: sqlite3
  14
+  database: db/test.sqlite3
  15
+  pool: 5
  16
+  timeout: 5000
  17
+
  18
+production:
  19
+  adapter: sqlite3
  20
+  database: db/production.sqlite3
  21
+  pool: 5
  22
+  timeout: 5000
5  config/environment.rb
... ...
@@ -0,0 +1,5 @@
  1
+# Load the rails application
  2
+require File.expand_path('../application', __FILE__)
  3
+
  4
+# Initialize the rails application
  5
+PaypalExpressSample::Application.initialize!
25  config/environments/development.rb
... ...
@@ -0,0 +1,25 @@
  1
+PaypalExpressSample::Application.configure do
  2
+  # Settings specified here will take precedence over those in config/application.rb
  3
+
  4
+  # In the development environment your application's code is reloaded on
  5
+  # every request.  This slows down response time but is perfect for development
  6
+  # since you don't have to restart the web server when you make code changes.
  7
+  config.cache_classes = false
  8
+
  9
+  # Log error messages when you accidentally call methods on nil.
  10
+  config.whiny_nils = true
  11
+
  12
+  # Show full error reports and disable caching
  13
+  config.consider_all_requests_local       = true
  14
+  config.action_controller.perform_caching = false
  15
+
  16
+  # Don't care if the mailer can't send
  17
+  config.action_mailer.raise_delivery_errors = false
  18
+
  19
+  # Print deprecation notices to the Rails logger
  20
+  config.active_support.deprecation = :log
  21
+
  22
+  # Only use best-standards-support built into browsers
  23
+  config.action_dispatch.best_standards_support = :builtin
  24
+end
  25
+
52  config/environments/production.rb
... ...
@@ -0,0 +1,52 @@
  1
+PaypalExpressSample::Application.configure do
  2
+  # Settings specified here will take precedence over those in config/application.rb
  3
+
  4
+  # Code is not reloaded between requests
  5
+  config.cache_classes = true
  6
+
  7
+  # Full error reports are disabled and caching is turned on
  8
+  config.consider_all_requests_local       = false
  9
+  config.action_controller.perform_caching = true
  10
+
  11
+  # Disable Rails's static asset server (Apache or nginx will already do this)
  12
+  config.serve_static_assets = false
  13
+
  14
+  # Compress both stylesheets and JavaScripts
  15
+  config.assets.js_compressor  = :uglifier
  16
+  config.assets.css_compressor = :scss
  17
+
  18
+  # Specifies the header that your server uses for sending files
  19
+  # (comment out if your front-end server doesn't support this)
  20
+  config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx
  21
+
  22
+  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  23
+  # config.force_ssl = true
  24
+
  25
+  # See everything in the log (default is :info)
  26
+  # config.log_level = :debug
  27
+
  28
+  # Use a different logger for distributed setups
  29
+  # config.logger = SyslogLogger.new
  30
+
  31
+  # Use a different cache store in production
  32
+  # config.cache_store = :mem_cache_store
  33
+
  34
+  # Enable serving of images, stylesheets, and javascripts from an asset server
  35
+  # config.action_controller.asset_host = "http://assets.example.com"
  36
+
  37
+  # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
  38
+  # config.assets.precompile += %w( search.js )
  39
+
  40
+  # Disable delivery errors, bad email addresses will be ignored
  41
+  # config.action_mailer.raise_delivery_errors = false
  42
+
  43
+  # Enable threaded mode
  44
+  # config.threadsafe!
  45
+
  46
+  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  47
+  # the I18n.default_locale when a translation can not be found)
  48
+  config.i18n.fallbacks = true
  49
+
  50
+  # Send deprecation notices to registered listeners
  51
+  config.active_support.deprecation = :notify
  52
+end
39  config/environments/test.rb
... ...
@@ -0,0 +1,39 @@
  1
+PaypalExpressSample::Application.configure do
  2
+  # Settings specified here will take precedence over those in config/application.rb
  3
+
  4
+  # The test environment is used exclusively to run your application's
  5
+  # test suite.  You never need to work with it otherwise.  Remember that
  6
+  # your test database is "scratch space" for the test suite and is wiped
  7
+  # and recreated between test runs.  Don't rely on the data there!
  8
+  config.cache_classes = true
  9
+
  10
+  # Configure static asset server for tests with Cache-Control for performance
  11
+  config.serve_static_assets = true
  12
+  config.static_cache_control = "public, max-age=3600"
  13
+
  14
+  # Log error messages when you accidentally call methods on nil
  15
+  config.whiny_nils = true
  16
+
  17
+  # Show full error reports and disable caching
  18
+  config.consider_all_requests_local       = true
  19
+  config.action_controller.perform_caching = false
  20
+
  21
+  # Raise exceptions instead of rendering exception templates
  22
+  config.action_dispatch.show_exceptions = false
  23
+
  24
+  # Disable request forgery protection in test environment
  25
+  config.action_controller.allow_forgery_protection    = false
  26
+
  27
+  # Tell Action Mailer not to deliver emails to the real world.
  28
+  # The :test delivery method accumulates sent emails in the
  29
+  # ActionMailer::Base.deliveries array.
  30
+  config.action_mailer.delivery_method = :test
  31
+
  32
+  # Use SQL instead of Active Record's schema dumper when creating the test database.
  33
+  # This is necessary if your schema can't be completely dumped by the schema dumper,
  34
+  # like if you have constraints or database-specific column types
  35
+  # config.active_record.schema_format = :sql
  36
+
  37
+  # Print deprecation notices to the stderr
  38
+  config.active_support.deprecation = :stderr
  39
+end
7  config/initializers/backtrace_silencers.rb
... ...
@@ -0,0 +1,7 @@
  1
+# Be sure to restart your server when you modify this file.
  2
+
  3
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
  4
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
  5
+
  6
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
  7
+# Rails.backtrace_cleaner.remove_silencers!
10  config/initializers/inflections.rb
... ...
@@ -0,0 +1,10 @@
  1
+# Be sure to restart your server when you modify this file.
  2
+
  3
+# Add new inflection rules using the following format
  4
+# (all these examples are active by default):
  5
+# ActiveSupport::Inflector.inflections do |inflect|
  6
+#   inflect.plural /^(ox)$/i, '\1en'
  7
+#   inflect.singular /^(ox)en/i, '\1'
  8
+#   inflect.irregular 'person', 'people'
  9
+#   inflect.uncountable %w( fish sheep )
  10
+# end
5  config/initializers/mime_types.rb
... ...
@@ -0,0 +1,5 @@
  1
+# Be sure to restart your server when you modify this file.
  2
+
  3
+# Add new mime types for use in respond_to blocks:
  4
+# Mime::Type.register "text/richtext", :rtf
  5
+# Mime::Type.register_alias "text/html", :iphone
7  config/initializers/secret_token.rb
... ...
@@ -0,0 +1,7 @@
  1
+# Be sure to restart your server when you modify this file.
  2
+
  3
+# Your secret key for verifying the integrity of signed cookies.
  4
+# If you change this key, all old signed cookies will become invalid!
  5
+# Make sure the secret is at least 30 characters and all random,
  6
+# no regular words or you'll be exposed to dictionary attacks.
  7
+PaypalExpressSample::Application.config.secret_token = 'f343b9bd7a9d3033ae485d73f440fee491b9127c90b529379110e3431fff26e35d2fc621a508b82281ec55a62e67b9c5b2192c0c8c9b74f2db17576c9ca1ff4a'
8  config/initializers/session_store.rb
... ...
@@ -0,0 +1,8 @@
  1
+# Be sure to restart your server when you modify this file.
  2
+
  3
+PaypalExpressSample::Application.config.session_store :cookie_store, key: '_paypal-express-sample_session'
  4
+
  5
+# Use the database for sessions instead of the cookie-based default,
  6
+# which shouldn't be used to store highly confidential information
  7
+# (create the session table with "rails generate session_migration")
  8
+# PaypalExpressSample::Application.config.session_store :active_record_store
12  config/initializers/wrap_parameters.rb
... ...
@@ -0,0 +1,12 @@
  1
+# Be sure to restart your server when you modify this file.
  2
+#
  3
+# This file contains the settings for ActionController::ParametersWrapper
  4
+# which will be enabled by default in the upcoming version of Ruby on Rails.
  5
+
  6
+# Enable parameter wrapping for JSON. You can disable this by set :format to empty array.
  7
+ActionController::Base.wrap_parameters :format => [:json]
  8
+
  9
+# Disable root element in JSON by default.
  10
+if defined?(ActiveRecord)