Skip to content

Commit

Permalink
Merge branch 'master' of github.com:thogg4/classie
Browse files Browse the repository at this point in the history
Conflicts:
	.gitignore
	Rakefile
	app/controllers/admin_controller.rb
	app/controllers/ads_controller.rb
	app/controllers/application_controller.rb
	app/controllers/cats_controller.rb
	app/controllers/sessions_controller.rb
	app/controllers/sub_cats_controller.rb
	app/controllers/users_controller.rb
	app/helpers/application_helper.rb
	app/models/ad.rb
	app/models/asset.rb
	app/models/cat.rb
	app/models/user.rb
	config/boot.rb
	config/environment.rb
	config/environments/development.rb
	config/environments/production.rb
	config/environments/test.rb
	config/initializers/backtrace_silencers.rb
	config/initializers/inflections.rb
	config/initializers/session_store.rb
	config/locales/en.yml
	config/routes.rb
	db/schema.rb
	db/seeds.rb
	public/404.html
	public/422.html
	public/500.html
	test/fixtures/ads.yml
	test/fixtures/cats.yml
	test/fixtures/users.yml
  • Loading branch information
Tim committed Aug 1, 2013
2 parents 830ebd2 + d4a4f1b commit 4bb5484
Show file tree
Hide file tree
Showing 192 changed files with 6,047 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
Expand All @@ -16,3 +17,10 @@

# Ignore application configuration
/config/application.yml
=======
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a simple classified ads application. Feel free to use it however you want.
13 changes: 13 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
<<<<<<< HEAD
#!/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__)

Classie::Application.load_tasks
=======
# 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.join(File.dirname(__FILE__), 'config', 'boot'))

require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

require 'tasks/rails'
>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
7 changes: 7 additions & 0 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
class AdminController < ApplicationController
<<<<<<< HEAD

def index
@ads = Ad.all

=======
def index
@ads = Ad.all


>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
# for categories
@cats = Cat.find(:all, :order => "position")
@cat = Cat.new
Expand Down
36 changes: 36 additions & 0 deletions app/controllers/ads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ def new
@ad = Ad.new
@cats = Cat.find(:all, :conditions => ["admin is null OR admin = ?", false])
else
<<<<<<< HEAD
redirect_to login_path, notice: "Sign in to create an ad. Don't have an account? Click Sign Up to create one."
=======
session[:return_to] = "new_ad"
redirect_to(login_path)
flash[:notice] = "Sign in to create an ad. Don't have an account? Click Sign Up to create one."
>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
end
end

Expand All @@ -34,6 +40,7 @@ def change_sub_cats_select

respond_to do |wants|
wants.json { render :json => @subcats }
<<<<<<< HEAD
end
end

Expand All @@ -43,6 +50,23 @@ def create
redirect_to user_path(current_user)
else
render :new
=======
end


end

def create
@ad = current_user.ads.build(params[:ad])
@ad.city = current_user.city
@ad.state = current_user.state
@ad.views = 0
if @ad.save
redirect_to(new_user_ad_asset_path(current_user, @ad))
else
flash[:error] = "Something happened and your ad was not saved. Please try again."
redirect_to(username_path(current_user))
>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
end
end

Expand All @@ -53,6 +77,10 @@ def edit
@asset = Asset.new
end

<<<<<<< HEAD
=======

>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
def update
@ad = Ad.find(params[:id])
if @ad.update_attributes(params[:ad])
Expand All @@ -74,5 +102,13 @@ def views
@ad = Ad.find(params[:id])
@ad.increment!(:views)
end
<<<<<<< HEAD

=======





>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
end
19 changes: 19 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
<<<<<<< HEAD
class ApplicationController < ActionController::Base
protect_from_forgery
=======
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details

include AuthenticatedSystem

# Scrub sensitive parameters from your log
# filter_parameter_logging :password

def get_ad_id
@ad = Ad.find(params[:ad_id])
end

>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
end
63 changes: 63 additions & 0 deletions app/controllers/assets_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
class AssetsController < ApplicationController

before_filter :get_ad_id, :except => "show"

def index
@assets = Asset.all
end



#show is my photo viewer page
def show
@image = params[:image]
render :layout => "bare"
end




def new
@asset = Asset.new
@ad = Ad.find(params[:ad_id])
@assets = @ad.assets
end

def create
@asset = Asset.new(params[:asset])
@asset.ad_id = @ad.id
if @asset.save
if params[:commit] == "Add"
flash[:notice] = "Photo added"
redirect_to(edit_user_ad_path(current_user, @ad))
else
flash[:notice] = "Photo added"
redirect_to(new_user_ad_asset_path(current_user, @ad))
end
else
render :action => 'new'
end
end

