ecommerce 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +96 -0
- data/README +256 -0
- data/Rakefile +7 -0
- data/app/controllers/application_controller.rb +6 -0
- data/app/controllers/cart_controller.rb +42 -0
- data/app/controllers/ecommerce_controller.rb +5 -0
- data/app/controllers/payment_notifications_controller.rb +80 -0
- data/app/controllers/photos_controller.rb +19 -0
- data/app/controllers/products_controller.rb +35 -0
- data/app/helpers/application_helper.rb +3 -0
- data/app/helpers/products_helper.rb +8 -0
- data/app/models/cart.rb +108 -0
- data/app/models/cart_item.rb +39 -0
- data/app/models/photo.rb +21 -0
- data/app/models/product.rb +29 -0
- data/app/views/cart/index.haml +80 -0
- data/app/views/layouts/application.html.erb +14 -0
- data/app/views/products/_form.html.haml +45 -0
- data/app/views/products/edit.html.haml +5 -0
- data/app/views/products/index.html.haml +17 -0
- data/app/views/products/new.html.haml +4 -0
- data/app/views/products/show.haml +28 -0
- data/app/views/products/show/_photos.haml +13 -0
- data/config.ru +4 -0
- data/config/application.rb +43 -0
- data/config/boot.rb +13 -0
- data/config/database.yml +22 -0
- data/config/ecommerce.yml +16 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +26 -0
- data/config/environments/production.rb +49 -0
- data/config/environments/test.rb +35 -0
- data/config/initializers/ecommerce-config.rb +7 -0
- data/config/initializers/mime_types.rb +6 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +23 -0
- data/db/seeds.rb +7 -0
- data/doc/README_FOR_APP +2 -0
- data/ecommerce-0.0.1.gem +0 -0
- data/ecommerce.gemspec +24 -0
- data/lib/ecommerce.rb +4 -0
- data/lib/ecommerce/ecommerce.rb +5 -0
- data/lib/ecommerce/engine.rb +25 -0
- data/lib/ecommerce/version.rb +3 -0
- data/lib/generators/ecommerce/USAGE +4 -0
- data/lib/generators/ecommerce/ecommerce_generator.rb +30 -0
- data/lib/generators/ecommerce/templates/migration.rb +59 -0
- data/lib/tasks/.gitkeep +0 -0
- data/models/payment_notification.rb +15 -0
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +26 -0
- data/public/favicon.ico +0 -0
- data/public/javascripts/ecommerce.js +10 -0
- data/public/robots.txt +5 -0
- data/public/stylesheets/.gitkeep +0 -0
- data/script/rails +6 -0
- data/spec/spec_helper.rb +27 -0
- data/test/performance/browsing_test.rb +9 -0
- data/test/test_helper.rb +13 -0
- data/vendor/plugins/.gitkeep +0 -0
- metadata +160 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
class CreateEcommerceTables < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
|
4
|
+
# Products
|
5
|
+
create_table :products do |t|
|
6
|
+
t.string :name, :null => false
|
7
|
+
t.string :permalink, :null => false
|
8
|
+
t.text :descr
|
9
|
+
t.column :price, :decimal, :precision => 8, :scale => 2, :default => 0
|
10
|
+
t.column :sale_price, :decimal, :precision => 8, :scale => 2, :default => 0
|
11
|
+
t.text :meta_description
|
12
|
+
t.text :meta_keywords
|
13
|
+
t.string :tags
|
14
|
+
t.int :shipping_weight
|
15
|
+
t.timestamps
|
16
|
+
end
|
17
|
+
|
18
|
+
# Each product has_many :photos
|
19
|
+
create_table :photos do |t|
|
20
|
+
t.integer :product_id
|
21
|
+
t.string :photo_file_name
|
22
|
+
t.string :photo_content_type
|
23
|
+
t.integer :photo_file_size
|
24
|
+
t.datetime :photo_updated_at
|
25
|
+
t.timestamps
|
26
|
+
end
|
27
|
+
|
28
|
+
create_table :carts do |t|
|
29
|
+
t.datetime :purchased_at
|
30
|
+
t.timestamps
|
31
|
+
end
|
32
|
+
|
33
|
+
create_table :cart_items do |t|
|
34
|
+
t.integer :cart_id
|
35
|
+
t.integer :product_id
|
36
|
+
t.integer :quantity
|
37
|
+
end
|
38
|
+
|
39
|
+
# PayPal -- how they let us know when a payment has cleared
|
40
|
+
create_table :payment_notifications do |t|
|
41
|
+
t.text :params
|
42
|
+
t.integer :cart_id
|
43
|
+
t.string :status
|
44
|
+
t.string :transaction_id
|
45
|
+
t.timestamps
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.down
|
51
|
+
drop_table :products
|
52
|
+
drop_table :photos
|
53
|
+
drop_table :carts
|
54
|
+
drop_table :cart_items
|
55
|
+
drop_table :payment_notifications
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
data/lib/tasks/.gitkeep
ADDED
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class PaymentNotification < ActiveRecord::Base
|
2
|
+
attr_accessible :params, :cart_id, :status, :transaction_id
|
3
|
+
|
4
|
+
belongs_to :cart
|
5
|
+
|
6
|
+
# convert params object to yaml when putting into the db and a hash when it comes out
|
7
|
+
serialize :params
|
8
|
+
|
9
|
+
after_create :set_purchase_date
|
10
|
+
|
11
|
+
# checks to make sure this is valid are done in the payment_notification_controller.create()
|
12
|
+
def set_purchase_date
|
13
|
+
cart.update_attribute(:purchased_at, Time.now)
|
14
|
+
end
|
15
|
+
end
|
data/public/404.html
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
data/public/422.html
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
data/public/500.html
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
data/public/favicon.ico
ADDED
File without changes
|
data/public/robots.txt
ADDED
File without changes
|
data/script/rails
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require File.expand_path("../../config/environment", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
|
6
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
7
|
+
# in spec/support/ and its subdirectories.
|
8
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
# == Mock Framework
|
12
|
+
#
|
13
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
14
|
+
#
|
15
|
+
# config.mock_with :mocha
|
16
|
+
# config.mock_with :flexmock
|
17
|
+
# config.mock_with :rr
|
18
|
+
config.mock_with :rspec
|
19
|
+
|
20
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
21
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
22
|
+
|
23
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
24
|
+
# examples within a transaction, remove the following line or assign false
|
25
|
+
# instead of true.
|
26
|
+
config.use_transactional_fixtures = true
|
27
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
3
|
+
require 'rails/test_help'
|
4
|
+
|
5
|
+
class ActiveSupport::TestCase
|
6
|
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
7
|
+
#
|
8
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
9
|
+
# -- they do not yet inherit this setting
|
10
|
+
fixtures :all
|
11
|
+
|
12
|
+
# Add more helper methods to be used by all tests here...
|
13
|
+
end
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ecommerce
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Jason Younker
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-03 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rails
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
description: Very simple ecommerce framework including products table, cart (and cart items) and paypal checkout
|
50
|
+
email:
|
51
|
+
- jason@ynkr.org
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
58
|
+
files:
|
59
|
+
- .gitignore
|
60
|
+
- .rspec
|
61
|
+
- Gemfile
|
62
|
+
- Gemfile.lock
|
63
|
+
- README
|
64
|
+
- Rakefile
|
65
|
+
- app/controllers/application_controller.rb
|
66
|
+
- app/controllers/cart_controller.rb
|
67
|
+
- app/controllers/ecommerce_controller.rb
|
68
|
+
- app/controllers/payment_notifications_controller.rb
|
69
|
+
- app/controllers/photos_controller.rb
|
70
|
+
- app/controllers/products_controller.rb
|
71
|
+
- app/helpers/application_helper.rb
|
72
|
+
- app/helpers/products_helper.rb
|
73
|
+
- app/models/cart.rb
|
74
|
+
- app/models/cart_item.rb
|
75
|
+
- app/models/photo.rb
|
76
|
+
- app/models/product.rb
|
77
|
+
- app/views/cart/index.haml
|
78
|
+
- app/views/layouts/application.html.erb
|
79
|
+
- app/views/products/_form.html.haml
|
80
|
+
- app/views/products/edit.html.haml
|
81
|
+
- app/views/products/index.html.haml
|
82
|
+
- app/views/products/new.html.haml
|
83
|
+
- app/views/products/show.haml
|
84
|
+
- app/views/products/show/_photos.haml
|
85
|
+
- config.ru
|
86
|
+
- config/application.rb
|
87
|
+
- config/boot.rb
|
88
|
+
- config/database.yml
|
89
|
+
- config/ecommerce.yml
|
90
|
+
- config/environment.rb
|
91
|
+
- config/environments/development.rb
|
92
|
+
- config/environments/production.rb
|
93
|
+
- config/environments/test.rb
|
94
|
+
- config/initializers/ecommerce-config.rb
|
95
|
+
- config/initializers/mime_types.rb
|
96
|
+
- config/locales/en.yml
|
97
|
+
- config/routes.rb
|
98
|
+
- db/seeds.rb
|
99
|
+
- doc/README_FOR_APP
|
100
|
+
- ecommerce-0.0.1.gem
|
101
|
+
- ecommerce.gemspec
|
102
|
+
- lib/ecommerce.rb
|
103
|
+
- lib/ecommerce/ecommerce.rb
|
104
|
+
- lib/ecommerce/engine.rb
|
105
|
+
- lib/ecommerce/version.rb
|
106
|
+
- lib/generators/ecommerce/USAGE
|
107
|
+
- lib/generators/ecommerce/ecommerce_generator.rb
|
108
|
+
- lib/generators/ecommerce/templates/migration.rb
|
109
|
+
- lib/tasks/.gitkeep
|
110
|
+
- models/payment_notification.rb
|
111
|
+
- public/404.html
|
112
|
+
- public/422.html
|
113
|
+
- public/500.html
|
114
|
+
- public/favicon.ico
|
115
|
+
- public/javascripts/ecommerce.js
|
116
|
+
- public/robots.txt
|
117
|
+
- public/stylesheets/.gitkeep
|
118
|
+
- script/rails
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
- test/performance/browsing_test.rb
|
121
|
+
- test/test_helper.rb
|
122
|
+
- vendor/plugins/.gitkeep
|
123
|
+
has_rdoc: true
|
124
|
+
homepage: ""
|
125
|
+
licenses: []
|
126
|
+
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
hash: 3
|
138
|
+
segments:
|
139
|
+
- 0
|
140
|
+
version: "0"
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
hash: 3
|
147
|
+
segments:
|
148
|
+
- 0
|
149
|
+
version: "0"
|
150
|
+
requirements: []
|
151
|
+
|
152
|
+
rubyforge_project: ecommerce
|
153
|
+
rubygems_version: 1.6.2
|
154
|
+
signing_key:
|
155
|
+
specification_version: 3
|
156
|
+
summary: Very simple ecommerce framework
|
157
|
+
test_files:
|
158
|
+
- spec/spec_helper.rb
|
159
|
+
- test/performance/browsing_test.rb
|
160
|
+
- test/test_helper.rb
|