Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb Perkins committed Jan 14, 2012
0 parents commit 395e764
Show file tree
Hide file tree
Showing 628 changed files with 18,990 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.bundle
db/*.sqlite3
log/resque_worker.*
log/*.log*
log/*.db
tmp/
dump.rdb
.DS_Store
public/assets/
public/system/
public/uploads/
1 change: 1 addition & 0 deletions .rbenv-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.9.3-p0
1 change: 1 addition & 0 deletions .rvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rvm 1.9.2
4 changes: 4 additions & 0 deletions Capfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }

load 'config/deploy' # remove this line to skip loading any of the default tasks
42 changes: 42 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
source 'http://rubygems.org'
source 'http://gems.github.com'

gem 'rails', '3.0.9'
gem 'jquery-rails'
gem 'capistrano', group: :development
gem 'haml'
gem 'will_paginate', '>=3.0.pre2'
gem "state_machine", '>=0.9.4'
gem 'authlogic'
gem "activemerchant"
gem "money"
gem "recaptcha", require: "recaptcha/rails"
gem "tabs_on_rails", ">=1.3.1"
gem "bartt-ssl_requirement", require: 'ssl_requirement'
gem "jammit"
gem 'spectator-validates_email', require: 'validates_email'

# Image processing. Currently there is an issue with Ruby ReadLine so we use a custom ImageScience.
gem 'carrierwave'
gem 'image_science', git: "git://github.com/asynchrony/image_science.git"

gem 'gibbon', group: :production

# Caching
gem 'redis'
gem 'redis-store', '>=1.0.0.beta4'

# Background jobs
gem 'stalker'
gem 'daemon-spawn'
gem "whenever"

# Database
gem 'sqlite3-ruby', require: 'sqlite3', group: [:development, :test]
gem "mysql2", "~> 0.2.7", group: [:production, :staging]

# Testing and monitoring
gem "factory_girl_rails", group: [:test, :development]
gem "timecop", group: :test
gem "newrelic_rpm", ">= 3.1.0"
gem 'hoptoad_notifier'
192 changes: 192 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
GIT
remote: git://github.com/asynchrony/image_science.git
revision: d33dbad3efaef4ddc3785e135be4006f9e80d2d9
specs:
image_science (1.3.2.1.Asynchrony)

GEM
remote: http://rubygems.org/
remote: http://gems.github.com/
specs:
POpen4 (0.1.4)
Platform (>= 0.4.0)
open4
Platform (0.4.0)
aaronh-chronic (0.3.9)
abstract (1.0.0)
actionmailer (3.0.9)
actionpack (= 3.0.9)
mail (~> 2.2.19)
actionpack (3.0.9)
activemodel (= 3.0.9)
activesupport (= 3.0.9)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
rack (~> 1.2.1)
rack-mount (~> 0.6.14)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemerchant (1.16.0)
activesupport (>= 2.3.11)
braintree (>= 2.0.0)
builder (>= 2.0.0)
json (>= 1.5.1)
activemodel (3.0.9)
activesupport (= 3.0.9)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.9)
activemodel (= 3.0.9)
activesupport (= 3.0.9)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activeresource (3.0.9)
activemodel (= 3.0.9)
activesupport (= 3.0.9)
activesupport (3.0.9)
arel (2.0.10)
authlogic (3.0.3)
activerecord (>= 3.0.7)
activerecord (>= 3.0.7)
bartt-ssl_requirement (1.2.7)
beanstalk-client (1.1.0)
braintree (2.10.1)
builder (>= 2.0.0)
builder (2.1.2)
capistrano (2.6.0)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
carrierwave (0.5.6)
activesupport (~> 3.0)
crack (0.1.8)
daemon-spawn (0.4.2)
erubis (2.6.6)
abstract (>= 1.0.0)
factory_girl (1.3.3)
factory_girl_rails (1.0.1)
factory_girl (~> 1.3)
railties (>= 3.0.0)
gibbon (0.1.7)
activesupport (> 3.0.0)
httparty (> 0.6.0)
json (> 1.4.0)
haml (3.1.2)
highline (1.6.2)
hoptoad_notifier (2.4.11)
activesupport
builder
httparty (0.7.8)
crack (= 0.1.8)
i18n (0.5.0)
jammit (0.6.3)
yui-compressor (>= 0.9.3)
jquery-rails (1.0.12)
railties (~> 3.0)
thor (~> 0.14)
json (1.5.3)
json_pure (1.5.3)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
money (3.7.1)
i18n (~> 0.4)
mysql2 (0.2.11)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.1.4)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
newrelic_rpm (3.1.0)
open4 (1.1.0)
polyglot (0.3.1)
rack (1.2.3)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.9)
actionmailer (= 3.0.9)
actionpack (= 3.0.9)
activerecord (= 3.0.9)
activeresource (= 3.0.9)
activesupport (= 3.0.9)
bundler (~> 1.0)
railties (= 3.0.9)
railties (3.0.9)
actionpack (= 3.0.9)
activesupport (= 3.0.9)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
rake (0.9.2)
rdoc (3.8)
recaptcha (0.3.1)
redis (2.2.1)
redis-store (1.0.0.rc1)
redis (~> 2.2.0)
spectator-validates_email (0.0.7)
actionpack (~> 3.0.0)
activemodel (~> 3.0.0)
sqlite3 (1.3.3)
sqlite3 (1.3.3-x86-mingw32)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
stalker (0.9.0)
beanstalk-client
json_pure
state_machine (1.0.1)
tabs_on_rails (2.0.2)
thor (0.14.6)
timecop (0.3.5)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.29)
whenever (0.6.8)
aaronh-chronic (>= 0.3.9)
activesupport (>= 2.3.4)
will_paginate (3.0.pre2)
yui-compressor (0.9.6)
POpen4 (>= 0.1.4)

PLATFORMS
ruby
x86-mingw32

DEPENDENCIES
activemerchant
authlogic
bartt-ssl_requirement
capistrano
carrierwave
daemon-spawn
factory_girl_rails
gibbon
haml
hoptoad_notifier
image_science!
jammit
jquery-rails
money
mysql2 (~> 0.2.7)
newrelic_rpm (>= 3.1.0)
rails (= 3.0.9)
recaptcha
redis
redis-store (>= 1.0.0.beta4)
spectator-validates_email
sqlite3-ruby
stalker
state_machine (>= 0.9.4)
tabs_on_rails (>= 1.3.1)
timecop
whenever
will_paginate (>= 3.0.pre2)
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
17 changes: 17 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
This is (nearly) all the code that powered FirstBargain.com until it was closed down.

FirstBargain was a penny-auction startup formed by students at Cornell University, founded by Taichi Kasahara and Jing Hui Wang at Cornell University. The Ruby code you see here was written primarily by Caleb Perkins (www.calebperkins.org), also a student. The HAML templates and CSS were written by Jing.

== Server requirements ==
# Redis
# Beanstalkd
# Ruby 1.9.2 or better
# Rails 3 (3.1 or later not supported yet)

Run as you would any Rails app.

== Caveats ==

This code scaled well in production but there should be more test coverage.

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. See the LICENSE for more information.
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

FirstBargain::Application.load_tasks
68 changes: 68 additions & 0 deletions app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
class AccountsController < ApplicationController
ssl_required :new, :create, :edit, :update, :welcome
before_filter :require_user, only: [:show, :edit, :update, :welcome]
before_filter :require_no_user, only: [:new, :create]
set_tab :register, only: [:new, :create]
set_tab :overview, :sidebar, only: :show
set_tab :settings, :sidebar, only: [:edit, :update]

def new
cookies[:referral] = {value: params[:u], expires: 1.week.from_now} if params[:u].present?
@account = Account.new
force_html @account do
render :layout => 'application'
end
end

def create
@account = Account.new params[:account]
@account.registration_ip = request.remote_ip
[:affiliate, :referral, :utm_medium, :utm_source, :utm_campaign, :utm_term, :utm_content].each do |sym|
@account.public_send("#{sym}=", cookies[sym])
end
force_html @account do
if @account.save
cookies.delete :referral
session[:welcome] = true
redirect_to welcome_account_url, notice: t("flash.account.created")
else render "create", :layout => 'application'
end
end
rescue ActiveRecord::RecordNotUnique # database hicupped, account was made
session[:welcome] = true
redirect_to welcome_account_url
rescue ActionController::InvalidAuthenticityToken
Rails.logger.warn "InvalidAuthenticityToken on registration page."
redirect_to new_account_url, alert: t("flash.session.expired_on_registration")
end

def show
@winnings = current_user.winnings
@wins = current_user.wins_this_month.includes(:product)
@buynows = current_user.buynows.paginate(page: params[:page], per_page: 10)
respond_with current_user
end

def edit
respond_with current_user
end

def update
x = current_user.username
if current_user.update_attributes(params[:account]) then flash.notice = t("flash.account.updated")
else current_user.username = x
end
respond_with(current_user, location: account_url)
end

def welcome
if session[:welcome]
@order = BidOrder.new
session.delete :welcome
cookies[:beginner] = 1
render :layout => 'application'
else redirect_to bids_url(:secure => true)
end
end

end
23 changes: 23 additions & 0 deletions app/controllers/activations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class ActivationsController < ApplicationController
before_filter :require_user, only: :create

def new
@account = Account.find_by_single_access_token params[:code]
if not @account then flash.alert = t("flash.activations.account_not_found")
elsif @account.verified? then flash.alert = t("flash.activations.already_verified")
else
@account.activate
flash.notice = t("flash.activations.activated")
end
redirect_to root_url
end

def create
if current_user.verified? then redirect_to root_url, alert: t("flash.activations.already_verified")
else
current_user.deliver_activation_instructions
redirect_to account_path, notice: t("flash.activations.created")
end
end

end
Loading

0 comments on commit 395e764

Please sign in to comment.