Created
June 20, 2011 10:33
-
-
Save yuyalush/1035415 to your computer and use it in GitHub Desktop.
Sinatra+Haml+Omniauth sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
動作環境 | |
Ruby1.9.2 | |
1. setup | |
gemで以下のものをインストール | |
sinatra | |
omniauth | |
haml | |
shotgun | |
2. ファイルを配置 | |
app.rbとconfig.ruを配置 | |
viewsというディレクトリを作り、そこへindex.hamlとindex2.hamlを配置する | |
3. サーバを起動する | |
# shotgun -o 0.0.0.0 -p 3000 | |
http://localhost:3000/ | |
にアクセスする |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: UTF-8 -*- | |
require 'rubygems' | |
require 'sinatra' | |
require 'haml' | |
require 'omniauth' | |
set :haml, {:format => :html5} | |
enable :sessions, :logging | |
use OmniAuth::Builder do | |
provider :twitter, 'CONSUMER_KEY', 'CONSUMER_SECRET' | |
end | |
get '/' do | |
haml :index | |
end | |
get '/auth/:name/callback' do | |
@auth = request.env['omniauth.auth'] | |
haml :index2 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './app.rb' | |
run Sinatra::Application |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!!! | |
%html | |
%head | |
%meta{:charset => "utf-8"} | |
%title Sinatra + Haml + Omniauthテスト | |
%body | |
%a{:href => '/auth/twitter'} Sign in Twitter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!!! | |
%html | |
%head | |
%meta{:charset => "utf-8"} | |
%title Sinatra + Haml + Omniauthテスト | |
%body | |
%p Finish! | |
%pre= @auth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment