From e2cb0fe8aa59893208ade3e0bf5ecc1846b0bbca Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sat, 7 Jun 2014 12:45:36 +0100 Subject: [PATCH 01/18] Fixes body background --- .../stylesheets/themes/default/layout/_body.scss | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/themes/default/layout/_body.scss b/app/assets/stylesheets/themes/default/layout/_body.scss index 5cb8079..a25a1fd 100644 --- a/app/assets/stylesheets/themes/default/layout/_body.scss +++ b/app/assets/stylesheets/themes/default/layout/_body.scss @@ -4,6 +4,15 @@ $container-padding: 2em; +html { + background: { + color: $blue; + image: image-url("#{$theme-path}/layout/background.jpg"); + position: top center; + repeat: no-repeat; + } +} + html, body { margin: 0; @@ -18,12 +27,6 @@ body#tinymce { #container { min-height: 100%; - background: { - color: $blue; - image: image-url("#{$theme-path}/layout/background.jpg"); - position: top center; - repeat: no-repeat; - } } .wrapper { From f2ab3482fd97722f5a7453830ae334e0bb6dda4d Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Mon, 16 Jun 2014 15:10:41 +0100 Subject: [PATCH 02/18] Bump ruby to 2.1.2 See: http://www.omniref.com/blog/blog/2014/03/27/ruby-garbage-collection-still-not-ready-for-production/ --- .travis.yml | 2 +- Gemfile | 8 ++++--- Gemfile.lock | 22 +++++++------------- app/assets/javascripts/application.js.coffee | 2 +- app/assets/stylesheets/application.scss | 1 + config/deploy.rb | 3 ++- 6 files changed, 17 insertions(+), 21 deletions(-) create mode 100644 app/assets/stylesheets/application.scss diff --git a/.travis.yml b/.travis.yml index c6c4ccf..6be0efd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ addons: code_climate: repo_token: b3db5b7df9a0a1d0fd3503e72d7431ffbfa172492c2840d590ccb2fafd9172d3 rvm: - - 2.1.1 + - 2.1.2 env: - MYSQL_USERNAME=travis script: diff --git a/Gemfile b/Gemfile index 3be9603..2960242 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -ruby '2.1.1' +ruby '2.1.2' gem 'dotenv-rails', '~> 0.10.0' gem 'rails', '~> 3.2.18' @@ -17,7 +17,6 @@ gem 'bbcoder', '~> 1.0.1' gem 'sanitize', '~> 2.1.0' gem 'carrierwave', '~> 0.10.0' gem 'bluecloth', '~> 2.2.0' -gem 'therubyracer', '~> 0.12.1' gem 'newrelic_rpm', '~> 3.7.2.195' gem 'will_paginate', '~> 3.0.5' gem 'dynamic_form', '~> 1.1.4' @@ -25,6 +24,9 @@ gem 'country_code_select', '~> 1.0.1' gem 'active_link_to', '~> 1.0.2' gem 'rmagick', '~> 2.13.2', require: false +# Please install nodejs locally. +gem 'therubyracer', '~> 0.12.1' if RUBY_PLATFORM == 'x86_64-linux' + gem 'sprockets', '~> 2.2.1' gem 'coffee-rails', '~> 3.2.2' gem 'jquery-rails', '~> 2.0.2' @@ -66,5 +68,5 @@ group :test do end group :development, :test do - gem 'pry-debugger', '~> 0.2.2' + gem 'pry-byebug', '~> 1.3.2' end diff --git a/Gemfile.lock b/Gemfile.lock index 4b3bfc9..193b327 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,6 +45,9 @@ GEM sass (>= 3.2.0) thor builder (3.0.4) + byebug (2.7.0) + columnize (~> 0.3) + debugger-linecache (~> 1.2) capistrano (3.1.0) i18n rake (>= 10.0.0) @@ -88,12 +91,7 @@ GEM dalli (2.7.1) database_cleaner (1.2.0) debug_inspector (0.0.2) - debugger (1.6.6) - columnize (>= 0.3.1) - debugger-linecache (~> 1.2.0) - debugger-ruby_core_source (~> 1.3.2) debugger-linecache (1.2.0) - debugger-ruby_core_source (1.3.4) diff-lcs (1.2.5) dotenv (0.10.0) dotenv-rails (0.10.0) @@ -123,7 +121,6 @@ GEM railties (>= 3.1.0, < 5.0) thor (~> 0.14) json (1.8.1) - libv8 (3.16.14.3) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) @@ -153,9 +150,9 @@ GEM coderay (~> 1.0) method_source (~> 0.8) slop (~> 3.4) - pry-debugger (0.2.2) - debugger (~> 1.3) - pry (~> 0.9.10) + pry-byebug (1.3.2) + byebug (~> 2.7) + pry (~> 0.9.12) puma (2.8.2) rack (>= 1.1, < 2.0) quiet_assets (1.0.2) @@ -187,7 +184,6 @@ GEM rake (10.3.1) rdoc (3.12.2) json (~> 1.4) - ref (1.0.5) rmagick (2.13.2) rspec-core (2.14.8) rspec-expectations (2.14.5) @@ -230,9 +226,6 @@ GEM term-ansicolor term-ansicolor (1.3.0) tins (~> 1.0) - therubyracer (0.12.1) - libv8 (~> 3.16.14.0) - ref thor (0.19.1) tilt (1.4.1) timecop (0.7.1) @@ -289,7 +282,7 @@ DEPENDENCIES nokogiri (~> 1.6.1) oj (~> 2.5.5) poltergeist (~> 1.5.0) - pry-debugger (~> 0.2.2) + pry-byebug (~> 1.3.2) puma (~> 2.8.2) quiet_assets (~> 1.0.2) rails (~> 3.2.18) @@ -302,7 +295,6 @@ DEPENDENCIES selenium-webdriver (~> 2.41.0) simplecov (~> 0.7.1) sprockets (~> 2.2.1) - therubyracer (~> 0.12.1) timecop (~> 0.7.1) tinymce-rails (~> 3.5.9) uglifier (~> 2.5.0) diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index 63237c4..29a6f8f 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -34,4 +34,4 @@ $ -> $('select.autosubmit').change -> $(this).closest('form').submit() - $('#notification').delay(3000).fadeOut() \ No newline at end of file + $('#notification').delay(3000).fadeOut() \ No newline at end of file diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss new file mode 100644 index 0000000..2af6646 --- /dev/null +++ b/app/assets/stylesheets/application.scss @@ -0,0 +1 @@ +// Placeholder - Sprockets doesn't like that this file may not exist \ No newline at end of file diff --git a/config/deploy.rb b/config/deploy.rb index 5cf56bf..e2ae9ca 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -9,7 +9,8 @@ set :repo_url, 'https://github.com/ENSL/ensl.org.git' set :keep_releases, 10 set :rbenv_type, :user -set :rbenv_ruby, '2.1.1' +set :rbenv_ruby, '2.1.2' +set :bundle_flags, '--quiet' set :dotenv_role, [:app, :web] set :puma_config, -> { File.join(current_path, 'config', 'puma.rb') } From 73bb575982b2b773ba11f849dcf0ac98cf1009ea Mon Sep 17 00:00:00 2001 From: Ari Timonen Date: Tue, 1 Jul 2014 14:39:40 +0300 Subject: [PATCH 03/18] Fix rules --- app/helpers/application_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 55be21c..9f01cac 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -175,7 +175,7 @@ module ApplicationHelper def latest_rules if Contest.last - Contest.last.rules + article_path(Contest.last.rules) else article_path(Article::RULES) end From 0a9c97db17234eef9bc366152f367b3a5833aa33 Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sun, 10 Aug 2014 18:21:53 +0100 Subject: [PATCH 04/18] Bump rails and puma versions --- Gemfile | 6 ++--- Gemfile.lock | 66 ++++++++++++++++++++++++++-------------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Gemfile b/Gemfile index 2960242..cab573d 100644 --- a/Gemfile +++ b/Gemfile @@ -3,10 +3,10 @@ source 'http://rubygems.org' ruby '2.1.2' gem 'dotenv-rails', '~> 0.10.0' -gem 'rails', '~> 3.2.18' +gem 'rails', '~> 3.2.19' gem 'mysql2', '~> 0.3.15' gem 'dalli', '~> 2.7.0' -gem 'puma', '~> 2.8.2' +gem 'puma', '~> 2.9.0' gem 'exceptional', '~> 2.0.33' gem 'oj', '~> 2.5.5' @@ -37,7 +37,7 @@ gem 'sass-rails', '~> 3.2.6' gem 'font-awesome-sass', '~> 4.1.0.0' gem 'bourbon', '~> 3.1.8' gem 'neat', '~> 1.6.0' -gem 'haml' +gem 'haml', '~> 4.0.5' gem 'rails_autolink', '~> 1.1.5' group :assets do diff --git a/Gemfile.lock b/Gemfile.lock index 193b327..ddc067b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GEM remote: http://rubygems.org/ specs: - actionmailer (3.2.18) - actionpack (= 3.2.18) + actionmailer (3.2.19) + actionpack (= 3.2.19) mail (~> 2.5.4) - actionpack (3.2.18) - activemodel (= 3.2.18) - activesupport (= 3.2.18) + actionpack (3.2.19) + activemodel (= 3.2.19) + activesupport (= 3.2.19) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.4) @@ -16,18 +16,18 @@ GEM sprockets (~> 2.2.1) active_link_to (1.0.2) actionpack - activemodel (3.2.18) - activesupport (= 3.2.18) + activemodel (3.2.19) + activesupport (= 3.2.19) builder (~> 3.0.0) - activerecord (3.2.18) - activemodel (= 3.2.18) - activesupport (= 3.2.18) + activerecord (3.2.19) + activemodel (= 3.2.19) + activesupport (= 3.2.19) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.2.18) - activemodel (= 3.2.18) - activesupport (= 3.2.18) - activesupport (3.2.18) + activeresource (3.2.19) + activemodel (= 3.2.19) + activesupport (= 3.2.19) + activesupport (3.2.19) i18n (~> 0.6, >= 0.6.4) multi_json (~> 1.0) annotate (2.6.3) @@ -115,7 +115,7 @@ GEM haml (4.0.5) tilt hike (1.2.3) - i18n (0.6.9) + i18n (0.6.11) journey (1.0.4) jquery-rails (2.0.3) railties (>= 3.1.0, < 5.0) @@ -127,7 +127,7 @@ GEM method_source (0.8.2) mime-types (1.25.1) mini_portile (0.5.3) - multi_json (1.10.0) + multi_json (1.10.1) multipart-post (2.0.0) mysql2 (0.3.15) neat (1.6.0) @@ -145,7 +145,7 @@ GEM cliver (~> 0.3.1) multi_json (~> 1.0) websocket-driver (>= 0.2.0) - polyglot (0.3.4) + polyglot (0.3.5) pry (0.9.12.6) coderay (~> 1.0) method_source (~> 0.8) @@ -153,7 +153,7 @@ GEM pry-byebug (1.3.2) byebug (~> 2.7) pry (~> 0.9.12) - puma (2.8.2) + puma (2.9.0) rack (>= 1.1, < 2.0) quiet_assets (1.0.2) railties (>= 3.1, < 5.0) @@ -164,24 +164,24 @@ GEM rack rack-test (0.6.2) rack (>= 1.0) - rails (3.2.18) - actionmailer (= 3.2.18) - actionpack (= 3.2.18) - activerecord (= 3.2.18) - activeresource (= 3.2.18) - activesupport (= 3.2.18) + rails (3.2.19) + actionmailer (= 3.2.19) + actionpack (= 3.2.19) + activerecord (= 3.2.19) + activeresource (= 3.2.19) + activesupport (= 3.2.19) bundler (~> 1.0) - railties (= 3.2.18) + railties (= 3.2.19) rails_autolink (1.1.5) rails (> 3.1) - railties (3.2.18) - actionpack (= 3.2.18) - activesupport (= 3.2.18) + railties (3.2.19) + actionpack (= 3.2.19) + activesupport (= 3.2.19) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) - rake (10.3.1) + rake (10.3.2) rdoc (3.12.2) json (~> 1.4) rmagick (2.13.2) @@ -235,7 +235,7 @@ GEM treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.39) + tzinfo (0.3.41) uglifier (2.5.0) execjs (>= 0.3.0) json (>= 1.8.0) @@ -274,7 +274,7 @@ DEPENDENCIES faraday (~> 0.9.0) font-awesome-sass (~> 4.1.0.0) gruff (~> 0.3.6) - haml + haml (~> 4.0.5) jquery-rails (~> 2.0.2) mysql2 (~> 0.3.15) neat (~> 1.6.0) @@ -283,9 +283,9 @@ DEPENDENCIES oj (~> 2.5.5) poltergeist (~> 1.5.0) pry-byebug (~> 1.3.2) - puma (~> 2.8.2) + puma (~> 2.9.0) quiet_assets (~> 1.0.2) - rails (~> 3.2.18) + rails (~> 3.2.19) rails_autolink (~> 1.1.5) rmagick (~> 2.13.2) rspec-rails (~> 2.14.1) From 8b3850acf87580bacb8a12dad96379b2601072fd Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sun, 10 Aug 2014 18:33:48 +0100 Subject: [PATCH 05/18] Fixes error when viewing team pages when not logged in --- app/views/teams/show.html.erb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/views/teams/show.html.erb b/app/views/teams/show.html.erb index 59677ca..f0e2deb 100644 --- a/app/views/teams/show.html.erb +++ b/app/views/teams/show.html.erb @@ -9,18 +9,20 @@ <% end %> - <% if cuser.teamers.joining.count == 0 && @team.active %> - <%= form_for @teamer do |f| %> - <%= f.error_messages %> - <%= f.hidden_field :user_id, :value => cuser.id %> - <%= f.hidden_field :team_id, :value => @team.id %> + <% if cuser && cuser.teamers %> + <% if cuser.teamers.joining.count == 0 && @team.active %> + <%= form_for @teamer do |f| %> + <%= f.error_messages %> + <%= f.hidden_field :user_id, :value => cuser.id %> + <%= f.hidden_field :team_id, :value => @team.id %> -
- <%= f.submit "Request To Join", class: 'button' %> -
+
+ <%= f.submit "Request To Join", class: 'button' %> +
+ <% end %> + <% elsif cuser.teamers.joining.first.team != @team %> + <%= link_to 'Request To Join', edit_teamer_path("teamer" => cuser.teamers.joining.first), method: :get,confirm: "You have already requested to join #{cuser.teamers.joining.first.team}. Do you want to request to join #{@team} instead?", class: 'button' %> <% end %> - <% elsif cuser.teamers.joining.first.team != @team %> - <%= link_to 'Request To Join', edit_teamer_path("teamer" => cuser.teamers.joining.first), method: :get,confirm: "You have already requested to join #{cuser.teamers.joining.first.team}. Do you want to request to join #{@team} instead?", class: 'button' %> <% end %>
From 5900a6602f281ffc4513fe1542aadce51dd81d64 Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sun, 10 Aug 2014 18:33:59 +0100 Subject: [PATCH 06/18] Don't bundle for deployment on CI --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6be0efd..0f10c7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: ruby cache: bundler +bundler_args: '' addons: code_climate: repo_token: b3db5b7df9a0a1d0fd3503e72d7431ffbfa172492c2840d590ccb2fafd9172d3 From d40e0e4c46128b21bebfb5592b0687eb53406aa8 Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sun, 10 Aug 2014 20:41:05 +0100 Subject: [PATCH 07/18] Fixes forum topic ordering by latest post --- app/controllers/forums_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 890b0ae..0c2e6d9 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -11,9 +11,10 @@ class ForumsController < ApplicationController raise AccessError unless @forum.can_show? cuser @topics = Topic.where(forum_id: @forum.id) - .includes(:posts, :user, :users_who_read, :lock) + .joins(posts: :user) + .includes(:lock, :readings) .group('topics.id') - .order('state DESC, posts.id DESC') + .order('state DESC, (SELECT created_at FROM posts p2 WHERE p2.topic_id = topics.id ORDER BY created_at DESC LIMIT 1) DESC') .paginate(page: params[:page], per_page: 30) @forum.read_by! cuser if cuser From 8d6ad516458299d4d25fb1d6c1c6f87aee0386c2 Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sun, 10 Aug 2014 21:15:23 +0100 Subject: [PATCH 08/18] Get selenium working on travisci --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0f10c7b..931580a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,9 @@ rvm: - 2.1.2 env: - MYSQL_USERNAME=travis +before_script: + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start script: - RAILS_ENV=test bundle exec rake db:create db:migrate db:test:prepare - RAILS_ENV=test bundle exec rspec spec From 5576dd6cac3ea9b52e8c94f77160af1ea65f177d Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sun, 10 Aug 2014 21:33:22 +0100 Subject: [PATCH 09/18] Added missing env variable for TravicCI --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 931580a..a44d372 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ rvm: - 2.1.2 env: - MYSQL_USERNAME=travis + - APP_SECRET=2d3a08dfea079fe45bcb7f830b010eda before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start From 294edc77a942c8241d006297777ea4c7831ccec6 Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sun, 10 Aug 2014 21:55:44 +0100 Subject: [PATCH 10/18] Increase Capybara timeout --- spec/spec_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b52f246..bb757ab 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,9 +10,10 @@ require 'rspec/rails' require 'capybara/rspec' require 'capybara/poltergeist' +Capybara.default_wait_time = 30 Capybara.register_driver :poltergeist do |app| Capybara::Poltergeist::Driver.new(app, - timeout: 15, + timeout: 30, phantomjs_logger: File.open('/dev/null') ) end From 7d21773546c9e45e973103f86554ca245e755a0d Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sun, 10 Aug 2014 23:52:01 +0100 Subject: [PATCH 11/18] Remove TS3 Password --- app/views/gathers/show.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/gathers/show.html.erb b/app/views/gathers/show.html.erb index 7f4f160..958f0a8 100644 --- a/app/views/gathers/show.html.erb +++ b/app/views/gathers/show.html.erb @@ -89,7 +89,6 @@
  • <%= link_to "Teamspeak 3", "http://www.teamspeak.com/?page=downloads" %>
  • Server: ensl.org
  • -
  • Password: ns2nsl
From eee3c1c9054943f377526c671f71f3ed19d4f43e Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sun, 10 Aug 2014 23:56:18 +0100 Subject: [PATCH 12/18] Added site layout configuration for users --- app/helpers/application_helper.rb | 6 ++- app/models/user.rb | 4 ++ app/views/users/edit.html.erb | 6 +++ .../20140810224606_add_layout_to_profile.rb | 5 ++ db/schema.rb | 49 ++++++++++++++++++- 5 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20140810224606_add_layout_to_profile.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9f01cac..2e74fbe 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -10,7 +10,11 @@ module ApplicationHelper end def active_theme - 'default' + if cuser && cuser.profile + cuser.current_layout + else + 'default' + end end def theme_stylesheet_link_tag diff --git a/app/models/user.rb b/app/models/user.rb index bd284d8..86d0da7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -177,6 +177,10 @@ class User < ActiveRecord::Base a end + def current_layout + profile.layout || 'default' + end + def joined created_at.strftime("%d %b %y") end diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 45188eb..b9a17de 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -109,6 +109,12 @@

Daylight savings will be observed automatically.

+
+ <%= p.label :layout %> +
+ <%= p.select :layout, ['default', 'flat'] %> +
+
diff --git a/db/migrate/20140810224606_add_layout_to_profile.rb b/db/migrate/20140810224606_add_layout_to_profile.rb new file mode 100644 index 0000000..8279800 --- /dev/null +++ b/db/migrate/20140810224606_add_layout_to_profile.rb @@ -0,0 +1,5 @@ +class AddLayoutToProfile < ActiveRecord::Migration + def change + add_column :profiles, :layout, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index bc13abc..f58c688 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,21 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140510080652) do +ActiveRecord::Schema.define(:version => 20140810224606) do + + create_table "admin_requests", :force => true do |t| + t.string "addr" + t.string "pwd" + t.integer "server_id" + t.string "player" + t.integer "user_id" + t.string "msg" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "admin_requests", ["server_id"], :name => "index_admin_requests_on_server_id" + add_index "admin_requests", ["user_id"], :name => "index_admin_requests_on_user_id" create_table "article_versions", :force => true do |t| t.integer "article_id" @@ -200,6 +214,16 @@ ActiveRecord::Schema.define(:version => 20140510080652) do add_index "data_files", ["directory_id"], :name => "index_data_files_on_directory_id" add_index "data_files", ["related_id"], :name => "index_data_files_on_related_id" + create_table "deleteds", :force => true do |t| + t.integer "deletable_id" + t.string "deletable_type" + t.integer "user_id" + t.text "reason" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "related_id" + end + create_table "directories", :force => true do |t| t.string "name" t.string "description" @@ -212,6 +236,21 @@ ActiveRecord::Schema.define(:version => 20140510080652) do add_index "directories", ["parent_id"], :name => "index_directories_on_parent_id" + create_table "firms", :force => true do |t| + t.string "name" + t.string "y_code" + t.string "email" + t.string "website" + t.string "phone" + t.string "address" + t.integer "zipcode" + t.string "town" + t.integer "owner" + t.string "opentime" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "forumers", :force => true do |t| t.integer "forum_id" t.integer "group_id" @@ -478,6 +517,13 @@ ActiveRecord::Schema.define(:version => 20140510080652) do add_index "movies", ["status"], :name => "index_movies_on_status" add_index "movies", ["user_id"], :name => "index_movies_on_user_id" + create_table "nodes", :force => true do |t| + t.string "name" + t.integer "foreign_key" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "options", :force => true do |t| t.string "option" t.integer "poll_id" @@ -587,6 +633,7 @@ ActiveRecord::Schema.define(:version => 20140510080652) do t.string "achievements_parsed" t.string "signature_parsed" t.string "stream" + t.string "layout" end add_index "profiles", ["user_id"], :name => "index_profiles_on_user_id" From 68b6c15b4f11c786181a65ce82d38ab0c944804e Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Mon, 11 Aug 2014 00:10:40 +0100 Subject: [PATCH 13/18] Check for upcoming matches before showing the calendar --- app/views/widgets/_calendar.html.erb | 34 +++++++++++++++------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/app/views/widgets/_calendar.html.erb b/app/views/widgets/_calendar.html.erb index 1936f34..ccb3094 100644 --- a/app/views/widgets/_calendar.html.erb +++ b/app/views/widgets/_calendar.html.erb @@ -1,19 +1,21 @@ -
-

<%= t('widget.schedule') %>

+<% if upcoming_matches.size > 0 %> +
+

<%= t('widget.schedule') %>

-
- <% upcoming_matches.group_by{ |e| e.start.month }.each do |month, events| %> - <% events.group_by { |e| e.start.day }.each do |day, day_events| %> -
<%= day_events.first.start.strftime("%A, %e %B") %>
- <% day_events.each do |event| %> -
-

- <%= event.start.strftime("%H:%M %Z") %> - <%= event.formatted_summary %> -

-
- <% end %> +
+ <% upcoming_matches.group_by{ |e| e.start.month }.each do |month, events| %> + <% events.group_by { |e| e.start.day }.each do |day, day_events| %> +
<%= day_events.first.start.strftime("%A, %e %B") %>
+ <% day_events.each do |event| %> +
+

+ <%= event.start.strftime("%H:%M %Z") %> + <%= event.formatted_summary %> +

+
+ <% end %> + <% end %> <% end %> - <% end %> +
-
\ No newline at end of file +<% end %> From a676d4c42355f6ed607249ab81af774d4b3e8ee0 Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Thu, 28 Aug 2014 21:43:11 +0100 Subject: [PATCH 14/18] Added steam profile lookup API endpoint --- Gemfile | 1 + Gemfile.lock | 10 ++++++++++ app/assets/javascripts/application.js.coffee | 13 ++++++++++++- app/controllers/api/v1/users_controller.rb | 14 +++++++++++++- app/views/users/_general.html.erb | 6 ++++-- config/routes.rb | 14 +++++++------- 6 files changed, 47 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index cab573d..34b7d6d 100644 --- a/Gemfile +++ b/Gemfile @@ -23,6 +23,7 @@ gem 'dynamic_form', '~> 1.1.4' gem 'country_code_select', '~> 1.0.1' gem 'active_link_to', '~> 1.0.2' gem 'rmagick', '~> 2.13.2', require: false +gem 'steam-condenser', github: 'koraktor/steam-condenser-ruby' # Please install nodejs locally. gem 'therubyracer', '~> 0.12.1' if RUBY_PLATFORM == 'x86_64-linux' diff --git a/Gemfile.lock b/Gemfile.lock index ddc067b..11f37e6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,11 @@ +GIT + remote: git://github.com/koraktor/steam-condenser-ruby.git + revision: c8a7b69d3dc73d56c1de6b6653ec45491d047db1 + specs: + steam-condenser (1.3.9) + multi_json (~> 1.6) + multi_xml (~> 0.5) + GEM remote: http://rubygems.org/ specs: @@ -128,6 +136,7 @@ GEM mime-types (1.25.1) mini_portile (0.5.3) multi_json (1.10.1) + multi_xml (0.5.5) multipart-post (2.0.0) mysql2 (0.3.15) neat (1.6.0) @@ -295,6 +304,7 @@ DEPENDENCIES selenium-webdriver (~> 2.41.0) simplecov (~> 0.7.1) sprockets (~> 2.2.1) + steam-condenser! timecop (~> 0.7.1) tinymce-rails (~> 3.5.9) uglifier (~> 2.5.0) diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index 29a6f8f..cc5b14b 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -34,4 +34,15 @@ $ -> $('select.autosubmit').change -> $(this).closest('form').submit() - $('#notification').delay(3000).fadeOut() \ No newline at end of file + $('#notification').delay(3000).fadeOut() + + $('#steam-search a').click (event) -> + event.preventDefault() + + $search = $('#steam-search') + id = $search.data 'user-id' + + $search.html "

