Skip to content

Commit

Permalink
settings with 'choices', new version of twitter-login
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Dec 17, 2010
1 parent ca6ff87 commit 42511c1
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -3,4 +3,4 @@
db/*.sqlite3
log/*.log
tmp
config/settings.yml
config/settings.local.yml
31 changes: 5 additions & 26 deletions Gemfile
@@ -1,30 +1,9 @@
source 'http://rubygems.org'

gem 'rails', '~> 3.0'
gem 'arel'
gem 'twitter-login', '~> 0.4.1', :require => 'twitter/login'
gem 'choices'

gem 'sqlite3-ruby', :require => 'sqlite3'

gem 'twitter-login', '~> 0.2.1', :require => 'twitter/login'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug'

# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri', '1.4.1'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'

# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
# gem 'webrat'
# end
group :development, :test do
gem 'sqlite3-ruby', :require => 'sqlite3'
end
112 changes: 54 additions & 58 deletions Gemfile.lock
Expand Up @@ -2,87 +2,83 @@ GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.0)
actionpack (= 3.0.0)
mail (~> 2.2.5)
actionpack (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.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)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4.1)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.12)
rack-test (~> 0.5.4)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.6)
tzinfo (~> 0.3.23)
activemodel (3.0.0)
activesupport (= 3.0.0)
activemodel (3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
i18n (~> 0.4.1)
activerecord (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
arel (~> 1.0.0)
i18n (~> 0.4)
activerecord (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
activesupport (3.0.0)
arel (1.0.1)
activesupport (~> 3.0.0)
activeresource (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
arel (2.0.6)
builder (2.1.2)
crack (0.1.6)
choices (0.2.0)
hashie (>= 0.4.0)
erubis (2.6.6)
abstract (>= 1.0.0)
hashie (0.2.2)
httparty (0.5.2)
crack (= 0.1.6)
i18n (0.4.1)
mail (2.2.6)
hashie (0.4.0)
i18n (0.5.0)
mail (2.2.12)
activesupport (>= 2.3.6)
mime-types
treetop (>= 1.4.5)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
oauth (0.4.3)
oauth (0.4.4)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.4)
rack-test (0.5.6)
rack (>= 1.0)
rails (3.0.0)
actionmailer (= 3.0.0)
actionpack (= 3.0.0)
activerecord (= 3.0.0)
activeresource (= 3.0.0)
activesupport (= 3.0.0)
bundler (~> 1.0.0)
railties (= 3.0.0)
railties (3.0.0)
actionpack (= 3.0.0)
activesupport (= 3.0.0)
rake (>= 0.8.4)
thor (~> 0.14.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)
bundler (~> 1.0)
railties (= 3.0.3)
railties (3.0.3)
actionpack (= 3.0.3)
activesupport (= 3.0.3)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
sqlite3-ruby (1.3.1)
thor (0.14.0)
treetop (1.4.8)
sqlite3-ruby (1.3.2)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
twitter (0.9.8)
hashie (~> 0.2.0)
httparty (~> 0.5.0)
oauth (~> 0.4.1)
yajl-ruby (~> 0.7.0)
twitter-login (0.2.3)
twitter (~> 0.9.5)
twitter-login (0.4.1)
hashie (>= 0.2.2)
oauth (~> 0.4.2)
yajl-ruby (>= 0.7.7)
tzinfo (0.3.23)
yajl-ruby (0.7.7)
yajl-ruby (0.7.8)

PLATFORMS
ruby

DEPENDENCIES
arel
choices
rails (~> 3.0)
sqlite3-ruby
twitter-login (~> 0.2.1)
twitter-login (~> 0.4.1)
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Expand Up @@ -36,7 +36,7 @@
</header>

<% unless logged_in? %>
<a class="main" href="/login">Sign in with Twitter</a>
<%= link_to 'Sign in with Twitter', twitter_login_path, :class => 'main' %>
<% end %>
<%= yield %>
Expand Down
10 changes: 5 additions & 5 deletions config/application.rb
Expand Up @@ -6,15 +6,14 @@
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)

settings = ERB.new(IO.read(File.expand_path('../settings.yml', __FILE__))).result
$settings = Hashie::Mash.new YAML::load(settings)[Rails.env.to_s]

module Todaslistas
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

config.from_file 'settings.yml'

# Add additional load paths for your own custom dirs
# config.autoload_paths += %W( #{config.root}/extras )

Expand Down Expand Up @@ -45,7 +44,8 @@ class Application < Rails::Application

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]

config.middleware.use Twitter::Login, :consumer_key => $settings.twitter.consumer_key, :secret => $settings.twitter.secret

config.twitter_login = Twitter::Login.new \
:consumer_key => config.twitter.consumer_key, :secret => config.twitter.secret
end
end
7 changes: 0 additions & 7 deletions config/initializers/secret_token.rb

This file was deleted.

4 changes: 4 additions & 0 deletions config/routes.rb
Expand Up @@ -7,6 +7,10 @@
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action

config = Todaslistas::Application.config
twitter = config.twitter_login.login_handler(:return_to => '/')
mount twitter => 'login', :as => :twitter_login

# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)
Expand Down
5 changes: 0 additions & 5 deletions config/settings.example.yml

This file was deleted.

19 changes: 19 additions & 0 deletions config/settings.yml
@@ -0,0 +1,19 @@
defaults: &defaults
secret_token: <%= ENV['COOKIE_SECRET'] %>
heroku: <%= !!ENV['HEROKU_TYPE'] %>
twitter:
consumer_key: <%= ENV['TWITTER_KEY'] %>
secret: <%= ENV['TWITTER_SECRET'] %>

development:
<<: *defaults

test: &testing
<<: *defaults
secret_token: <%= "banana" * 5 %>

cucumber:
<<: *testing

production:
<<: *defaults

0 comments on commit 42511c1

Please sign in to comment.