Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ config/database.yml
config/private.yml
config/initializers/development_mail.rb
db/schema.rb
public/assets
public/assets
/nbproject/*
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
source 'http://rubygems.org'

gem 'rails', '3.0.3'
gem 'rails', '3.0.11'
gem 'mysql2'
gem 'omniauth'
gem 'jquery-rails'
gem 'bcrypt-ruby', :require => 'bcrypt'
gem 'will_paginate', '3.0.pre2'
gem 'whenever', :require => false
gem 'go_gtp', '0.0.4', :require => 'go/gtp', :git => "git://github.com/JEG2/go_gtp.git"
gem 'go_gtp', :require => 'go/gtp', :git => "http://github.com/JEG2/go_gtp.git"
gem 'stalker', '0.5.0'
gem 'oily_png', '0.1.0'
gem 'exception_notification', :git => 'git://github.com/rails/exception_notification.git', :require => 'exception_notifier'
gem 'exception_notification', :git => 'http://github.com/rails/exception_notification.git', :require => 'exception_notifier'

group :development, :test do
gem 'mocha'
Expand Down
97 changes: 51 additions & 46 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
GIT
remote: git://github.com/JEG2/go_gtp.git
revision: 2753f3ebeb3c058bfc05eca20810df67557844c6
remote: http://github.com/JEG2/go_gtp.git
revision: a1cc912436c8e0bac10bca693ce583c8baf2a0c4
specs:
go_gtp (0.0.4)
go_gtp (0.0.5.alpha)

GIT
remote: git://github.com/rails/exception_notification.git
remote: http://github.com/rails/exception_notification.git
revision: 192a49a02d63d28b23ed41cebadfedd490929cf1
specs:
exception_notification (1.0.0)
Expand All @@ -16,34 +16,34 @@ GEM
ZenTest (4.4.0)
aaronh-chronic (0.3.9)
abstract (1.0.0)
actionmailer (3.0.3)
actionpack (= 3.0.3)
mail (~> 2.2.9)
actionpack (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
actionmailer (3.0.11)
actionpack (= 3.0.11)
mail (~> 2.2.19)
actionpack (3.0.11)
activemodel (= 3.0.11)
activesupport (= 3.0.11)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
i18n (~> 0.5.0)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.6)
rack-mount (~> 0.6.14)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.3)
activesupport (= 3.0.3)
activemodel (3.0.11)
activesupport (= 3.0.11)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
arel (~> 2.0.2)
i18n (~> 0.5.0)
activerecord (3.0.11)
activemodel (= 3.0.11)
activesupport (= 3.0.11)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activeresource (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
activeresource (3.0.11)
activemodel (= 3.0.11)
activesupport (= 3.0.11)
activesupport (3.0.11)
addressable (2.2.2)
arel (2.0.6)
arel (2.0.10)
autotest (4.4.1)
autotest-rails (4.1.0)
ZenTest
Expand Down Expand Up @@ -79,16 +79,17 @@ GEM
i18n (0.5.0)
jquery-rails (0.2.4)
rails (~> 3.0)
json (1.6.4)
json_pure (1.4.6)
launchy (0.3.7)
configuration (>= 0.0.5)
rake (>= 0.8.1)
mail (2.2.12)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
mime-types (1.17.2)
mocha (0.9.9)
rake
mongrel (1.2.0.pre2)
Expand Down Expand Up @@ -143,30 +144,33 @@ GEM
oa-openid (= 0.1.5)
open_gem (1.4.2)
launchy (~> 0.3.5)
polyglot (0.3.1)
polyglot (0.3.3)
pyu-ruby-sasl (0.0.3.2)
rack (1.2.1)
rack-mount (0.6.13)
rack (1.2.5)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-openid (1.1.2)
rack (>= 0.4)
ruby-openid (>= 2.0.3)
rack-test (0.5.6)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.3)
actionmailer (= 3.0.3)
actionpack (= 3.0.3)
activerecord (= 3.0.3)
activeresource (= 3.0.3)
activesupport (= 3.0.3)
rails (3.0.11)
actionmailer (= 3.0.11)
actionpack (= 3.0.11)
activerecord (= 3.0.11)
activeresource (= 3.0.11)
activesupport (= 3.0.11)
bundler (~> 1.0)
railties (= 3.0.3)
railties (3.0.3)
actionpack (= 3.0.3)
activesupport (= 3.0.3)
railties (= 3.0.11)
railties (3.0.11)
actionpack (= 3.0.11)
activesupport (= 3.0.11)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
rake (0.8.7)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
rest-client (1.6.1)
mime-types (>= 1.16)
rspec (2.0.1)
Expand All @@ -189,9 +193,10 @@ GEM
beanstalk-client
json_pure
thor (0.14.6)
treetop (1.4.9)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.23)
tzinfo (0.3.31)
whenever (0.6.2)
aaronh-chronic (>= 0.3.9)
activesupport (>= 2.3.4)
Expand All @@ -207,7 +212,7 @@ DEPENDENCIES
capistrano
exception_notification!
factory_girl_rails
go_gtp (= 0.0.4)!
go_gtp!
guard
guard-rspec
jquery-rails
Expand All @@ -217,7 +222,7 @@ DEPENDENCIES
nifty-generators
oily_png (= 0.1.0)
omniauth
rails (= 3.0.3)
rails (= 3.0.11)
rspec-rails (>= 2.0.1)
stalker (= 0.5.0)
whenever
Expand Down
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class ApplicationController < ActionController::Base
include ControllerAuthentication
include ControllerI18n
protect_from_forgery
before_filter :mark_user_request, :if => :logged_in?
before_filter :set_user_time_zone, :if => :logged_in?
Expand Down
10 changes: 6 additions & 4 deletions app/controllers/authentications_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class AuthenticationsController < ApplicationController
after_filter :change_locale, :only => [:create]

def index
end

Expand All @@ -10,7 +12,7 @@ def create
authentication.user.apply_omniauth(omniauth)
authentication.user.save!
remember_user(authentication.user)
flash[:notice] = "Signed in as #{authentication.user.username}"
flash[:notice] = t("signed_in_as", :username => authentication.user.username, :scope => "controllers.authentications")
redirect_to_target_or_default root_url
else
user = current_user_or_guest
Expand All @@ -20,11 +22,11 @@ def create
user.guest = false
if user.save
if was_guest
flash[:notice] = "Signed in as #{user.username}."
flash[:notice] = t("signed_in_as", :username => user.username, :scope => "controllers.authentications")
remember_user(user)
redirect_to_target_or_default root_url
else
flash[:notice] = "Authentication successful."
flash[:notice] = t("create", :scope => "controllers.authentications")
redirect_to edit_current_user_url
end
else
Expand All @@ -37,7 +39,7 @@ def create
def destroy
@authentication = current_user.authentications.find(params[:id])
@authentication.destroy
flash[:notice] = "Successfully destroyed authentication."
flash[:notice] = t("destroy", :scope => "controllers.authentications")
redirect_to edit_current_user_path
end
end
4 changes: 2 additions & 2 deletions app/controllers/games_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def create
@game.prepare
if @game.save
@game.queue_computer_move
Notifications.invitation(@game).deliver if @game.send_invitation_email?
flash[:notice] = "Game started. Click on a point below to place your stone."
flash[:notice] = t("create", :scope => "controllers.games")
Notifications.invitation(@game).deliver if @game.send_invitation_email?
redirect_to @game
else
fetch_games
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/moves_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def create
@game.queue_computer_move
Notifications.move(@game).deliver if @game.current_player && @game.current_player.email.present? && @game.current_player.email_on_move?
rescue GameEngine::IllegalMove
flash[:alert] = "That is an illegal move."
flash[:alert] = t("illegal_move", :scope => "controllers.moves")
rescue GameEngine::OutOfTurn
flash[:alert] = "It is not your turn to move."
flash[:alert] = t("out_of_turn", :scope => "controllers.moves")
end
end
8 changes: 5 additions & 3 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
class SessionsController < ApplicationController
after_filter :change_locale, :only => [:create]

def new
end

def create
user = User.authenticate(params[:login], params[:password])
if user
remember_user(user)
flash[:notice] = "Logged in successfully."
flash[:notice] = t("create_success", :scope => "controllers.sessions")
redirect_to_target_or_default("/")
else
flash.now[:alert] = "Invalid login or password."
flash.now[:alert] = t("create_fail", :scope => "controllers.sessions")
render :action => 'new'
end
end

def destroy
forget_user
flash[:notice] = "You have been logged out."
flash[:notice] = t("destroy", :scope => "controllers.sessions")
redirect_to root_url
end
end
15 changes: 8 additions & 7 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class UsersController < ApplicationController
before_filter :login_required, :except => [:show, :new, :create, :unsubscribe]
after_filter :change_locale, :only => [:create, :update]

def show
@user = User.where(:guest => false).find(params[:id])
Expand All @@ -9,10 +10,10 @@ def show
def new
if params[:email]
if logged_in?
flash[:notice] = "Please update your profile below."
flash[:notice] = t("new_update", :scope => "controllers.users")
redirect_to edit_current_user_url(:email => params[:email])
elsif User.find_by_email(params[:email])
flash[:notice] = "It appears you already have an account, please login below."
flash[:notice] = t("new_login", :scope => "controllers.users")
redirect_to login_url(:login => params[:email])
end
end
Expand All @@ -23,7 +24,7 @@ def create
@user = User.new(params[:user])
if @user.save
remember_user(@user)
flash[:notice] = "Thank you for signing up! You are now logged in."
flash[:notice] = t("create", :scope => "controllers.users")
redirect_to root_url
else
render :action => 'new'
Expand All @@ -47,7 +48,7 @@ def update
@user.guest = false
if @user.save
session[:omniauth] = nil
flash[:notice] = "Your profile has been updated."
flash[:notice] = t("update", :scope => "controllers.users")
redirect_to root_url
else
render :action => 'edit'
Expand All @@ -57,17 +58,17 @@ def update
def unsubscribe
@user = User.find_by_unsubscribe_token!(params[:token])
@user.update_attributes!(:email_on_invitation => false, :email_on_move => false, :email_on_message => false)
flash[:notice] = "You have been unsubscribed from further email notifications."
flash[:notice] = t("unsubscribe", :scope => "controllers.users")
redirect_to root_url
end

def publicize
if guest?
redirect_to signin_url, :alert => "You must first sign in to be added to the Looking for Games list."
redirect_to signin_url, :alert => t("publicize_guest", :scope => "controllers.users")
else
@user = current_user
@user.update_attribute(:publicized_at, (params[:remove] ? nil : Time.now))
redirect_to root_url, :notice => "You have been #{params[:remove] ? 'removed from' : 'added to'} the Looking for Games list."
redirect_to root_url, :notice => t(params[:remove] ? "publicize_remove" : "publicize_add", :scope => "controllers.users")
end
end
end
12 changes: 6 additions & 6 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@ def avatar_url(user)

def link_to_user(user)
if user
user.guest? ? "Guest" : link_to(user.name_with_rank, user, :class => "subtle")
user.guest? ? t("guest", :scope => "helpers.application") : link_to(user.name_with_rank, user, :class => "subtle")
else
"GNU Go"
t("gnu_go", :scope => "helpers.application")
end
end

def relative_time(time)
[relative_date(time.to_date), time.strftime("%I:%M %p")].compact.join(" ")
[relative_date(time.to_date), l(time, :format => '%I:%M %p')].compact.join(" ")
end

def relative_date(date)
today = Time.zone.now.to_date
if date == today
nil
elsif date == today-1
"yesterday"
t("yesterday", :scope => "helpers.application")
elsif date.year == today.year
date.strftime("%b %d")
l(date, :format => "%b %d")
else
date.strftime("%b %d, %Y")
l(date, :format => "%b %d, %Y")
end
end
end
Loading