Searching...

" + + $.get "/api/v1/users/#{id}", (data) -> + $search.html "Steam Profile: #{data.steam.nickname}" diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 1898db6..95128cf 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -1,5 +1,17 @@ class Api::V1::UsersController < Api::V1::BaseController def index - respond_with Api::V1::UsersCollection.as_json + render json: Api::V1::UsersCollection.as_json + end + + def show + @user = User.find(params[:id]) + @steam = SteamCondenser::Community::SteamId.from_steam_id("STEAM_#{@user.steamid}") + + render json: { + steam: { + url: @steam.base_url, + nickname: @steam.nickname + } + } end end diff --git a/app/views/users/_general.html.erb b/app/views/users/_general.html.erb index 509f423..4dfb4c6 100644 --- a/app/views/users/_general.html.erb +++ b/app/views/users/_general.html.erb @@ -10,8 +10,10 @@
<%= @user.profile.town %>
SteamID
- <%= @user.steamid %> - <%= link_to "Search for Steam Account", "http://steamidfinder.com/?STEAM_#{@user.steamid}" %> +

<%= @user.steamid %>

+
diff --git a/config/routes.rb b/config/routes.rb index ba366eb..7cf11e2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,8 +1,14 @@ -Ensl::Application.routes.draw do +Ensl::Application.routes.draw do %w(403 404 422 500).each do |code| get code, to: 'errors#show', code: code end + namespace :api do + namespace :v1 do + resources :users, only: [:show, :index] + end + end + root to: "articles#news_index" resources :articles do @@ -130,10 +136,4 @@ Ensl::Application.routes.draw do match ':controller/:action/:id/:id2' match 'teamers/replace', to: 'teamers#replace', as: 'teamers_replace' - - namespace :api do - namespace :v1 do - resources :users - end - end end From 127b5f6308e34704631afa78024f8574218bd59e Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Thu, 28 Aug 2014 23:43:15 +0100 Subject: [PATCH 15/18] Hotfix: Rollback rules url helper --- app/helpers/application_helper.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2e74fbe..2c44635 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -178,10 +178,6 @@ module ApplicationHelper end def latest_rules - if Contest.last - article_path(Contest.last.rules) - else - article_path(Article::RULES) - end + article_path(Article::RULES) end end From 2535d5bc7a21f711de8eaf8dbb1d2684c0ab0476 Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sat, 27 Sep 2014 19:11:19 +0100 Subject: [PATCH 16/18] Update rules article constant --- app/models/article.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/article.rb b/app/models/article.rb index c0c5128..0a5b6d0 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -24,7 +24,7 @@ class Article < ActiveRecord::Base STATUS_PUBLISHED = 0 STATUS_DRAFT = 1 - RULES = 400 + RULES = 859 HISTORY = 401 HOF = 402 SPONSORS = 403 From 847ea18f17688164c46ed7be59b8c070f980d4ec Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sat, 27 Sep 2014 19:42:24 +0100 Subject: [PATCH 17/18] Bump Ruby and puma versions --- Gemfile | 4 ++-- Gemfile.lock | 4 ++-- config/deploy.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 34b7d6d..fd44e33 100644 --- a/Gemfile +++ b/Gemfile @@ -1,12 +1,12 @@ source 'http://rubygems.org' -ruby '2.1.2' +ruby '2.1.3' gem 'dotenv-rails', '~> 0.10.0' gem 'rails', '~> 3.2.19' gem 'mysql2', '~> 0.3.15' gem 'dalli', '~> 2.7.0' -gem 'puma', '~> 2.9.0' +gem 'puma', '~> 2.9.1' gem 'exceptional', '~> 2.0.33' gem 'oj', '~> 2.5.5' diff --git a/Gemfile.lock b/Gemfile.lock index 11f37e6..277b057 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -162,7 +162,7 @@ GEM pry-byebug (1.3.2) byebug (~> 2.7) pry (~> 0.9.12) - puma (2.9.0) + puma (2.9.1) rack (>= 1.1, < 2.0) quiet_assets (1.0.2) railties (>= 3.1, < 5.0) @@ -292,7 +292,7 @@ DEPENDENCIES oj (~> 2.5.5) poltergeist (~> 1.5.0) pry-byebug (~> 1.3.2) - puma (~> 2.9.0) + puma (~> 2.9.1) quiet_assets (~> 1.0.2) rails (~> 3.2.19) rails_autolink (~> 1.1.5) diff --git a/config/deploy.rb b/config/deploy.rb index e2ae9ca..f4ce51e 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -9,7 +9,7 @@ set :repo_url, 'https://github.com/ENSL/ensl.org.git' set :keep_releases, 10 set :rbenv_type, :user -set :rbenv_ruby, '2.1.2' +set :rbenv_ruby, '2.1.3' set :bundle_flags, '--quiet' set :dotenv_role, [:app, :web] From 52e840a0416ef52f9cd15c68d9f9c70a80464948 Mon Sep 17 00:00:00 2001 From: Ari Timonen Date: Thu, 2 Apr 2015 04:01:41 +0300 Subject: [PATCH 18/18] Fix timezone parsing for google calendar --- Gemfile | 2 +- app/models/gather.rb | 4 +-- app/services/google_calendar.rb | 4 +-- db/schema.rb | 49 ++------------------------------- 4 files changed, 7 insertions(+), 52 deletions(-) diff --git a/Gemfile b/Gemfile index fd44e33..3a53b48 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -ruby '2.1.3' +ruby '2.2.1' gem 'dotenv-rails', '~> 0.10.0' gem 'rails', '~> 3.2.19' diff --git a/app/models/gather.rb b/app/models/gather.rb index 21507a2..44b774f 100644 --- a/app/models/gather.rb +++ b/app/models/gather.rb @@ -70,8 +70,8 @@ class Gather < ActiveRecord::Base def self.player_count_for_game(name) game = self.find_game(name) - if game && players = game.gathers.ordered.first.gatherers - players.size + if game && (players = game.gathers.ordered.first.gatherers.count) + players else 0 end diff --git a/app/services/google_calendar.rb b/app/services/google_calendar.rb index 96cc92b..21f350f 100644 --- a/app/services/google_calendar.rb +++ b/app/services/google_calendar.rb @@ -98,11 +98,11 @@ class GoogleCalendar end def start - Time.use_zone(@timezone_offset) { Time.zone.parse(@entry["start"]["dateTime"]) } + @entry["start"]["dateTime"].to_datetime.in_time_zone(@timezone_offset) end def end - Time.use_zone(@timezone_offset) { Time.zone.parse(@entry["end"]["dateTime"]) } + @entry["end"]["dateTime"].to_datetime.in_time_zone(@timezone_offset) end def formatted_summary diff --git a/db/schema.rb b/db/schema.rb index f58c688..50b6998 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,21 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140810224606) do - - create_table "admin_requests", :force => true do |t| - t.string "addr" - t.string "pwd" - t.integer "server_id" - t.string "player" - t.integer "user_id" - t.string "msg" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "admin_requests", ["server_id"], :name => "index_admin_requests_on_server_id" - add_index "admin_requests", ["user_id"], :name => "index_admin_requests_on_user_id" +ActiveRecord::Schema.define(:version => 20141010193221) do create_table "article_versions", :force => true do |t| t.integer "article_id" @@ -214,16 +200,6 @@ ActiveRecord::Schema.define(:version => 20140810224606) do add_index "data_files", ["directory_id"], :name => "index_data_files_on_directory_id" add_index "data_files", ["related_id"], :name => "index_data_files_on_related_id" - create_table "deleteds", :force => true do |t| - t.integer "deletable_id" - t.string "deletable_type" - t.integer "user_id" - t.text "reason" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "related_id" - end - create_table "directories", :force => true do |t| t.string "name" t.string "description" @@ -236,21 +212,6 @@ ActiveRecord::Schema.define(:version => 20140810224606) do add_index "directories", ["parent_id"], :name => "index_directories_on_parent_id" - create_table "firms", :force => true do |t| - t.string "name" - t.string "y_code" - t.string "email" - t.string "website" - t.string "phone" - t.string "address" - t.integer "zipcode" - t.string "town" - t.integer "owner" - t.string "opentime" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "forumers", :force => true do |t| t.integer "forum_id" t.integer "group_id" @@ -294,6 +255,7 @@ ActiveRecord::Schema.define(:version => 20140810224606) do t.datetime "created_at" t.datetime "updated_at" t.integer "votes", :default => 0, :null => false + t.integer "status", :default => 0, :null => false end add_index "gatherers", ["gather_id"], :name => "index_gatherers_on_gather_id" @@ -517,13 +479,6 @@ ActiveRecord::Schema.define(:version => 20140810224606) do add_index "movies", ["status"], :name => "index_movies_on_status" add_index "movies", ["user_id"], :name => "index_movies_on_user_id" - create_table "nodes", :force => true do |t| - t.string "name" - t.integer "foreign_key" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "options", :force => true do |t| t.string "option" t.integer "poll_id"