edbond (owner)

Fork Of

Revisions

gist: 89691 Download_button fork
public
Description:
twitterapp
Public Clone URL: git://gist.github.com/89691.git
Embed All Files: show embed
twitter_app.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
app_name = ask("What is your application called?")
puts "\nBefore this generator runs you will need to register your Twitter application for OAuth at http://twitter.com/oauth_clients, then enter the consumer key and secret below:\n\n"
consumer_key = ask("OAuth Consumer Key:")
consumer_secret = ask("OAuth Consumer Secret:")
 
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm README"
run "cp config/database.yml config/database.yml.example"
 
file '.gitignore', <<-END
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
END
 
git :init
git :add => "."
git :commit => '-m "Initial commit."'
 
gem 'haml', :version => '>= 2.0.6'
gem 'twitter-auth', :lib => 'twitter_auth'
gem 'cucumber'
gem 'rspec', :lib => false
gem 'rspec-rails', :lib => false
gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => 'http://gems.github.com'
gem 'carlosbrando-remarkable', :lib => 'remarkable', :source => 'http://gems.github.com'
gem 'webrat'
 
plugin 'jrails', :git => 'git://github.com/aaronchi/jrails.git ', :submodule => true
plugin 'uberkit', :git => 'git://github.com/mbleigh/uberkit.git', :submodule => true
 
generate('twitter_auth')
generate('rspec')
generate('cucumber')
generate('rspec_controller', 'static')
 
file 'app/views/layouts/master.html.erb', <<-TEMPLATE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>#{app_name} - <%= @title || "Powered by TwitterAuth" %></title>
<%= stylesheet_link_tag 'master' %>
</head>
<body>
<div id='wrapper'>
<div id='header'>
<h1>#{app_name}</h1>
<div id='user_bar'>
<% if logged_in? %>
Logged in as <strong><%= current_user.login %></strong>. <%= link_to 'Log out', '/logout' %>
<% else %>
<%= link_to 'Login via Twitter', '/login' %>
<% end %>
</div>
<div class='clearfix'></div>
</div>
<div id='contents'>
<%= yield %>
</div>
</div>
<div id='footer'>
Copyright &copy; 2009 #{app_name}. Powered by <%= link_to 'TwitterAuth', 'http://mbleigh.com/twitter-auth', :target => '_blank' %>.
</div>
</body>
</html>
TEMPLATE
 
file 'app/views/static/index.html.erb', <<-TEMPLATE
<h2>Welcome to Your Twitter Application!</h2>
 
<p>You have successfully created a Twitter-ready application! To test it out just click on <strong>Login via Twitter</strong> above. You should be taken to Twitter and then back here where it will tell you that you are logged in!</p>
TEMPLATE
 
file 'public/stylesheets/sass/master.sass', <<-SASS
body
:font-family Arial, sans-serif
:background #cef
:margin 0
:padding 0
:color #333
 
a
:color #06b
:font-weight bold
 
.clearfix
:clear both
 
#wrapper
:background white
:padding 1.5em 2em
:width 55em
:-moz-border-radius 1em
:-webkit-border-radius 1em
:border-radius 1em
:margin 1em auto 0.5em
 
#footer
:text-align center
:font-size 0.8em
:color #666
 
#header
h1
:float left
:font-size 3em
:margin 0
:padding 0
:color #057
:margin-bottom 0.3em
#user_bar
:float right
:margin-top 1.2em
 
p
:line-height 150%
SASS
 
file 'app/controllers/application_controller.rb', <<-RUBY
class ApplicationController < ActionController::Base
layout 'master'
end
RUBY
 
run "cp config/twitter_auth.yml config/twitter_auth.yml.example"
 
file 'config/twitter_auth.yml', <<-YAML
development:
strategy: oauth
oauth_consumer_key: "#{consumer_key}"
oauth_consumer_secret: "#{consumer_secret}"
base_url: "https://twitter.com"
api_timeout: 10
remember_for: 14 # days
oauth_callback: "http://localhost:3000/oauth_callback"
test:
strategy: oauth
oauth_consumer_key: "#{consumer_key}"
oauth_consumer_secret: "#{consumer_secret}"
base_url: "http://https://twitter.com"
api_timeout: 10
remember_for: 14 # days
oauth_callback: "http://localhost:3000/oauth_callback"
production:
strategy: oauth
oauth_consumer_key: "#{consumer_key}"
oauth_consumer_secret: "#{consumer_secret}"
base_url: "https://twitter.com"
api_timeout: 10
remember_for: 14 # days
YAML
 
route "map.root :controller => 'static', :action => 'index'"
route "map.static '/:action', :controller => 'static'"
 
git :add => '.'
git :commit => '-m "Adding in templates, gems, and plugins."'
 
if yes?("Run rake gems:install? (yes/no)")
  rake("gems:install")
end
 
if yes?("Create and migrate databases now? (yes/no)")
  rake("db:create:all")
  rake("db:migrate")
end