Skip to content

Commit aadc5a3

Browse files
committed
Added Singly skeleton
1 parent 3c0f9e4 commit aadc5a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+782
-0
lines changed

Gemfile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'rails', '3.2.3'
4+
5+
# Bundle edge Rails instead:
6+
# gem 'rails', :git => 'git://github.com/rails/rails.git'
7+
8+
group :development do
9+
gem 'sqlite3'
10+
end
11+
12+
gem 'json'
13+
14+
gem 'haml', '3.1.4'
15+
gem 'httparty'
16+
gem 'omniauth-singly'
17+
18+
# Gems used only for assets and not required
19+
# in production environments by default.
20+
group :assets do
21+
gem 'sass-rails', '~> 3.2.3'
22+
gem 'coffee-rails', '~> 3.2.1'
23+
24+
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
25+
# gem 'therubyracer', :platform => :ruby
26+
27+
gem 'uglifier', '>= 1.0.3'
28+
end
29+
30+
gem 'jquery-rails'
31+
32+
# Heroku dependencies
33+
group :production do
34+
gem 'pg'
35+
gem 'thin'
36+
end

Gemfile.lock

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
actionmailer (3.2.3)
5+
actionpack (= 3.2.3)
6+
mail (~> 2.4.4)
7+
actionpack (3.2.3)
8+
activemodel (= 3.2.3)
9+
activesupport (= 3.2.3)
10+
builder (~> 3.0.0)
11+
erubis (~> 2.7.0)
12+
journey (~> 1.0.1)
13+
rack (~> 1.4.0)
14+
rack-cache (~> 1.2)
15+
rack-test (~> 0.6.1)
16+
sprockets (~> 2.1.2)
17+
activemodel (3.2.3)
18+
activesupport (= 3.2.3)
19+
builder (~> 3.0.0)
20+
activerecord (3.2.3)
21+
activemodel (= 3.2.3)
22+
activesupport (= 3.2.3)
23+
arel (~> 3.0.2)
24+
tzinfo (~> 0.3.29)
25+
activeresource (3.2.3)
26+
activemodel (= 3.2.3)
27+
activesupport (= 3.2.3)
28+
activesupport (3.2.3)
29+
i18n (~> 0.6)
30+
multi_json (~> 1.0)
31+
arel (3.0.2)
32+
builder (3.0.0)
33+
coffee-rails (3.2.2)
34+
coffee-script (>= 2.2.0)
35+
railties (~> 3.2.0)
36+
coffee-script (2.2.0)
37+
coffee-script-source
38+
execjs
39+
coffee-script-source (1.3.1)
40+
daemons (1.1.8)
41+
erubis (2.7.0)
42+
eventmachine (0.12.10)
43+
execjs (1.3.2)
44+
multi_json (~> 1.0)
45+
faraday (0.8.0)
46+
multipart-post (~> 1.1)
47+
haml (3.1.4)
48+
hashie (1.2.0)
49+
hike (1.2.1)
50+
httparty (0.8.1)
51+
multi_json
52+
multi_xml
53+
httpauth (0.1)
54+
i18n (0.6.0)
55+
journey (1.0.3)
56+
jquery-rails (2.0.2)
57+
railties (>= 3.2.0, < 5.0)
58+
thor (~> 0.14)
59+
json (1.7.1)
60+
mail (2.4.4)
61+
i18n (>= 0.4.0)
62+
mime-types (~> 1.16)
63+
treetop (~> 1.4.8)
64+
mime-types (1.18)
65+
multi_json (1.3.4)
66+
multi_xml (0.4.2)
67+
multipart-post (1.1.5)
68+
oauth2 (0.6.1)
69+
faraday (~> 0.7)
70+
httpauth (~> 0.1)
71+
multi_json (~> 1.3)
72+
omniauth (1.1.0)
73+
hashie (~> 1.2)
74+
rack
75+
omniauth-oauth2 (1.0.2)
76+
oauth2 (~> 0.6.0)
77+
omniauth (~> 1.0)
78+
omniauth-singly (0.0.1)
79+
omniauth (~> 1.0)
80+
omniauth-oauth2 (~> 1.0)
81+
pg (0.13.2)
82+
polyglot (0.3.3)
83+
rack (1.4.1)
84+
rack-cache (1.2)
85+
rack (>= 0.4)
86+
rack-ssl (1.3.2)
87+
rack
88+
rack-test (0.6.1)
89+
rack (>= 1.0)
90+
rails (3.2.3)
91+
actionmailer (= 3.2.3)
92+
actionpack (= 3.2.3)
93+
activerecord (= 3.2.3)
94+
activeresource (= 3.2.3)
95+
activesupport (= 3.2.3)
96+
bundler (~> 1.0)
97+
railties (= 3.2.3)
98+
railties (3.2.3)
99+
actionpack (= 3.2.3)
100+
activesupport (= 3.2.3)
101+
rack-ssl (~> 1.3.2)
102+
rake (>= 0.8.7)
103+
rdoc (~> 3.4)
104+
thor (~> 0.14.6)
105+
rake (0.9.2.2)
106+
rdoc (3.12)
107+
json (~> 1.4)
108+
sass (3.1.17)
109+
sass-rails (3.2.5)
110+
railties (~> 3.2.0)
111+
sass (>= 3.1.10)
112+
tilt (~> 1.3)
113+
sprockets (2.1.3)
114+
hike (~> 1.2)
115+
rack (~> 1.0)
116+
tilt (~> 1.1, != 1.3.0)
117+
sqlite3 (1.3.6)
118+
thin (1.3.1)
119+
daemons (>= 1.0.9)
120+
eventmachine (>= 0.12.6)
121+
rack (>= 1.0.0)
122+
thor (0.14.6)
123+
tilt (1.3.3)
124+
treetop (1.4.10)
125+
polyglot
126+
polyglot (>= 0.3.1)
127+
tzinfo (0.3.33)
128+
uglifier (1.2.4)
129+
execjs (>= 0.3.0)
130+
multi_json (>= 1.0.2)
131+
132+
PLATFORMS
133+
ruby
134+
135+
DEPENDENCIES
136+
coffee-rails (~> 3.2.1)
137+
haml (= 3.1.4)
138+
httparty
139+
jquery-rails
140+
json
141+
omniauth-singly
142+
pg
143+
rails (= 3.2.3)
144+
sass-rails (~> 3.2.3)
145+
sqlite3
146+
thin
147+
uglifier (>= 1.0.3)

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Singly Rails Skeleton
2+
3+
This is a basic Rails App that implements an OAuth2 client against the Singly
4+
API. For more info, see https://dev.singly.com.
5+
6+
# Contributors
7+
8+
Thanks go to [Adam Derewecki](https://github.com/derwiki) for the initial implementation.

Rakefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env rake
2+
# Add your own tasks in files placed in lib/tasks ending in .rake,
3+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4+
5+
require File.expand_path('../config/application', __FILE__)
6+
7+
SinglyRailsSkeleton::Application.load_tasks

app/assets/images/rails.png

6.49 KB
Loading

app/assets/javascripts/application.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This is a manifest file that'll be compiled into application.js, which will include all the files
2+
// listed below.
3+
//
4+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6+
//
7+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8+
// the compiled file.
9+
//
10+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11+
// GO AFTER THE REQUIRES BELOW.
12+
//
13+
//= require jquery
14+
//= require jquery_ujs
15+
//= require_tree .

app/assets/javascripts/auth.js.coffee

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
body { background: #efeded; color: #333; font-family: helvetica, arial, sans-serif; line-height: 1.6; font-size: 75%; }
2+
a { text-decoration: none; color: #0078c9; }
3+
a:hover { text-decoration: underline; }
4+
div, ul, li, h1, h2, h3, h4 { background-repeat: no-repeat; background-position: top left; }
5+
h1, h2, h3, h4 { font-size: 1em; line-height: 1.4; margin: 0 0 1em; }
6+
p, blockquote, dl, dd, ul, ol, li { margin: 0 0 1em; padding: 0; }
7+
ul { list-style-type: none; }
8+
img, img a { border: 0; }
9+
hr, legend { display: none; }
10+
form { margin: 0; }
11+
fieldset { display: block; margin: 0; padding: 0; border: 0; }
12+
13+
h1 { font-size: 36px; margin-bottom: 10px; }
14+
15+
input, select, button { vertical-align: middle; font-size: 1em; }
16+
17+
.ClearFix { clear: both; height: 0; font-size: 0; }
18+
19+
#layout { width: 910px; margin: 0 auto; background: #fff; padding: 25px; }
20+
#quick-search { margin-bottom: 20px; }
21+
#grid li { float: left; margin-left: 20px; width: 125px; }

app/assets/stylesheets/auth.css.scss

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place all the styles related to the auth controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place all the styles related to the default controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class ApplicationController < ActionController::Base
2+
protect_from_forgery
3+
end

app/controllers/auth_controller.rb

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require "httparty"
2+
3+
class AuthController < ApplicationController
4+
5+
SINGLY_API_BASE = "https://api.singly.com"
6+
7+
def callback
8+
auth = request.env["omniauth.auth"]
9+
session[:access_token] = auth.credentials.token
10+
redirect_to "/"
11+
end
12+
13+
def logout
14+
session.clear
15+
redirect_to "/"
16+
end
17+
end

app/controllers/default_controller.rb

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require "httparty"
2+
3+
class DefaultController < ApplicationController
4+
def home
5+
if access_token
6+
@profiles = HTTParty.get(profiles_url,
7+
:query => {:access_token => access_token}
8+
).parsed_response
9+
end
10+
end
11+
12+
private
13+
14+
def access_token
15+
session[:access_token]
16+
end
17+
18+
SINGLY_API_BASE = "https://api.singly.com"
19+
20+
def profiles_url
21+
"#{SINGLY_API_BASE}/profiles"
22+
end
23+
end

app/helpers/application_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ApplicationHelper
2+
end

app/helpers/auth_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module AuthHelper
2+
end

app/helpers/default_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module DefaultHelper
2+
end

app/mailers/.gitkeep

Whitespace-only changes.

app/models/.gitkeep

Whitespace-only changes.

app/views/default/home.html.haml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
%h1 Singly OAuth Example
2+
%h2
3+
- if @profiles
4+
Nice to see you again!
5+
- else
6+
Please connect a service
7+
- if session[:access_token]
8+
%p
9+
Your access token is
10+
%input{:type => :text, :value => session[:access_token], :readonly => :readonly}
11+
%a(href="/logout") Log out
12+
%ul
13+
- %w[facebook twitter].each do |service|
14+
%li
15+
= service.capitalize
16+
- if @profiles && @profiles[service]
17+
is connected as
18+
= @profiles[service]
19+
- else
20+
is not connected.
21+
%a(href="/auth/singly?service=#{service}") Connect
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
!!!
2+
%html
3+
%head
4+
%title Singly Rails Skeleton
5+
= stylesheet_link_tag "application", :media => "all"
6+
= javascript_include_tag "application"
7+
= csrf_meta_tags
8+
%body
9+
= yield

config.ru

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This file is used by Rack-based servers to start the application.
2+
3+
require ::File.expand_path('../config/environment', __FILE__)
4+
run SinglyRailsSkeleton::Application

0 commit comments

Comments
 (0)