def edit
@asset = Asset.find(params[:id])
end

def update
@ad = Ad.find(params[:ad_id])
@asset = Asset.find(params[:id])
if @asset.update_attributes(params[:asset])
flash[:notice] = "Successfully updated asset."
redirect_to(edit_user_ad_path(current_user, @ad))
else
render :action => 'edit'
end
end

def destroy
@asset = Asset.find(params[:id])
@asset.destroy
flash[:notice] = "Photo deleted"
redirect_to(edit_user_ad_path(current_user, @ad))
end
end
6 changes: 6 additions & 0 deletions app/controllers/cats_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
class CatsController < ApplicationController
<<<<<<< HEAD

=======
>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
def index
@cats = Cat.all
end
Expand Down Expand Up @@ -34,5 +37,8 @@ def destroy
flash[:notice] = "Successfully destroyed cat."
redirect_to(admin_path)
end
<<<<<<< HEAD

=======
>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
end
53 changes: 53 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
class SessionsController < ApplicationController

def create
Expand All @@ -7,12 +8,64 @@ def create
else
flash[:error] = 'The Email or Password you entered is incorrect'
redirect_to signin_path
=======
# This controller handles the login/logout function of the site.
class SessionsController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem

# render new.erb.html
def new
end

def create
logout_keeping_session!
user = User.authenticate(params[:login], params[:password])
if user
# Protects against session fixation attacks, causes request forgery
# protection if user resubmits an earlier form using back
# button. Uncomment if you understand the tradeoffs.
# reset_session
self.current_user = user
new_cookie_flag = (params[:remember_me] == "1")
handle_remember_cookie! new_cookie_flag

flash[:notice] = "Logged in successfully"
if session[:return_to] == "new_ad"
redirect_to(new_user_ad_path(current_user))
elsif session[:return_to] == "my_ads"
redirect_to(username_path(current_user))
else
redirect_to(root_path)
end
session[:return_to] = nil

else
note_failed_signin
@login = params[:login]
@remember_me = params[:remember_me]
render :action => 'new'
>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
end
end

def destroy
<<<<<<< HEAD
logout
redirect_to root_path, notice: 'Logged Out'
end

=======
logout_killing_session!
flash[:notice] = "You have been logged out."
redirect_back_or_default('/')
end

protected
# Track failed login attempts
def note_failed_signin
flash[:error] = "Couldn't log you in as '#{params[:login]}'"
logger.warn "Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}"
end
>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
end
12 changes: 12 additions & 0 deletions app/controllers/sub_cats_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
class SubCatsController < ApplicationController

<<<<<<< HEAD
=======

>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
def new
@sub_cat = SubCat.new
end
Expand All @@ -9,6 +13,10 @@ def create
@sub_cat = @cat.sub_cats.build(params[:sub_cat])
if @sub_cat.save
redirect_to(admin_path)
<<<<<<< HEAD
=======
else
>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
end
end

Expand All @@ -19,7 +27,11 @@ def prioritize_sub_cats
sub_cat.position = params["sub_cat"].index(sub_cat.id.to_s)
sub_cat.save
end
<<<<<<< HEAD
render :nothing
=======
render :nothing => true
>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
end

def update
Expand Down
31 changes: 31 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
class UsersController < ApplicationController

<<<<<<< HEAD
=======


# render new.rhtml
>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
def new
@user = User.new
end

def create
<<<<<<< HEAD
@user = User.new(params[:user])
if @user.save
auto_login(@user)
Expand All @@ -14,6 +21,22 @@ def create
end
end

=======
logout_keeping_session!
@user = User.new(params[:user])
success = @user && @user.save
if success && @user.errors.empty?
self.current_user = @user # !! now logged in
redirect_to(root_path)
flash[:notice] = "Thanks for signing up!"
else
flash[:error] = "We couldn't set up that account, sorry. Please try again."
render :action => 'new'
end
end


>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
def update
if current_user.update_attributes(params[:user])
current_user.ads.each do |ad|
Expand All @@ -37,5 +60,13 @@ def show
flash[:notice] = "You must sign in before you can see your ads. Don't have an account? Click Sign Up to create one."
end
end
<<<<<<< HEAD

=======





>>>>>>> d4a4f1bcc942c20df1b86ac333158c9e7d25fbed
end
2 changes: 2 additions & 0 deletions app/helpers/admin_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module AdminHelper
end
2 changes: 2 additions & 0 deletions app/helpers/ads_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module AdsHelper
end
Loading

0 comments on commit 4bb5484

Please sign in to comment.