Skip to content

Commit

Permalink
bringing in pre-setup rails files
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaiwarner committed Mar 16, 2011
1 parent fed8587 commit 23deba3
Show file tree
Hide file tree
Showing 102 changed files with 2,560 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
@@ -0,0 +1,9 @@
.bundle
db/*.sqlite3
log/*.log
tmp/**/*
config/database.yml
public/uploads/*
config/initializers/secret_token.rb
config/initializers/carrierwave_s3.rb

19 changes: 19 additions & 0 deletions Gemfile
@@ -0,0 +1,19 @@
source 'http://rubygems.org'

gem 'rails', '3.0.1'
gem 'haml'
gem 'devise'
gem 'cancan'
gem 'rmagick'
gem 'carrierwave'
gem 'fog'
gem 'high_voltage'
gem 'meta_where'
gem 'jquery-rails', '>= 0.2.6'
gem 'kaminari'

gem 'sqlite3'

group :development, :test do
gem "rspec-rails", ">= 2.4.1"
end
135 changes: 135 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,135 @@
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.1)
actionpack (= 3.0.1)
mail (~> 2.2.5)
actionpack (3.0.1)
activemodel (= 3.0.1)
activesupport (= 3.0.1)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4.1)
rack (~> 1.2.1)
rack-mount (~> 0.6.12)
rack-test (~> 0.5.4)
tzinfo (~> 0.3.23)
activemodel (3.0.1)
activesupport (= 3.0.1)
builder (~> 2.1.2)
i18n (~> 0.4.1)
activerecord (3.0.1)
activemodel (= 3.0.1)
activesupport (= 3.0.1)
arel (~> 1.0.0)
tzinfo (~> 0.3.23)
activeresource (3.0.1)
activemodel (= 3.0.1)
activesupport (= 3.0.1)
activesupport (3.0.1)
arel (1.0.1)
activesupport (~> 3.0.0)
bcrypt-ruby (2.1.4)
builder (2.1.2)
cancan (1.5.0)
carrierwave (0.5.1)
activesupport (~> 3.0)
devise (1.1.5)
bcrypt-ruby (~> 2.1.2)
warden (~> 1.0.2)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
excon (0.5.2)
fog (0.5.3)
builder
excon (>= 0.5.2)
formatador (>= 0.0.16)
json
mime-types
net-ssh (>= 2.0.23)
nokogiri (>= 1.4.4)
ruby-hmac
formatador (0.0.16)
haml (3.0.25)
high_voltage (0.9.3)
i18n (0.4.2)
jquery-rails (0.2.6)
rails (~> 3.0)
thor (~> 0.14.4)
json (1.5.1)
kaminari (0.10.4)
rails (>= 3.0.0)
mail (2.2.9)
activesupport (>= 2.3.6)
i18n (~> 0.4.1)
mime-types (~> 1.16)
treetop (~> 1.4.8)
meta_where (0.9.6)
activerecord (~> 3.0.0)
activesupport (~> 3.0.0)
arel (~> 1.0.1)
mime-types (1.16)
net-ssh (2.1.0)
nokogiri (1.4.4)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.6)
rack (>= 1.0)
rails (3.0.1)
actionmailer (= 3.0.1)
actionpack (= 3.0.1)
activerecord (= 3.0.1)
activeresource (= 3.0.1)
activesupport (= 3.0.1)
bundler (~> 1.0.0)
railties (= 3.0.1)
railties (3.0.1)
actionpack (= 3.0.1)
activesupport (= 3.0.1)
rake (>= 0.8.4)
thor (~> 0.14.0)
rake (0.8.7)
rmagick (2.13.1)
rspec (2.4.0)
rspec-core (~> 2.4.0)
rspec-expectations (~> 2.4.0)
rspec-mocks (~> 2.4.0)
rspec-core (2.4.0)
rspec-expectations (2.4.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.4.0)
rspec-rails (2.4.1)
actionpack (~> 3.0)
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.4.0)
ruby-hmac (0.4.0)
sqlite3 (1.3.3)
thor (0.14.4)
treetop (1.4.8)
polyglot (>= 0.3.1)
tzinfo (0.3.23)
warden (1.0.3)
rack (>= 1.0.0)

PLATFORMS
ruby

DEPENDENCIES
cancan
carrierwave
devise
fog
haml
high_voltage
jquery-rails (>= 0.2.6)
kaminari
meta_where
rails (= 3.0.1)
rmagick
rspec-rails (>= 2.4.1)
sqlite3
7 changes: 7 additions & 0 deletions Rakefile
@@ -0,0 +1,7 @@
# 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__)
require 'rake'

Aumodoro::Application.load_tasks
22 changes: 22 additions & 0 deletions app/controllers/application_controller.rb
@@ -0,0 +1,22 @@
class ApplicationController < ActionController::Base
protect_from_forgery

layout :detect_browser

rescue_from CanCan::AccessDenied do |exception|
redirect_to root_url, :alert => exception.message
end


private

def detect_browser
agent = request.headers["HTTP_USER_AGENT"].downcase
["android", "ipod", "opera mini", "blackberry", "kindle", "mobile"].each do |m|
return "application.mobile" if agent.match(m)
end
return "application"
end


end
99 changes: 99 additions & 0 deletions app/controllers/friends_controller.rb
@@ -0,0 +1,99 @@
class FriendsController < ApplicationController
#before_filter :load_friend, :except => [:index, :new]
authorize_resource

respond_to :html, :json

def autocomplete
@friends = (params[:term] == "") ? [] : Friend.limit(10).where(:user_id => current_user.id, :name.matches => '%'+params[:term]+'%')
respond_with(@friends.collect{ |friend| friend.name })
end


def index
@friends = Friend.where(:user_id => current_user.id).order('name ASC').page(params[:page]).per(100)
respond_with(@friends)
end

def best
@friends = Friend.where(:user_id => current_user.id).order('score DESC')
respond_with(@friends)
end

def learn
# show random friend
offset = rand(Friend.where(:user_id => current_user.id).count)
@friend = Friend.first(:offset => offset)
respond_with(@friend)
end

def show
@friend = Friend.where(:user_id => current_user.id).find_by_slug(params[:id])
@interactions = @friend.interactions.order('datetime DESC').page(params[:page]).per(10)
respond_with(@friend)
end


def new
@friend = Friend.new
respond_with(@friend)
end


def edit
@friend = Friend.where(:user_id => current_user.id).find_by_slug(params[:id])
end


def create
@friend = Friend.new(params[:friend])
@friend.user = current_user
@friend.score = 0

respond_to do |format|
if @friend.save
format.html { redirect_to(@friend, :notice => 'Friend was successfully created.') }
format.xml { render :xml => @friend, :status => :created, :location => @friend }
else
format.html { render :action => "new" }
format.xml { render :xml => @friend.errors, :status => :unprocessable_entity }
end
end
end


def update
@friend = Friend.where(:user_id => current_user.id).find_by_slug(params[:id])



respond_to do |format|
if @friend.update_attributes(params[:friend])
format.html { redirect_to(@friend, :notice => 'Friend was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @friend.errors, :status => :unprocessable_entity }
end
end
end


def destroy
@friend = Friend.where(:user_id => current_user.id).find_by_slug(params[:id])
@friend.destroy

respond_to do |format|
format.html { redirect_to(friends_url) }
format.xml { head :ok }
end
end


protected
def load_friend
@friend = Friend.find_by_slug(params[:id])
end


end
98 changes: 98 additions & 0 deletions app/controllers/interactions_controller.rb
@@ -0,0 +1,98 @@
class InteractionsController < ApplicationController
load_and_authorize_resource



def index
@interactions = Interaction.where(:user_id => current_user.id).order('datetime DESC').page(params[:page])

respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @interactions }
end
end



def show
@interaction = Interaction.where(:user_id => current_user.id).find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @interaction }
end
end



def new
@interaction = Interaction.new

respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @interaction }
end
end


def edit
@interaction = Interaction.where(:user_id => current_user.id).find(params[:id])
end



def create

# muliple friends
friend_names = []
if params[:interaction_friend_name].include? ','
friend_names = params[:interaction_friend_name].split(',').collect{|friend| friend.strip }
else
friend_names = [params[:interaction_friend_name].gsub(',','').strip]
end

friend_names.each do |friend_name|
interaction = Interaction.new(params[:interaction])
interaction.user = current_user

friend = Friend.find_by_name friend_name
if friend
interaction.friend_id = friend.id

interaction.points ||= 0

interaction.save
end
end

redirect_to(interactions_path, :notice => 'Interaction noted.')
end



def update
@interaction = Interaction.where(:user_id => current_user.id).find(params[:id])

respond_to do |format|
if @interaction.update_attributes(params[:interaction])
format.html { redirect_to(friend_path(@interaction.friend), :notice => 'Interaction was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @interaction.errors, :status => :unprocessable_entity }
end
end
end



def destroy
@interaction = Interaction.where(:user_id => current_user.id).find(params[:id])
@interaction.destroy

respond_to do |format|
format.html { redirect_to(interactions_url) }
format.xml { head :ok }
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
module ApplicationHelper
end

0 comments on commit 23deba3

Please sign in to comment.