diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5b7a61f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM ruby:latest + +COPY ./ /app/ + +WORKDIR /app/ + +# Setup +RUN bundle install + +CMD /app/bootstrap.sh diff --git a/Gemfile b/Gemfile index dff2bf4..54657a0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -ruby '2.4.0' +ruby '2.5.3' source 'https://rubygems.org' gem 'activemodel-serializers-xml' @@ -11,6 +11,7 @@ gem 'sinatra-contrib' gem 'zippy' gem 'omniauth' gem 'omniauth-mlh' +gem 'foreman' group :development do gem 'sinatra-reloader' @@ -20,13 +21,3 @@ group :development, :test do gem 'pry' gem 'rake' end - -group :test do - gem 'capybara' - gem 'capybara-webkit' - gem 'capybara_minitest_spec' - gem 'database_cleaner' - gem 'faker' - gem 'minitest' - gem 'rack-test' -end diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..73f325a --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +PKG=covhacksoc/no-light +TAG=latest + +PORT=8000 + +build: + docker build -t $(PKG):$(TAG) . + +run: + docker run -p $(PORT):$(PORT) -e PORT=$(PORT) -it $(PKG):$(TAG) diff --git a/Procfile b/Procfile index 673bf14..a23739b 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: rackup config.ru -p $PORT +web: rackup config.ru -p $PORT -o 0.0.0.0 diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..1ee3b6b --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,2 @@ +#!/bin/sh +foreman start diff --git a/no_light_sinatra.rb b/no_light_sinatra.rb index d522203..744940a 100644 --- a/no_light_sinatra.rb +++ b/no_light_sinatra.rb @@ -13,17 +13,13 @@ class NoLightSinatra < Sinatra::Base use Airbrake::Rack::Middleware unless ENV['RACK_ENV'] == 'test' enable :sessions - use OmniAuth::Builder do - provider :mlh, ENV['MY_MLH_KEY'], ENV['MY_MLH_SECRET'], scope: 'default' - end - set public_folder: 'public', static: true configure do DEFAULT_BRANDING = '' ENVIRONMENTS = { - 'development' => { 'uri' => 'mongodb://localhost/no_light_development' }, - 'test' => { 'uri' => 'mongodb://localhost/no_light_test' }, + 'development' => { 'uri' => 'mongodb://192.168.0.40/no_light_development' }, + 'test' => { 'uri' => 'mongodb://192.168.0.40/no_light_test' }, 'production' => { 'uri' => ENV['MONGODB_URI'] } } @@ -39,81 +35,45 @@ class NoLightSinatra < Sinatra::Base erb :default_page end - get '/auth/mlh/callback' do - auth = request.env["omniauth.auth"] - session[:user_id] = auth["uid"] - session[:full_name] = "#{auth[:info][:first_name]} #{auth[:info][:last_name]}" - next_page = session[:redirect] - - if next_page - session[:redirect] = nil - redirect '%s' % next_page - else - redirect '/' - end - end - - get '/logout' do - session.clear - redirect '/' - end - + post '/submit' do - authorize do - @submission = Submission.new(get_submit_params) - - if @submission.already_exists? - erb :error, locals: { - title: "Error - Already Submitted", - message: "You have already submitted this code under your name (\"#{@submission.name}\")." - } - else - @submission.save - erb :submitted - end + @submission = Submission.new(get_submit_params) + if @submission.already_exists? + erb :error, locals: { + title: "Error - Already Submitted", + message: "You have already submitted this code under your name (\"#{@submission.name}\")." + } + else + @submission.save + erb :submitted end end get '/:hackathon.zip' do - authorize do - @submissions = Submission.by_hackathon(params[:hackathon]) + @submissions = Submission.by_hackathon(params[:hackathon]) - if @submissions.count > 0 - create_zip_folder(@submissions) - set_response_headers - download_zip_folder - else - erb :error, locals: { - title: "Error - No Submissions", - message: "We did not receive any submissions for your event (\"#{params[:hackathon]}\")." - } - end + if @submissions.count > 0 + create_zip_folder(@submissions) + set_response_headers + download_zip_folder + else + erb :error, locals: { + title: "Error - No Submissions", + message: "We did not receive any submissions for your event (\"#{params[:hackathon]}\")." + } end end get '/:hackathon' do - authorize do - show_editor(DEFAULT_BRANDING) - end + show_editor(DEFAULT_BRANDING) end get '/:hackathon/:branding?' do - authorize do - show_editor(params[:branding]) - end + show_editor(params[:branding]) end private - def authorize - if session[:user_id] - yield - else - session[:redirect] = request.fullpath - redirect '/auth/mlh' - end - end - def show_editor(custom_branding) @body_class = ['editor', custom_branding].join(' ') erb :editor @@ -127,7 +87,7 @@ def get_submit_params get_submit_params = params[:submission] || {} get_submit_params.merge({ 'seconds' => seconds_from(params[:submission][:seconds]), - 'name' => session[:full_name] + 'name' => params[:submission][:name] }) end diff --git a/public/css/extended.css b/public/css/extended.css index 213d93c..683aff3 100644 --- a/public/css/extended.css +++ b/public/css/extended.css @@ -5,11 +5,6 @@ src: url('/fonts/code-new-roman.otf'); } -@font-face { - font-family: 'MLH Outage'; - src: url('/fonts/outage.ttf'); -} - /** GENERAL STYLING **/ html, body { @@ -35,22 +30,14 @@ body.editor { text-align: center; } -/** LOGO **/ - -#container a.mlh { - display: block; - - background: url("/img/mlh/mlh.png") no-repeat center center; - background-size: auto 90px; - - width: 100%; - height: 180px; -} - #container img { max-width: 40%; } +#gamelink { + color: #333; +} + /** HEADER **/ header { @@ -70,7 +57,7 @@ header #submit { padding: 15px; background: #999; vertical-align: top; - font-family: 'MLH Outage', 'Arial', 'Verdana', 'Times New Roman'; + font-family: 'Arial', 'Verdana', 'Times New Roman'; } header #submit:active { @@ -120,7 +107,7 @@ form { border-bottom: 2px solid #eee; color: #333; margin: 20px 0; - font-family: 'MLH Outage', 'Arial', 'Verdana', 'Times New Roman'; + font-family: 'Arial', 'Verdana', 'Times New Roman'; } #container h1.error { diff --git a/public/fonts/outage.ttf b/public/fonts/outage.ttf deleted file mode 100644 index 636ce1c..0000000 Binary files a/public/fonts/outage.ttf and /dev/null differ diff --git a/public/img/mlh/mlh-white.png b/public/img/mlh/mlh-white.png deleted file mode 100644 index 6bc14ed..0000000 Binary files a/public/img/mlh/mlh-white.png and /dev/null differ diff --git a/public/img/mlh/mlh.png b/public/img/mlh/mlh.png deleted file mode 100644 index dc32b6c..0000000 Binary files a/public/img/mlh/mlh.png and /dev/null differ diff --git a/public/img/sponsors/blackrock.png b/public/img/sponsors/blackrock.png deleted file mode 100644 index 9cbda58..0000000 Binary files a/public/img/sponsors/blackrock.png and /dev/null differ diff --git a/public/img/sponsors/bloomberg.png b/public/img/sponsors/bloomberg.png deleted file mode 100644 index 03a55c9..0000000 Binary files a/public/img/sponsors/bloomberg.png and /dev/null differ diff --git a/public/img/sponsors/dell-windows.png b/public/img/sponsors/dell-windows.png deleted file mode 100644 index 836c2d3..0000000 Binary files a/public/img/sponsors/dell-windows.png and /dev/null differ diff --git a/public/img/sponsors/github.png b/public/img/sponsors/github.png deleted file mode 100644 index 74b8818..0000000 Binary files a/public/img/sponsors/github.png and /dev/null differ diff --git a/public/img/sponsors/kcl.png b/public/img/sponsors/kcl.png deleted file mode 100644 index 4b2f065..0000000 Binary files a/public/img/sponsors/kcl.png and /dev/null differ diff --git a/views/default_page.erb b/views/default_page.erb index e9eef55..b05a44d 100644 --- a/views/default_page.erb +++ b/views/default_page.erb @@ -1,6 +1,4 @@
\ No newline at end of file +To play, click here
+ diff --git a/views/editor.erb b/views/editor.erb index 8ea77b5..53f7b2f 100644 --- a/views/editor.erb +++ b/views/editor.erb @@ -3,12 +3,8 @@