some New and some old

Added some new stuff (mainly the fix for the "new" ranks suffixes) and
removed some uneeded bits.
Also changed the gemfile so it will work on Windows too.
This commit is contained in:
Jonas Folvik
2016-01-11 18:21:21 +01:00
parent d9b971ab34
commit c35a36a5c5
9 changed files with 138 additions and 125 deletions
+7 -2
View File
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
gem 'rails', '4.1.0' gem 'rails', '4.1.0'
gem 'mysql2' gem 'mysql2', '~> 0.3.18'
gem 'jquery-rails' gem 'jquery-rails'
gem 'bcrypt-ruby' # To use ActiveModel's has_secure_password gem 'bcrypt-ruby' # To use ActiveModel's has_secure_password
gem 'sanitize' gem 'sanitize'
@@ -15,6 +15,9 @@ gem 'activerecord-session_store'
gem 'highlight_js-rails', github: 'RedstonerServer/highlight_js-rails' gem 'highlight_js-rails', github: 'RedstonerServer/highlight_js-rails'
gem 'kaminari', github: 'jomo/kaminari', branch: 'patch-2' # pagination gem 'kaminari', github: 'jomo/kaminari', branch: 'patch-2' # pagination
gem 'jquery-textcomplete-rails', github: 'RedstonerServer/jquery-textcomplete-rails' # @mentions gem 'jquery-textcomplete-rails', github: 'RedstonerServer/jquery-textcomplete-rails' # @mentions
gem 'coffee-script-source', '1.8.0'
gem 'tzinfo'
gem 'tzinfo-data', '~> 1.2015', '>= 1.2015.7'
# Gems used only for assets and not required # Gems used only for assets and not required
# in production environments by default. # in production environments by default.
@@ -36,4 +39,6 @@ group :development do
end end
# Use unicorn as the app server # Use unicorn as the app server
gem 'unicorn' group :production do
# gem 'unicorn'
end
+93 -66
View File
@@ -46,7 +46,7 @@ GEM
activemodel (= 4.1.0) activemodel (= 4.1.0)
activesupport (= 4.1.0) activesupport (= 4.1.0)
arel (~> 5.0.0) arel (~> 5.0.0)
activerecord-session_store (0.1.0) activerecord-session_store (0.1.2)
actionpack (>= 4.0.0, < 5) actionpack (>= 4.0.0, < 5)
activerecord (>= 4.0.0, < 5) activerecord (>= 4.0.0, < 5)
railties (>= 4.0.0, < 5) railties (>= 4.0.0, < 5)
@@ -56,13 +56,17 @@ GEM
minitest (~> 5.1) minitest (~> 5.1)
thread_safe (~> 0.1) thread_safe (~> 0.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
arel (5.0.0) arel (5.0.1.20140414130214)
bcrypt (3.1.7) bcrypt (3.1.10)
bcrypt (3.1.10-x86-mingw32)
bcrypt-ruby (3.1.5) bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3) bcrypt (>= 3.1.3)
better_errors (1.1.0) bcrypt-ruby (3.1.5-x86-mingw32)
bcrypt (>= 3.1.3)
better_errors (2.1.1)
coderay (>= 1.0.0) coderay (>= 1.0.0)
erubis (>= 2.6.6) erubis (>= 2.6.6)
rack (>= 0.9.0)
binding_of_caller (0.7.2) binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1) debug_inspector (>= 0.0.1)
builder (3.2.2) builder (3.2.2)
@@ -73,49 +77,58 @@ GEM
capistrano-bundler (1.1.4) capistrano-bundler (1.1.4)
capistrano (~> 3.1) capistrano (~> 3.1)
sshkit (~> 1.2) sshkit (~> 1.2)
capistrano-rails (1.1.2) capistrano-rails (1.1.5)
capistrano (~> 3.1) capistrano (~> 3.1)
capistrano-bundler (~> 1.1) capistrano-bundler (~> 1.1)
capistrano-rbenv (2.0.3) capistrano-rbenv (2.0.4)
capistrano (~> 3.1) capistrano (~> 3.1)
sshkit (~> 1.3) sshkit (~> 1.3)
choice (0.1.6) choice (0.2.0)
coderay (1.1.0) coderay (1.1.0)
coffee-rails (4.0.1) coffee-rails (4.1.1)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0) railties (>= 4.0.0, < 5.1.x)
coffee-script (2.2.0) coffee-script (2.4.1)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.7.0) coffee-script-source (1.8.0)
colorize (0.7.5) concurrent-ruby (1.0.0)
crass (1.0.2)
debug_inspector (0.0.2) debug_inspector (0.0.2)
domain_name (0.5.25)
unf (>= 0.0.5, < 1.0.0)
erubis (2.7.0) erubis (2.7.0)
execjs (2.0.2) execjs (2.6.0)
hike (1.2.3) ffi (1.9.10-x86-mingw32)
hirb (0.7.1) hirb (0.7.3)
i18n (0.6.9) http-cookie (1.0.2)
jquery-rails (3.1.0) domain_name (~> 0.5)
i18n (0.7.0)
jquery-rails (3.1.4)
railties (>= 3.0, < 5.0) railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
json (1.8.1) json (1.8.3)
kgio (2.9.2)
mail (2.5.4) mail (2.5.4)
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
mime-types (1.25.1) mime-types (1.25.1)
mini_portile (0.5.3) mini_portile2 (2.0.0)
minitest (5.3.2) minitest (5.8.3)
multi_json (1.9.2) mysql2 (0.3.20)
mysql2 (0.3.15) mysql2 (0.3.20-x86-mingw32)
net-scp (1.2.1) net-scp (1.2.1)
net-ssh (>= 2.6.5) net-ssh (>= 2.6.5)
net-ssh (2.9.2) net-ssh (3.0.2)
nokogiri (1.6.1) netrc (0.11.0)
mini_portile (~> 0.5.0) nokogiri (1.6.7.1)
polyglot (0.3.4) mini_portile2 (~> 2.0.0.rc2)
rack (1.5.2) nokogiri (1.6.7.1-x86-mingw32)
rack-test (0.6.2) mini_portile2 (~> 2.0.0.rc2)
nokogumbo (1.4.7)
nokogiri
polyglot (0.3.5)
rack (1.5.5)
rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
rails (4.1.0) rails (4.1.0)
actionmailer (= 4.1.0) actionmailer (= 4.1.0)
@@ -127,65 +140,74 @@ GEM
bundler (>= 1.3.0, < 2.0) bundler (>= 1.3.0, < 2.0)
railties (= 4.1.0) railties (= 4.1.0)
sprockets-rails (~> 2.0) sprockets-rails (~> 2.0)
rails-erd (1.1.0) rails-erd (1.4.4)
activerecord (>= 3.0) activerecord (>= 3.2)
activesupport (>= 3.0) activesupport (>= 3.2)
choice (~> 0.1.6) choice (~> 0.2.0)
ruby-graphviz (~> 1.0.4) ruby-graphviz (~> 1.2)
railties (4.1.0) railties (4.1.0)
actionpack (= 4.1.0) actionpack (= 4.1.0)
activesupport (= 4.1.0) activesupport (= 4.1.0)
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
raindrops (0.13.0) rake (10.4.2)
rake (10.2.2) rb-readline (0.5.3)
rb-readline (0.5.1)
redcarpet (3.2.3) redcarpet (3.2.3)
rest-client (1.6.7) rest-client (1.8.0)
mime-types (>= 1.16) http-cookie (>= 1.0.2, < 2.0)
ruby-graphviz (1.0.9) mime-types (>= 1.16, < 3.0)
sanitize (2.1.0) netrc (~> 0.7)
rest-client (1.8.0-x86-mingw32)
ffi (~> 1.9)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
ruby-graphviz (1.2.2)
sanitize (4.0.1)
crass (~> 1.0.2)
nokogiri (>= 1.4.4) nokogiri (>= 1.4.4)
sass (3.2.19) nokogumbo (~> 1.4.1)
sass-rails (4.0.3) sass (3.4.20)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0) railties (>= 4.0.0, < 5.0)
sass (~> 3.2.0) sass (~> 3.1)
sprockets (~> 2.8, <= 2.11.0) sprockets (>= 2.8, < 4.0)
sprockets-rails (~> 2.0) sprockets-rails (>= 2.0, < 4.0)
sprockets (2.11.0) tilt (>= 1.1, < 3)
hike (~> 1.2) sprockets (3.5.2)
multi_json (~> 1.0) concurrent-ruby (~> 1.0)
rack (~> 1.0) rack (> 1, < 3)
tilt (~> 1.1, != 1.3.0) sprockets-rails (2.3.3)
sprockets-rails (2.1.3)
actionpack (>= 3.0) actionpack (>= 3.0)
activesupport (>= 3.0) activesupport (>= 3.0)
sprockets (~> 2.8) sprockets (>= 2.8, < 4.0)
sshkit (1.7.1) sshkit (1.8.1)
colorize (>= 0.7.0)
net-scp (>= 1.1.2) net-scp (>= 1.1.2)
net-ssh (>= 2.8.0) net-ssh (>= 2.8.0)
strip_attributes (1.5.1) strip_attributes (1.7.1)
activemodel (>= 3.0, < 5.0) activemodel (>= 3.0, < 5.0)
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.3) thread_safe (0.3.5)
tilt (1.4.1) tilt (2.0.2)
treetop (1.4.15) treetop (1.4.15)
polyglot polyglot
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
tzinfo (1.1.0) tzinfo (1.2.2)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (2.5.0) tzinfo-data (1.2015.7)
tzinfo (>= 1.0.0)
uglifier (2.7.2)
execjs (>= 0.3.0) execjs (>= 0.3.0)
json (>= 1.8.0) json (>= 1.8.0)
unicorn (4.8.3) unf (0.1.4)
kgio (~> 2.6) unf_ext
rack unf_ext (0.0.7.1)
raindrops (~> 0.7) unf_ext (0.0.7.1-x86-mingw32)
webrick (1.3.1) webrick (1.3.1)
PLATFORMS PLATFORMS
ruby ruby
x86-mingw32
DEPENDENCIES DEPENDENCIES
activerecord-session_store activerecord-session_store
@@ -196,12 +218,13 @@ DEPENDENCIES
capistrano-rails (~> 1.1.2) capistrano-rails (~> 1.1.2)
capistrano-rbenv (~> 2.0) capistrano-rbenv (~> 2.0)
coffee-rails coffee-rails
coffee-script-source (= 1.8.0)
highlight_js-rails! highlight_js-rails!
hirb hirb
jquery-rails jquery-rails
jquery-textcomplete-rails! jquery-textcomplete-rails!
kaminari! kaminari!
mysql2 mysql2 (~> 0.3.18)
rails (= 4.1.0) rails (= 4.1.0)
rails-erd rails-erd
rb-readline rb-readline
@@ -210,6 +233,10 @@ DEPENDENCIES
sanitize sanitize
sass-rails sass-rails
strip_attributes strip_attributes
tzinfo
tzinfo-data (~> 1.2015, >= 1.2015.7)
uglifier uglifier
unicorn
webrick webrick
BUNDLED WITH
1.11.2
+9 -9
View File
@@ -17,9 +17,9 @@ class ApplicationController < ActionController::Base
helper_method :superadmin? helper_method :superadmin?
helper_method :donor? helper_method :donor?
helper_method :retired? helper_method :retired?
helper_method :developer? helper_method :mit?
helper_method :trainingmod? helper_method :dev?
helper_method :lead_mod? helper_method :lead?
helper_method :confirmed? helper_method :confirmed?
@@ -79,16 +79,16 @@ class ApplicationController < ActionController::Base
!!(current_user && current_user.retired?) !!(current_user && current_user.retired?)
end end
def developer? def mit?
!!(current_user && current_user.developer?) !!(current_user && current_user.mit?)
end end
def trainingmod? def dev?
!!(current_user && current_user.trainingmod?) !!(current_user && current_user.dev?)
end end
def lead_mod? def lead?
!!(current_user && current_user.lead_mod?) !!(current_user && current_user.lead?)
end end
def confirmed? def confirmed?
+9 -1
View File
@@ -12,6 +12,14 @@ class UsersController < ApplicationController
@users = User.joins(:role).where("roles.value >= ?", Role.get(:mod).to_i) @users = User.joins(:role).where("roles.value >= ?", Role.get(:mod).to_i)
elsif params[:role].downcase == "donor" elsif params[:role].downcase == "donor"
@users = User.joins(:role).where(donor: true) @users = User.joins(:role).where(donor: true)
elsif params[:role].downcase == "retired"
@users = User.joins(:role).where(retired: true)
elsif params[:role].downcase == "mit"
@users = User.joins(:role).where(mit: true)
elsif params[:role].downcase == "dev"
@users = User.joins(:role).where(dev: true)
elsif params[:role].downcase == "lead"
@users = User.joins(:role).where(lead: true)
else else
if role = Role.get(params[:role]) if role = Role.get(params[:role])
@users = User.joins(:role).where(role: role) @users = User.joins(:role).where(role: role)
@@ -140,7 +148,7 @@ class UsersController < ApplicationController
def update def update
if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?) if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?)
if mod? if mod?
userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about, :role, :confirmed, :donor]) userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about, :role, :confirmed, :donor, :retired, :dev, :mit, :lead])
else else
userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about]) userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about])
end end
+6 -41
View File
@@ -21,8 +21,6 @@ class User < ActiveRecord::Base
validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@(.+\..{2,}|\[[0-9a-f:.]+\])\z/i, message: "That doesn't look like an email address."} validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@(.+\..{2,}|\[[0-9a-f:.]+\])\z/i, message: "That doesn't look like an email address."}
validates :ign, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z\d_]+\z/i, message: "Username is invalid (a-z, 0-9, _)."} validates :ign, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z\d_]+\z/i, message: "Username is invalid (a-z, 0-9, _)."}
validate :account_exists?, :if => lambda {|user| user.ign_changed? }
has_many :blogposts has_many :blogposts
has_many :comments has_many :comments
@@ -39,16 +37,16 @@ class User < ActiveRecord::Base
!!self.retired !!self.retired
end end
def developer? def dev?
!!self.developer !!self.dev
end end
def trainingmod? def mit?
!!self.trainingmod !!self.mit
end end
def lead_mod? def lead?
!!self.lead_mod !!self.lead
end end
def confirmed? def confirmed?
@@ -129,32 +127,6 @@ class User < ActiveRecord::Base
end end
end end
# def haspaid?
# begin
# response = open("https://sessionserver.mojang.com/session/minecraft/profile/#{CGI.escape(self.uuid)}", read_timeout: 0.5)
# if response.status[0] == "200"
# session_profile = JSON.load(response.read)
# # unpaid accounts are called 'demo' accounts
# return session_profile["demo"] == true
# elsif response.status[0] == "204"
# # user doesn't exist
# return false
# else
# Rails.logger.error "---"
# Rails.logger.error "ERROR: unexpected response code while checking '#{self.uuid}' for premium account"
# Rails.logger.error "code: #{reponse.status}, body: '#{reponse.read}'"
# Rails.logger.error "---"
# end
# rescue => e
# Rails.logger.error "---"
# Rails.logger.error "ERROR: failed to check for premium account for '#{self.uuid}'. Minecraft servers down?"
# Rails.logger.error e.message
# Rails.logger.error "---"
# end
# # mojang servers have trouble
# return true
# end
# def correct_case?(ign) # def correct_case?(ign)
# begin # begin
# http = Net::HTTP.start("skins.minecraft.net") # http = Net::HTTP.start("skins.minecraft.net")
@@ -220,13 +192,6 @@ class User < ActiveRecord::Base
self.name ||= self.ign self.name ||= self.ign
end end
def account_exists?
profile = self.get_profile
if !profile || profile["demo"] == true
errors.add(:ign, "'#{self.ign}' is not a paid account!")
end
end
def strip_whitespaces def strip_whitespaces
self.name.strip! if self.name self.name.strip! if self.name
self.ign.strip! if self.ign self.ign.strip! if self.ign
+5 -4
View File
@@ -50,21 +50,22 @@
<tr> <tr>
<td>Developer</td> <td>Developer</td>
<td> <td>
<%= f.select :developer, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> <%= f.select :dev, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>TrainingMod</td> <td>Mod In Training</td>
<td> <td>
<%= f.select :trainingmod, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> <%= f.select :mit, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Lead Mod</td> <td>Lead Mod</td>
<td> <td>
<%= f.select :lead_mod, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> <%= f.select :lead, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %>
</td> </td>
</tr> </tr>
<% end %> <% end %>
<tr> <tr>
<td>Skype username</td> <td>Skype username</td>
+4
View File
@@ -14,6 +14,10 @@ class CreateUsers < ActiveRecord::Migration
t.string :youtube_channelname t.string :youtube_channelname
t.string :twitter t.string :twitter
t.boolean :donor, default: false t.boolean :donor, default: false
t.boolean :retired, default: false
t.boolean :mit, default: false
t.boolean :dev, default: false
t.boolean :lead, default: false
t.string :email_token t.string :email_token
t.boolean :confirmed, default: false t.boolean :confirmed, default: false
t.datetime :last_seen t.datetime :last_seen
+5 -1
View File
@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150826002927) do ActiveRecord::Schema.define(version: 20150825232749) do
create_table "blogposts", force: true do |t| create_table "blogposts", force: true do |t|
t.string "title" t.string "title"
@@ -124,6 +124,10 @@ ActiveRecord::Schema.define(version: 20150826002927) do
t.string "youtube_channelname" t.string "youtube_channelname"
t.string "twitter" t.string "twitter"
t.boolean "donor", default: false t.boolean "donor", default: false
t.boolean "mit", default: false
t.boolean "retired", default: false
t.boolean "dev", default: false
t.boolean "lead", default: false
t.string "email_token" t.string "email_token"
t.boolean "confirmed", default: false t.boolean "confirmed", default: false
t.datetime "last_seen" t.datetime "last_seen"
-1
View File
@@ -12,7 +12,6 @@ Role.create!([
userpw = SecureRandom.hex(36) userpw = SecureRandom.hex(36)
# fallback profile for deleted users # fallback profile for deleted users
deleted_user = User.create!( deleted_user = User.create!(
uuid: "8667ba71b85a4004af54457a9734eed7", uuid: "8667ba71b85a4004af54457a9734eed7",