forked from shiroginne/Hack-n-slash
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 02c1bd6
Showing
8 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source 'https://rubygems.org' | ||
gem 'thin' | ||
gem 'sinatra', :require => 'sinatra/base' | ||
gem 'omniauth' | ||
gem 'omniauth-github' | ||
gem 'slim' | ||
gem 'mongoid' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
activemodel (3.2.2) | ||
activesupport (= 3.2.2) | ||
builder (~> 3.0.0) | ||
activesupport (3.2.2) | ||
i18n (~> 0.6) | ||
multi_json (~> 1.0) | ||
addressable (2.2.7) | ||
bson (1.6.1) | ||
builder (3.0.0) | ||
daemons (1.1.8) | ||
eventmachine (0.12.10) | ||
faraday (0.7.6) | ||
addressable (~> 2.2) | ||
multipart-post (~> 1.1) | ||
rack (~> 1.1) | ||
hashie (1.2.0) | ||
i18n (0.6.0) | ||
mongo (1.6.1) | ||
bson (~> 1.6.1) | ||
mongoid (2.4.7) | ||
activemodel (~> 3.1) | ||
mongo (~> 1.3) | ||
tzinfo (~> 0.3.22) | ||
multi_json (1.1.0) | ||
multipart-post (1.1.5) | ||
oauth2 (0.5.2) | ||
faraday (~> 0.7) | ||
multi_json (~> 1.0) | ||
omniauth (1.0.3) | ||
hashie (~> 1.2) | ||
rack | ||
omniauth-github (1.0.1) | ||
omniauth (~> 1.0) | ||
omniauth-oauth2 (~> 1.0) | ||
omniauth-oauth2 (1.0.0) | ||
oauth2 (~> 0.5.0) | ||
omniauth (~> 1.0) | ||
rack (1.4.1) | ||
rack-protection (1.1.4) | ||
rack | ||
sinatra (1.3.1) | ||
rack (~> 1.3, >= 1.3.4) | ||
rack-protection (~> 1.1, >= 1.1.2) | ||
tilt (~> 1.3, >= 1.3.3) | ||
slim (1.1.1) | ||
temple (~> 0.4.0) | ||
tilt (~> 1.3.2) | ||
temple (0.4.0) | ||
thin (1.3.1) | ||
daemons (>= 1.0.9) | ||
eventmachine (>= 0.12.6) | ||
rack (>= 1.0.0) | ||
tilt (1.3.3) | ||
tzinfo (0.3.32) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
mongoid | ||
omniauth | ||
omniauth-github | ||
sinatra | ||
slim | ||
thin |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Hacker | ||
include Mongoid::Document | ||
|
||
field :uid, type: String | ||
field :name, type: String | ||
field :email, type: String | ||
|
||
end |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
h1 "You bro, #{Hacker.last.try(:name)}" | ||
a href='/auth/github' | ||
| Sign in with github | ||
|
||
h2 Bros => | ||
- Hacker.all.each do |hack| | ||
img src="#{gravatar(hack.try(:email))}" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'rubygems' | ||
require 'bundler' | ||
require 'yaml' | ||
require 'digest' | ||
|
||
Bundler.require | ||
|
||
require './core' | ||
require './app/models/hacker' | ||
require './app/models/target' | ||
run Core |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
development: | ||
host: localhost | ||
database: bro_development | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
class Core < Sinatra::Base | ||
GITHUB = YAML.load_file(File.join(settings.root, 'config/github_key.yml')) | ||
Mongoid.load!(File.join(settings.root, 'config/mongoid.yml')) | ||
|
||
set :views, settings.root + '/app/views' | ||
set :slim, :pretty => true | ||
|
||
use Rack::Session::Cookie | ||
use OmniAuth::Builder do | ||
provider :github, GITHUB['id'], GITHUB['secret'] | ||
end | ||
|
||
helpers do | ||
def gravatar email | ||
"http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email)}" if email | ||
end | ||
end | ||
|
||
get '/' do | ||
slim :home | ||
end | ||
|
||
get '/auth/failure' do | ||
"Not cool, bro" | ||
end | ||
|
||
get '/auth/github/callback' do | ||
Hacker.find_or_create_by(uid: request.env['omniauth.auth']['uid'], | ||
name: request.env['omniauth.auth']['info']['nickname'], | ||
email: request.env['omniauth.auth']['info']['email']) | ||
redirect '/' | ||
end | ||
|
||
end |