From d5edeca666cde03e2cc6123870306e533affcc01 Mon Sep 17 00:00:00 2001 From: Jonas Folvik Date: Mon, 28 Dec 2015 21:05:41 +0100 Subject: [PATCH 001/214] Defined developer/trainingmod rank Defined the developer and trainingmod ranks to make it easier for others to understand, and to make it easier to give them permissions in the future (if needed). --- app/models/user.rb | 8 ++++++++ db/seeds.rb | 2 ++ 2 files changed, 10 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 83d668a..92d7a81 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -61,6 +61,14 @@ class User < ActiveRecord::Base !!(self.role >= :normal) end + def trainingmod? + !!(self.role >= :trainingmod) + end + + def developer? + !!(self.role >= :developer) + end + def mod? !!(self.role >= :mod) end diff --git a/db/seeds.rb b/db/seeds.rb index 780ddb5..833a176 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,6 +5,8 @@ Role.create!([ {name: "disabled", value: 1, color: "#ccc"}, {name: "banned", value: 2, color: "#ccc"}, {name: "normal", value: 10, color: "#282"}, + {name: "trainingmod", value: 40, color: "#fa5"}, + {name: "developer", value: 70, color: "#a0a"}, {name: "mod", value: 100, color: "#6af"}, {name: "admin", value: 200, color: "#d22"}, {name: "superadmin", value: 500, color: "#d22"} -- 2.52.0 From ccac3fc975f0e5dcb1152b89cb306f1c2fe714af Mon Sep 17 00:00:00 2001 From: Jonas Folvik Date: Tue, 29 Dec 2015 12:16:28 +0100 Subject: [PATCH 002/214] Added lead mod, developer and trainingmod as suffixes Added lead mod, developer and trainingmod as suffixes so that you can have two of them together (if needed) --- app/models/user.rb | 20 ++++++++++++-------- app/views/users/edit.html.erb | 20 ++++++++++++++++++++ db/seeds.rb | 2 -- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 92d7a81..22a7e20 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -35,6 +35,18 @@ class User < ActiveRecord::Base !!self.donor end + def developer? + !!self.developer + end + + def trainingmod? + !!self.trainingmod + end + + def lead_mod? + !!self.lead_mod + end + def confirmed? !!self.confirmed end @@ -61,14 +73,6 @@ class User < ActiveRecord::Base !!(self.role >= :normal) end - def trainingmod? - !!(self.role >= :trainingmod) - end - - def developer? - !!(self.role >= :developer) - end - def mod? !!(self.role >= :mod) end diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index b2d1bd5..8d24076 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -40,6 +40,26 @@ <% end %> + <% if admin? %> + + Developer + + <%= f.select :developer, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> + + + + TrainingMod + + <%= f.select :trainingmod, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> + + + + Lead Mod + + <%= f.select :lead_mod, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> + + + <% end %> Skype username diff --git a/db/seeds.rb b/db/seeds.rb index 833a176..780ddb5 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,8 +5,6 @@ Role.create!([ {name: "disabled", value: 1, color: "#ccc"}, {name: "banned", value: 2, color: "#ccc"}, {name: "normal", value: 10, color: "#282"}, - {name: "trainingmod", value: 40, color: "#fa5"}, - {name: "developer", value: 70, color: "#a0a"}, {name: "mod", value: 100, color: "#6af"}, {name: "admin", value: 200, color: "#d22"}, {name: "superadmin", value: 500, color: "#d22"} -- 2.52.0 From 5585583079c1b58d2d9c97c9ca69734fe294a81e Mon Sep 17 00:00:00 2001 From: Jonas Folvik Date: Fri, 1 Jan 2016 15:05:29 +0100 Subject: [PATCH 003/214] added some ranks Added lead_mod, trainingmod and developer in one file I missed last time --- app/controllers/application_controller.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a0e166e..d1ad4fe 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,6 +16,9 @@ class ApplicationController < ActionController::Base helper_method :admin? helper_method :superadmin? helper_method :donor? + helper_method :developer? + helper_method :trainingmod? + helper_method :lead_mod? helper_method :confirmed? @@ -71,6 +74,18 @@ class ApplicationController < ActionController::Base !!(current_user && current_user.donor?) end + def developer? + !!(current_user && current_user.developer?) + end + + def trainingmod? + !!(current_user && current_user.trainingmod?) + end + + def lead_mod? + !!(current_user && current_user.lead_mod?) + end + def confirmed? !!(current_user && current_user.confirmed?) end -- 2.52.0 From 3275c05a5ff42c400b1796bba1d9a36fded1dc07 Mon Sep 17 00:00:00 2001 From: Jonas Folvik Date: Mon, 4 Jan 2016 21:39:52 +0100 Subject: [PATCH 004/214] Added retired Added the retired suffix --- app/controllers/application_controller.rb | 5 +++++ app/models/user.rb | 4 ++++ app/views/users/edit.html.erb | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d1ad4fe..3837ff0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,6 +16,7 @@ class ApplicationController < ActionController::Base helper_method :admin? helper_method :superadmin? helper_method :donor? + helper_method :retired? helper_method :developer? helper_method :trainingmod? helper_method :lead_mod? @@ -74,6 +75,10 @@ class ApplicationController < ActionController::Base !!(current_user && current_user.donor?) end + def retired? + !!(current_user && current_user.retired?) + end + def developer? !!(current_user && current_user.developer?) end diff --git a/app/models/user.rb b/app/models/user.rb index 22a7e20..7caf0ca 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -35,6 +35,10 @@ class User < ActiveRecord::Base !!self.donor end + def retired? + !!self.retired + end + def developer? !!self.developer end diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 8d24076..ec546ac 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -39,6 +39,12 @@ <%= f.select :donor, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> + + Retired + + <%= f.select :retired, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> + + <% end %> <% if admin? %> -- 2.52.0 From d9b971ab349f7ba3c8d95badee8fb6023588d197 Mon Sep 17 00:00:00 2001 From: Jonas Folvik Date: Mon, 4 Jan 2016 21:49:21 +0100 Subject: [PATCH 005/214] Fixed a bug Fixed a bug that made it so when you are editing a reply, you can't go back to the original thread using the "line" of links at the top --- app/views/threadreplies/edit.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/threadreplies/edit.html.erb b/app/views/threadreplies/edit.html.erb index 645c64d..d3218cd 100644 --- a/app/views/threadreplies/edit.html.erb +++ b/app/views/threadreplies/edit.html.erb @@ -1,6 +1,6 @@ <% title "Edit Thread Reply: #{@reply.thread.title}" %> -<%= link_to @reply.thread.forum.group, forumgroup_path(@reply.thread.forum.group) %> → <%= link_to @reply.thread.forum, @reply.thread.forum %> → <%= link_to @reply.thread %> → Edit reply +<%= link_to @reply.thread.forum.group, forumgroup_path(@reply.thread.forum.group) %> → <%= link_to @reply.thread.forum, @reply.thread.forum %> → <%= link_to @reply.thread, @reply.thread %> → Edit reply

Edit reply

<%= form_for [@reply.thread, @reply] do |f| %> <%= render partial: "md_editor", locals: {name: "threadreply[content]", content: @reply.content} %> -- 2.52.0 From c35a36a5c5fe1a4640414976764717dd1aca9578 Mon Sep 17 00:00:00 2001 From: Jonas Folvik Date: Mon, 11 Jan 2016 18:21:21 +0100 Subject: [PATCH 006/214] 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. --- Gemfile | 9 +- Gemfile.lock | 159 +++++++++++++--------- app/controllers/application_controller.rb | 18 +-- app/controllers/users_controller.rb | 10 +- app/models/user.rb | 47 +------ app/views/users/edit.html.erb | 9 +- db/migrate/02_create_users.rb | 4 + db/schema.rb | 6 +- db/seeds.rb | 1 - 9 files changed, 138 insertions(+), 125 deletions(-) diff --git a/Gemfile b/Gemfile index eac521d..86eb387 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' gem 'rails', '4.1.0' -gem 'mysql2' +gem 'mysql2', '~> 0.3.18' gem 'jquery-rails' gem 'bcrypt-ruby' # To use ActiveModel's has_secure_password gem 'sanitize' @@ -15,6 +15,9 @@ gem 'activerecord-session_store' gem 'highlight_js-rails', github: 'RedstonerServer/highlight_js-rails' gem 'kaminari', github: 'jomo/kaminari', branch: 'patch-2' # pagination 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 # in production environments by default. @@ -36,4 +39,6 @@ group :development do end # Use unicorn as the app server -gem 'unicorn' \ No newline at end of file +group :production do + # gem 'unicorn' +end \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 705d8af..d4fdaf5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -46,7 +46,7 @@ GEM activemodel (= 4.1.0) activesupport (= 4.1.0) arel (~> 5.0.0) - activerecord-session_store (0.1.0) + activerecord-session_store (0.1.2) actionpack (>= 4.0.0, < 5) activerecord (>= 4.0.0, < 5) railties (>= 4.0.0, < 5) @@ -56,13 +56,17 @@ GEM minitest (~> 5.1) thread_safe (~> 0.1) tzinfo (~> 1.1) - arel (5.0.0) - bcrypt (3.1.7) + arel (5.0.1.20140414130214) + bcrypt (3.1.10) + bcrypt (3.1.10-x86-mingw32) bcrypt-ruby (3.1.5) 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) erubis (>= 2.6.6) + rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) builder (3.2.2) @@ -73,49 +77,58 @@ GEM capistrano-bundler (1.1.4) capistrano (~> 3.1) sshkit (~> 1.2) - capistrano-rails (1.1.2) + capistrano-rails (1.1.5) capistrano (~> 3.1) capistrano-bundler (~> 1.1) - capistrano-rbenv (2.0.3) + capistrano-rbenv (2.0.4) capistrano (~> 3.1) sshkit (~> 1.3) - choice (0.1.6) + choice (0.2.0) coderay (1.1.0) - coffee-rails (4.0.1) + coffee-rails (4.1.1) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) - coffee-script (2.2.0) + railties (>= 4.0.0, < 5.1.x) + coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.7.0) - colorize (0.7.5) + coffee-script-source (1.8.0) + concurrent-ruby (1.0.0) + crass (1.0.2) debug_inspector (0.0.2) + domain_name (0.5.25) + unf (>= 0.0.5, < 1.0.0) erubis (2.7.0) - execjs (2.0.2) - hike (1.2.3) - hirb (0.7.1) - i18n (0.6.9) - jquery-rails (3.1.0) + execjs (2.6.0) + ffi (1.9.10-x86-mingw32) + hirb (0.7.3) + http-cookie (1.0.2) + domain_name (~> 0.5) + i18n (0.7.0) + jquery-rails (3.1.4) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - json (1.8.1) - kgio (2.9.2) + json (1.8.3) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.25.1) - mini_portile (0.5.3) - minitest (5.3.2) - multi_json (1.9.2) - mysql2 (0.3.15) + mini_portile2 (2.0.0) + minitest (5.8.3) + mysql2 (0.3.20) + mysql2 (0.3.20-x86-mingw32) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (2.9.2) - nokogiri (1.6.1) - mini_portile (~> 0.5.0) - polyglot (0.3.4) - rack (1.5.2) - rack-test (0.6.2) + net-ssh (3.0.2) + netrc (0.11.0) + nokogiri (1.6.7.1) + mini_portile2 (~> 2.0.0.rc2) + nokogiri (1.6.7.1-x86-mingw32) + 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) rails (4.1.0) actionmailer (= 4.1.0) @@ -127,65 +140,74 @@ GEM bundler (>= 1.3.0, < 2.0) railties (= 4.1.0) sprockets-rails (~> 2.0) - rails-erd (1.1.0) - activerecord (>= 3.0) - activesupport (>= 3.0) - choice (~> 0.1.6) - ruby-graphviz (~> 1.0.4) + rails-erd (1.4.4) + activerecord (>= 3.2) + activesupport (>= 3.2) + choice (~> 0.2.0) + ruby-graphviz (~> 1.2) railties (4.1.0) actionpack (= 4.1.0) activesupport (= 4.1.0) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - raindrops (0.13.0) - rake (10.2.2) - rb-readline (0.5.1) + rake (10.4.2) + rb-readline (0.5.3) redcarpet (3.2.3) - rest-client (1.6.7) - mime-types (>= 1.16) - ruby-graphviz (1.0.9) - sanitize (2.1.0) + rest-client (1.8.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 3.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) - sass (3.2.19) - sass-rails (4.0.3) + nokogumbo (~> 1.4.1) + sass (3.4.20) + sass-rails (5.0.4) railties (>= 4.0.0, < 5.0) - sass (~> 3.2.0) - sprockets (~> 2.8, <= 2.11.0) - sprockets-rails (~> 2.0) - sprockets (2.11.0) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.1.3) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + sprockets (3.5.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (2.3.3) actionpack (>= 3.0) activesupport (>= 3.0) - sprockets (~> 2.8) - sshkit (1.7.1) - colorize (>= 0.7.0) + sprockets (>= 2.8, < 4.0) + sshkit (1.8.1) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - strip_attributes (1.5.1) + strip_attributes (1.7.1) activemodel (>= 3.0, < 5.0) thor (0.19.1) - thread_safe (0.3.3) - tilt (1.4.1) + thread_safe (0.3.5) + tilt (2.0.2) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (1.1.0) + tzinfo (1.2.2) 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) json (>= 1.8.0) - unicorn (4.8.3) - kgio (~> 2.6) - rack - raindrops (~> 0.7) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.1) + unf_ext (0.0.7.1-x86-mingw32) webrick (1.3.1) PLATFORMS ruby + x86-mingw32 DEPENDENCIES activerecord-session_store @@ -196,12 +218,13 @@ DEPENDENCIES capistrano-rails (~> 1.1.2) capistrano-rbenv (~> 2.0) coffee-rails + coffee-script-source (= 1.8.0) highlight_js-rails! hirb jquery-rails jquery-textcomplete-rails! kaminari! - mysql2 + mysql2 (~> 0.3.18) rails (= 4.1.0) rails-erd rb-readline @@ -210,6 +233,10 @@ DEPENDENCIES sanitize sass-rails strip_attributes + tzinfo + tzinfo-data (~> 1.2015, >= 1.2015.7) uglifier - unicorn webrick + +BUNDLED WITH + 1.11.2 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3837ff0..62e7b31 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -17,9 +17,9 @@ class ApplicationController < ActionController::Base helper_method :superadmin? helper_method :donor? helper_method :retired? - helper_method :developer? - helper_method :trainingmod? - helper_method :lead_mod? + helper_method :mit? + helper_method :dev? + helper_method :lead? helper_method :confirmed? @@ -79,16 +79,16 @@ class ApplicationController < ActionController::Base !!(current_user && current_user.retired?) end - def developer? - !!(current_user && current_user.developer?) + def mit? + !!(current_user && current_user.mit?) end - def trainingmod? - !!(current_user && current_user.trainingmod?) + def dev? + !!(current_user && current_user.dev?) end - def lead_mod? - !!(current_user && current_user.lead_mod?) + def lead? + !!(current_user && current_user.lead?) end def confirmed? diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 730f981..2da3181 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -12,6 +12,14 @@ class UsersController < ApplicationController @users = User.joins(:role).where("roles.value >= ?", Role.get(:mod).to_i) elsif params[:role].downcase == "donor" @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 if role = Role.get(params[:role]) @users = User.joins(:role).where(role: role) @@ -140,7 +148,7 @@ class UsersController < ApplicationController def update if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?) 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 userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about]) end diff --git a/app/models/user.rb b/app/models/user.rb index 7caf0ca..292cf4e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 :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 :comments @@ -39,16 +37,16 @@ class User < ActiveRecord::Base !!self.retired end - def developer? - !!self.developer + def dev? + !!self.dev end - def trainingmod? - !!self.trainingmod + def mit? + !!self.mit end - def lead_mod? - !!self.lead_mod + def lead? + !!self.lead end def confirmed? @@ -129,32 +127,6 @@ class User < ActiveRecord::Base 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) # begin # http = Net::HTTP.start("skins.minecraft.net") @@ -220,13 +192,6 @@ class User < ActiveRecord::Base self.name ||= self.ign 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 self.name.strip! if self.name self.ign.strip! if self.ign diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index ec546ac..c8a2e58 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -50,21 +50,22 @@ Developer - <%= f.select :developer, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> + <%= f.select :dev, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> - TrainingMod + Mod In Training - <%= f.select :trainingmod, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> + <%= f.select :mit, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> Lead Mod - <%= f.select :lead_mod, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> + <%= f.select :lead, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> + <% end %> Skype username diff --git a/db/migrate/02_create_users.rb b/db/migrate/02_create_users.rb index c8d68ed..0957c4c 100644 --- a/db/migrate/02_create_users.rb +++ b/db/migrate/02_create_users.rb @@ -14,6 +14,10 @@ class CreateUsers < ActiveRecord::Migration t.string :youtube_channelname t.string :twitter 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.boolean :confirmed, default: false t.datetime :last_seen diff --git a/db/schema.rb b/db/schema.rb index 0f9ed93..3e5eb65 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # 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| t.string "title" @@ -124,6 +124,10 @@ ActiveRecord::Schema.define(version: 20150826002927) do t.string "youtube_channelname" t.string "twitter" 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.boolean "confirmed", default: false t.datetime "last_seen" diff --git a/db/seeds.rb b/db/seeds.rb index 780ddb5..37eba2f 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -12,7 +12,6 @@ Role.create!([ userpw = SecureRandom.hex(36) - # fallback profile for deleted users deleted_user = User.create!( uuid: "8667ba71b85a4004af54457a9734eed7", -- 2.52.0 From 553a15519abe5c0bcc67aaf09c0823639e1838e4 Mon Sep 17 00:00:00 2001 From: Jonas Folvik Date: Sun, 17 Jan 2016 00:44:31 +0100 Subject: [PATCH 007/214] Fixed path bug This is a fix for the bug that you couldn't go back to the original thread by clicking the links at the top. --- app/views/threadreplies/edit.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/threadreplies/edit.html.erb b/app/views/threadreplies/edit.html.erb index 645c64d..d3218cd 100644 --- a/app/views/threadreplies/edit.html.erb +++ b/app/views/threadreplies/edit.html.erb @@ -1,6 +1,6 @@ <% title "Edit Thread Reply: #{@reply.thread.title}" %> -<%= link_to @reply.thread.forum.group, forumgroup_path(@reply.thread.forum.group) %> → <%= link_to @reply.thread.forum, @reply.thread.forum %> → <%= link_to @reply.thread %> → Edit reply +<%= link_to @reply.thread.forum.group, forumgroup_path(@reply.thread.forum.group) %> → <%= link_to @reply.thread.forum, @reply.thread.forum %> → <%= link_to @reply.thread, @reply.thread %> → Edit reply

Edit reply

<%= form_for [@reply.thread, @reply] do |f| %> <%= render partial: "md_editor", locals: {name: "threadreply[content]", content: @reply.content} %> -- 2.52.0 From 676875914fb9f88af1a996ac4658df6104f97a84 Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 17 Jan 2016 18:23:26 +0100 Subject: [PATCH 008/214] fix parens checking if forum exists this led to 500 when the forum was deleted but the thread still existed --- app/models/forumthread.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/forumthread.rb b/app/models/forumthread.rb index 2723cd6..9baf117 100644 --- a/app/models/forumthread.rb +++ b/app/models/forumthread.rb @@ -38,7 +38,7 @@ class Forumthread < ActiveRecord::Base def can_read?(user) # we might have threads without a forum # e.g. forum deleted - forum && forum.can_read?(user) || (forum.can_write?(user) && self.sticky?) || author == user + forum && (forum.can_read?(user) || (forum.can_write?(user)) && self.sticky?) || author == user end def can_write?(user) -- 2.52.0 From 80d9a1761a104e43c8af02f5d979c0148ee337ff Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 17 Jan 2016 18:33:17 +0100 Subject: [PATCH 009/214] *actually* fix parens checking if forum exists this led to 500 when the forum was deleted but the thread still existed --- app/models/forumthread.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/forumthread.rb b/app/models/forumthread.rb index 9baf117..892ef15 100644 --- a/app/models/forumthread.rb +++ b/app/models/forumthread.rb @@ -38,7 +38,7 @@ class Forumthread < ActiveRecord::Base def can_read?(user) # we might have threads without a forum # e.g. forum deleted - forum && (forum.can_read?(user) || (forum.can_write?(user)) && self.sticky?) || author == user + forum && (forum.can_read?(user) || (forum.can_write?(user) && self.sticky?) || author == user) end def can_write?(user) -- 2.52.0 From ce19d61e1dc45a0a55ee9f9569e5a82e1cf181ab Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 17 Jan 2016 18:58:05 +0100 Subject: [PATCH 010/214] use utf8mb4 because utf8 is not UTF-8 compatible... --- config/database.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/database.yml b/config/database.yml index 8b37796..efae840 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,6 +1,6 @@ default: &default adapter: mysql2 - encoding: utf8 + encoding: utf8mb4 database: website pool: 5 timeout: 5000 -- 2.52.0 From e53228eaf15dc2d9ab5f631e312ef5132eaae747 Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 17 Jan 2016 19:45:46 +0100 Subject: [PATCH 011/214] update to rails 4.2.5, clean up --- Gemfile | 17 +- Gemfile.lock | 273 +++++++++++++++----------- app/controllers/users_controller.rb | 4 +- app/helpers/mailer_helper.rb | 2 +- db/migrate/02_create_users.rb | 2 +- db/migrate/03_create_blogposts.rb | 2 +- db/migrate/04_create_comments.rb | 2 +- db/migrate/07_create_forumthreads.rb | 2 +- db/migrate/08_create_sessions.rb | 2 +- db/migrate/10_create_threadreplies.rb | 2 +- db/schema.rb | 156 +++++++-------- 11 files changed, 255 insertions(+), 209 deletions(-) diff --git a/Gemfile b/Gemfile index eac521d..4714ee3 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,10 @@ source 'https://rubygems.org' -gem 'rails', '4.1.0' +gem 'rails', github: 'rails/rails', branch: '4-2-stable' gem 'mysql2' gem 'jquery-rails' -gem 'bcrypt-ruby' # To use ActiveModel's has_secure_password +gem 'bcrypt' # To use ActiveModel's has_secure_password gem 'sanitize' gem 'strip_attributes' gem 'redcarpet', '~> 3.2.3' @@ -20,7 +20,6 @@ gem 'jquery-textcomplete-rails', github: 'RedstonerServer/jquery-textcomplete-ra # in production environments by default. group :assets do gem 'sass-rails' - gem 'coffee-rails' gem 'uglifier' end @@ -33,7 +32,15 @@ group :development do gem 'capistrano-rails', '~> 1.1.2' gem 'capistrano-rbenv', '~> 2.0' gem 'capistrano-bundler', '~> 1.1.3' + # windows timezone foo + gem 'tzinfo-data', platforms: [:mingw, :mswin] end -# Use unicorn as the app server -gem 'unicorn' \ No newline at end of file +group :test do + gem 'sqlite3' +end + +group :production do + # Use unicorn as the app server + gem 'unicorn' +end \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 705d8af..8e09425 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,46 +23,76 @@ GIT actionpack (>= 3.0.0) activesupport (>= 3.0.0) +GIT + remote: git://github.com/rails/rails.git + revision: dd750a33c854bcd9eefe7ea46b0b0bb52c06767f + branch: 4-2-stable + specs: + actionmailer (4.2.5) + actionpack (= 4.2.5) + actionview (= 4.2.5) + activejob (= 4.2.5) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.5) + actionview (= 4.2.5) + activesupport (= 4.2.5) + rack (~> 1.6) + rack-test (~> 0.6.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (4.2.5) + activesupport (= 4.2.5) + builder (~> 3.1) + erubis (~> 2.7.0) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + activejob (4.2.5) + activesupport (= 4.2.5) + globalid (>= 0.3.0) + activemodel (4.2.5) + activesupport (= 4.2.5) + builder (~> 3.1) + activerecord (4.2.5) + activemodel (= 4.2.5) + activesupport (= 4.2.5) + arel (~> 6.0) + activesupport (4.2.5) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + rails (4.2.5) + actionmailer (= 4.2.5) + actionpack (= 4.2.5) + actionview (= 4.2.5) + activejob (= 4.2.5) + activemodel (= 4.2.5) + activerecord (= 4.2.5) + activesupport (= 4.2.5) + bundler (>= 1.3.0, < 2.0) + railties (= 4.2.5) + sprockets-rails + railties (4.2.5) + actionpack (= 4.2.5) + activesupport (= 4.2.5) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + GEM remote: https://rubygems.org/ specs: - actionmailer (4.1.0) - actionpack (= 4.1.0) - actionview (= 4.1.0) - mail (~> 2.5.4) - actionpack (4.1.0) - actionview (= 4.1.0) - activesupport (= 4.1.0) - rack (~> 1.5.2) - rack-test (~> 0.6.2) - actionview (4.1.0) - activesupport (= 4.1.0) - builder (~> 3.1) - erubis (~> 2.7.0) - activemodel (4.1.0) - activesupport (= 4.1.0) - builder (~> 3.1) - activerecord (4.1.0) - activemodel (= 4.1.0) - activesupport (= 4.1.0) - arel (~> 5.0.0) - activerecord-session_store (0.1.0) + activerecord-session_store (0.1.2) actionpack (>= 4.0.0, < 5) activerecord (>= 4.0.0, < 5) railties (>= 4.0.0, < 5) - activesupport (4.1.0) - i18n (~> 0.6, >= 0.6.9) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.1) - tzinfo (~> 1.1) - arel (5.0.0) - bcrypt (3.1.7) - bcrypt-ruby (3.1.5) - bcrypt (>= 3.1.3) - better_errors (1.1.0) + arel (6.0.3) + bcrypt (3.1.10) + better_errors (2.1.1) coderay (>= 1.0.0) erubis (>= 2.6.6) + rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) builder (3.2.2) @@ -73,112 +103,117 @@ GEM capistrano-bundler (1.1.4) capistrano (~> 3.1) sshkit (~> 1.2) - capistrano-rails (1.1.2) + capistrano-rails (1.1.5) capistrano (~> 3.1) capistrano-bundler (~> 1.1) - capistrano-rbenv (2.0.3) + capistrano-rbenv (2.0.4) capistrano (~> 3.1) sshkit (~> 1.3) - choice (0.1.6) + choice (0.2.0) coderay (1.1.0) - coffee-rails (4.0.1) + coffee-rails (4.1.1) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) - coffee-script (2.2.0) + railties (>= 4.0.0, < 5.1.x) + coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.7.0) - colorize (0.7.5) + coffee-script-source (1.10.0) + concurrent-ruby (1.0.0) + crass (1.0.2) debug_inspector (0.0.2) + domain_name (0.5.25) + unf (>= 0.0.5, < 1.0.0) erubis (2.7.0) - execjs (2.0.2) - hike (1.2.3) - hirb (0.7.1) - i18n (0.6.9) - jquery-rails (3.1.0) - railties (>= 3.0, < 5.0) + execjs (2.6.0) + globalid (0.3.6) + activesupport (>= 4.1.0) + hirb (0.7.3) + http-cookie (1.0.2) + domain_name (~> 0.5) + i18n (0.7.0) + jquery-rails (4.1.0) + rails-dom-testing (~> 1.0) + railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (1.8.1) - kgio (2.9.2) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.25.1) - mini_portile (0.5.3) - minitest (5.3.2) - multi_json (1.9.2) - mysql2 (0.3.15) + json (1.8.3) + kgio (2.10.0) + loofah (2.0.3) + nokogiri (>= 1.5.9) + mail (2.6.3) + mime-types (>= 1.16, < 3) + mime-types (2.99) + mini_portile2 (2.0.0) + minitest (5.8.3) + mysql2 (0.4.2) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (2.9.2) - nokogiri (1.6.1) - mini_portile (~> 0.5.0) - polyglot (0.3.4) - rack (1.5.2) - rack-test (0.6.2) + net-ssh (3.0.2) + netrc (0.11.0) + nokogiri (1.6.7.1) + mini_portile2 (~> 2.0.0.rc2) + nokogumbo (1.4.7) + nokogiri + rack (1.6.4) + rack-test (0.6.3) rack (>= 1.0) - rails (4.1.0) - actionmailer (= 4.1.0) - actionpack (= 4.1.0) - actionview (= 4.1.0) - activemodel (= 4.1.0) - activerecord (= 4.1.0) - activesupport (= 4.1.0) - bundler (>= 1.3.0, < 2.0) - railties (= 4.1.0) - sprockets-rails (~> 2.0) - rails-erd (1.1.0) - activerecord (>= 3.0) - activesupport (>= 3.0) - choice (~> 0.1.6) - ruby-graphviz (~> 1.0.4) - railties (4.1.0) - actionpack (= 4.1.0) - activesupport (= 4.1.0) - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - raindrops (0.13.0) - rake (10.2.2) - rb-readline (0.5.1) + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.7) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6.0) + rails-deprecated_sanitizer (>= 1.0.1) + rails-erd (1.4.5) + activerecord (>= 3.2) + activesupport (>= 3.2) + choice (~> 0.2.0) + ruby-graphviz (~> 1.2) + rails-html-sanitizer (1.0.2) + loofah (~> 2.0) + raindrops (0.15.0) + rake (10.5.0) + rb-readline (0.5.3) redcarpet (3.2.3) - rest-client (1.6.7) - mime-types (>= 1.16) - ruby-graphviz (1.0.9) - sanitize (2.1.0) + rest-client (1.8.0) + 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) - sass (3.2.19) - sass-rails (4.0.3) + nokogumbo (~> 1.4.1) + sass (3.4.21) + sass-rails (5.0.4) railties (>= 4.0.0, < 5.0) - sass (~> 3.2.0) - sprockets (~> 2.8, <= 2.11.0) - sprockets-rails (~> 2.0) - sprockets (2.11.0) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.1.3) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (~> 2.8) - sshkit (1.7.1) - colorize (>= 0.7.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + sprockets (3.5.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.0.0) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.3.11) + sshkit (1.8.1) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - strip_attributes (1.5.1) + strip_attributes (1.7.1) activemodel (>= 3.0, < 5.0) thor (0.19.1) - thread_safe (0.3.3) - tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - tzinfo (1.1.0) + thread_safe (0.3.5) + tilt (2.0.2) + tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (2.5.0) + uglifier (2.7.2) execjs (>= 0.3.0) json (>= 1.8.0) - unicorn (4.8.3) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.1) + unicorn (5.0.1) kgio (~> 2.6) rack raindrops (~> 0.7) @@ -189,27 +224,31 @@ PLATFORMS DEPENDENCIES activerecord-session_store - bcrypt-ruby + bcrypt better_errors binding_of_caller capistrano-bundler (~> 1.1.3) capistrano-rails (~> 1.1.2) capistrano-rbenv (~> 2.0) - coffee-rails highlight_js-rails! hirb jquery-rails jquery-textcomplete-rails! kaminari! mysql2 - rails (= 4.1.0) + rails! rails-erd rb-readline redcarpet (~> 3.2.3) rest-client sanitize sass-rails + sqlite3 strip_attributes + tzinfo-data uglifier unicorn webrick + +BUNDLED WITH + 1.11.2 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 730f981..caa5f02 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -108,8 +108,8 @@ class UsersController < ApplicationController end begin # these shouldn't be send in the background - RedstonerMailer.register_mail(@user, is_idiot).deliver - RedstonerMailer.register_info_mail(@user, is_idiot).deliver + RedstonerMailer.register_mail(@user, is_idiot).deliver_now + RedstonerMailer.register_info_mail(@user, is_idiot).deliver_now rescue => e Rails.logger.error "---" Rails.logger.error "WARNING: registration mail failed for user #{@user.try(:name)}, #{@user.try(:email)}" diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb index 7ddc853..dbacf81 100644 --- a/app/helpers/mailer_helper.rb +++ b/app/helpers/mailer_helper.rb @@ -4,7 +4,7 @@ module MailerHelper begin mails.each do |mail| begin - mail.deliver + mail.deliver_now rescue => e Rails.logger.error "---" Rails.logger.error "WARNING: '#{mail.try(:subject)}' failed for recipient #{mail.try(:to)}" diff --git a/db/migrate/02_create_users.rb b/db/migrate/02_create_users.rb index c8d68ed..1fefaf9 100644 --- a/db/migrate/02_create_users.rb +++ b/db/migrate/02_create_users.rb @@ -20,7 +20,7 @@ class CreateUsers < ActiveRecord::Migration t.references :role, null: false, default: Role.get(:normal) - t.timestamps + t.timestamps null: true end end end \ No newline at end of file diff --git a/db/migrate/03_create_blogposts.rb b/db/migrate/03_create_blogposts.rb index fd674bb..f530ed1 100644 --- a/db/migrate/03_create_blogposts.rb +++ b/db/migrate/03_create_blogposts.rb @@ -7,7 +7,7 @@ class CreateBlogposts < ActiveRecord::Migration t.references :user_author t.references :user_editor - t.timestamps + t.timestamps null: true end end end \ No newline at end of file diff --git a/db/migrate/04_create_comments.rb b/db/migrate/04_create_comments.rb index 61b6871..022bae6 100644 --- a/db/migrate/04_create_comments.rb +++ b/db/migrate/04_create_comments.rb @@ -7,7 +7,7 @@ class CreateComments < ActiveRecord::Migration t.references :user_editor t.references :blogpost - t.timestamps + t.timestamps null: true end end end diff --git a/db/migrate/07_create_forumthreads.rb b/db/migrate/07_create_forumthreads.rb index 1f06761..830b5f2 100644 --- a/db/migrate/07_create_forumthreads.rb +++ b/db/migrate/07_create_forumthreads.rb @@ -11,7 +11,7 @@ class CreateForumthreads < ActiveRecord::Migration t.references :forum - t.timestamps + t.timestamps null: true end end end diff --git a/db/migrate/08_create_sessions.rb b/db/migrate/08_create_sessions.rb index b2443e4..8e12ed1 100644 --- a/db/migrate/08_create_sessions.rb +++ b/db/migrate/08_create_sessions.rb @@ -3,7 +3,7 @@ class CreateSessions < ActiveRecord::Migration create_table :sessions do |t| t.string :session_id, :null => false t.text :data - t.timestamps + t.timestamps null: true end add_index :sessions, :session_id diff --git a/db/migrate/10_create_threadreplies.rb b/db/migrate/10_create_threadreplies.rb index 97a6626..ff6a810 100644 --- a/db/migrate/10_create_threadreplies.rb +++ b/db/migrate/10_create_threadreplies.rb @@ -7,7 +7,7 @@ class CreateThreadreplies < ActiveRecord::Migration t.references :user_editor t.references :forumthread - t.timestamps + t.timestamps null: true end end end diff --git a/db/schema.rb b/db/schema.rb index 0f9ed93..586de61 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,89 +11,89 @@ # # 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| - t.string "title" - t.text "content" - t.integer "user_author_id" - t.integer "user_editor_id" + create_table "blogposts", force: :cascade do |t| + t.string "title", limit: 255 + t.text "content", limit: 65535 + t.integer "user_author_id", limit: 4 + t.integer "user_editor_id", limit: 4 t.datetime "created_at" t.datetime "updated_at" end - create_table "comments", force: true do |t| - t.text "content" - t.integer "user_author_id" - t.integer "user_editor_id" - t.integer "blogpost_id" + create_table "comments", force: :cascade do |t| + t.text "content", limit: 65535 + t.integer "user_author_id", limit: 4 + t.integer "user_editor_id", limit: 4 + t.integer "blogpost_id", limit: 4 t.datetime "created_at" t.datetime "updated_at" end - create_table "forumgroups", force: true do |t| - t.string "name" - t.integer "position" - t.integer "role_read_id" - t.integer "role_write_id" + create_table "forumgroups", force: :cascade do |t| + t.string "name", limit: 255 + t.integer "position", limit: 4 + t.integer "role_read_id", limit: 4 + t.integer "role_write_id", limit: 4 end - create_table "forums", force: true do |t| - t.string "name" - t.integer "position" - t.integer "role_read_id" - t.integer "role_write_id" - t.integer "forumgroup_id" + create_table "forums", force: :cascade do |t| + t.string "name", limit: 255 + t.integer "position", limit: 4 + t.integer "role_read_id", limit: 4 + t.integer "role_write_id", limit: 4 + t.integer "forumgroup_id", limit: 4 end - create_table "forums_labels", id: false, force: true do |t| - t.integer "forum_id" - t.integer "label_id" + create_table "forums_labels", id: false, force: :cascade do |t| + t.integer "forum_id", limit: 4 + t.integer "label_id", limit: 4 end - create_table "forumthreads", force: true do |t| - t.string "title" - t.text "content" - t.boolean "sticky", default: false - t.boolean "locked", default: false - t.integer "user_author_id" - t.integer "user_editor_id" - t.integer "forum_id" + create_table "forumthreads", force: :cascade do |t| + t.string "title", limit: 255 + t.text "content", limit: 65535 + t.boolean "sticky", default: false + t.boolean "locked", default: false + t.integer "user_author_id", limit: 4 + t.integer "user_editor_id", limit: 4 + t.integer "forum_id", limit: 4 t.datetime "created_at" t.datetime "updated_at" - t.integer "label_id" + t.integer "label_id", limit: 4 end - create_table "info", force: true do |t| - t.string "title" - t.text "content" + create_table "info", force: :cascade do |t| + t.string "title", limit: 255 + t.text "content", limit: 65535 t.datetime "created_at" t.datetime "updated_at" end - create_table "labels", force: true do |t| - t.string "name" - t.string "color" + create_table "labels", force: :cascade do |t| + t.string "name", limit: 255 + t.string "color", limit: 255 end - create_table "register_tokens", force: true do |t| - t.string "uuid", limit: 32, null: false - t.string "token", limit: 6, null: false - t.string "email", null: false + create_table "register_tokens", force: :cascade do |t| + t.string "uuid", limit: 32, null: false + t.string "token", limit: 6, null: false + t.string "email", limit: 255, null: false end add_index "register_tokens", ["email"], name: "index_register_tokens_on_email", unique: true, using: :btree add_index "register_tokens", ["uuid"], name: "index_register_tokens_on_uuid", unique: true, using: :btree - create_table "roles", force: true do |t| - t.string "name" - t.integer "value" - t.string "color" + create_table "roles", force: :cascade do |t| + t.string "name", limit: 255 + t.integer "value", limit: 4 + t.string "color", limit: 255 end - create_table "sessions", force: true do |t| - t.string "session_id", null: false - t.text "data" + create_table "sessions", force: :cascade do |t| + t.string "session_id", limit: 255, null: false + t.text "data", limit: 65535 t.datetime "created_at" t.datetime "updated_at" end @@ -101,40 +101,40 @@ ActiveRecord::Schema.define(version: 20150826002927) do add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree - create_table "threadreplies", force: true do |t| - t.text "content" - t.integer "user_author_id" - t.integer "user_editor_id" - t.integer "forumthread_id" + create_table "threadreplies", force: :cascade do |t| + t.text "content", limit: 65535 + t.integer "user_author_id", limit: 4 + t.integer "user_editor_id", limit: 4 + t.integer "forumthread_id", limit: 4 t.datetime "created_at" t.datetime "updated_at" end - create_table "users", force: true do |t| - t.string "uuid", null: false - t.string "name", null: false - t.string "password_digest", null: false - t.string "ign", null: false - t.string "email", null: false - t.text "about" - t.string "last_ip" - t.string "skype" - t.boolean "skype_public", default: false - t.string "youtube" - t.string "youtube_channelname" - t.string "twitter" - t.boolean "donor", default: false - t.string "email_token" - t.boolean "confirmed", default: false + create_table "users", force: :cascade do |t| + t.string "uuid", limit: 255, null: false + t.string "name", limit: 255, null: false + t.string "password_digest", limit: 255, null: false + t.string "ign", limit: 255, null: false + t.string "email", limit: 255, null: false + t.text "about", limit: 65535 + t.string "last_ip", limit: 255 + t.string "skype", limit: 255 + t.boolean "skype_public", default: false + t.string "youtube", limit: 255 + t.string "youtube_channelname", limit: 255 + t.string "twitter", limit: 255 + t.boolean "donor", default: false + t.string "email_token", limit: 255 + t.boolean "confirmed", default: false t.datetime "last_seen" - t.integer "role_id", null: false + t.integer "role_id", limit: 4, null: false t.datetime "created_at" t.datetime "updated_at" - t.boolean "mail_own_thread_reply", default: true - t.boolean "mail_other_thread_reply", default: true - t.boolean "mail_own_blogpost_comment", default: true - t.boolean "mail_other_blogpost_comment", default: true - t.boolean "mail_mention", default: true + t.boolean "mail_own_thread_reply", default: true + t.boolean "mail_other_thread_reply", default: true + t.boolean "mail_own_blogpost_comment", default: true + t.boolean "mail_other_blogpost_comment", default: true + t.boolean "mail_mention", default: true end add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree -- 2.52.0 From 69c0037cf6510b1dbb7717dff6ceab2884c9073b Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 17 Jan 2016 23:16:37 +0100 Subject: [PATCH 012/214] add README --- README.md | 23 +++++++++++++++++++++++ README.rdoc | 2 -- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 README.md delete mode 100644 README.rdoc diff --git a/README.md b/README.md new file mode 100644 index 0000000..b9180ae --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# redstoner.com + +Redstoner's ruby-on-rails website with blog, forum, etc. + +# Installation + +You need a MySQL server with `utf8mb4` support. +If you have issues, try adding this to your `my.cnf`: +``` +[mysqld] +character-set-client-handshake = FALSE +character-set-server = utf8mb4 +collation-server = utf8mb4_unicode_ci +``` + +The rest should be a default rails installation: +```shell +bundle +rake db:setup +rails s +``` + +Note: We currently use rails [4-2-stable](https://github.com/rails/rails/tree/4-2-stable) because it has backported [support for `utf8mb4`](https://github.com/rails/rails/commit/37e5770fd3db04f3206075d736fc14161dd04530). \ No newline at end of file diff --git a/README.rdoc b/README.rdoc deleted file mode 100644 index 1524f99..0000000 --- a/README.rdoc +++ /dev/null @@ -1,2 +0,0 @@ -== Redstoner.com -I'm too lazy to write something here :D \ No newline at end of file -- 2.52.0 From 1ed36f21294f18026c3a6d3e29b9ec3a76674200 Mon Sep 17 00:00:00 2001 From: jomo Date: Mon, 18 Jan 2016 00:23:39 +0100 Subject: [PATCH 013/214] changes for rails 5 --- config/environments/production.rb | 4 ++-- config/environments/test.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 2c4c3e7..257ea31 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -9,7 +9,7 @@ Redstoner::Application.configure do config.action_controller.perform_caching = true # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = false + config.serve_static_files = false # Compress JavaScripts and CSS config.assets.compress = true @@ -35,7 +35,7 @@ Redstoner::Application.configure do # config.force_ssl = true # See everything in the log (default is :info) - # config.log_level = :debug + config.log_level = :info # Prepend all log lines with the following tags # config.log_tags = [ :subdomain, :uuid ] diff --git a/config/environments/test.rb b/config/environments/test.rb index fadfd19..b6605f1 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,7 +8,7 @@ Redstoner::Application.configure do config.cache_classes = true # Configure static asset server for tests with Cache-Control for performance - config.serve_static_assets = true + config.serve_static_files = true config.static_cache_control = "public, max-age=3600" # Log error messages when you accidentally call methods on nil -- 2.52.0 From ec8d0095f32356c5f1ba2eef55903f3aedc66828 Mon Sep 17 00:00:00 2001 From: Jonas Folvik Date: Mon, 18 Jan 2016 20:28:03 +0100 Subject: [PATCH 014/214] Removed methods that are unused and not needed Removed the haspaid?, correct_case?, ign_is_not_skull and ign_is_not_mojang methods because they aren't used anymore, since we now have a connection between the server and the website to check if they have paid and that the skull is a skull. I also removed the account_exists? method because it makes problems when you setup the database since some users can be seen to not exist. --- app/models/user.rb | 63 --------------------------------------------- config/database.yml | 1 - 2 files changed, 64 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 83d668a..7bb67e8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 :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 :comments @@ -113,45 +111,6 @@ class User < ActiveRecord::Base 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) - # begin - # http = Net::HTTP.start("skins.minecraft.net") - # skin = http.get("/MinecraftSkins/#{CGI.escape(ign)}.png") - # http.finish - # rescue - # Rails.logger.error "---" - # Rails.logger.error "ERROR: failed to get skin status code for '#{ign}'. Skin servers down?" - # Rails.logger.error "---" - # end - # skin.code != "404" - # end - def get_profile uri = URI.parse("https://api.mojang.com/profiles/minecraft") http = Net::HTTP.new(uri.host, uri.port) @@ -185,9 +144,6 @@ class User < ActiveRecord::Base [id, to_s.parameterize].join("-") end - - - private def set_role @@ -204,13 +160,6 @@ class User < ActiveRecord::Base self.name ||= self.ign 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 self.name.strip! if self.name self.ign.strip! if self.ign @@ -224,16 +173,4 @@ class User < ActiveRecord::Base def set_email_token self.email_token ||= SecureRandom.hex(16) end - - # def ign_is_not_skull - # errors.add(:ign, "Good one...") if ["MHF_Blaze", "MHF_CaveSpider", "MHF_Chicken", "MHF_Cow", "MHF_Enderman", "MHF_Ghast", "MHF_Golem", "MHF_Herobrine", "MHF_LavaSlime", "MHF_MushroomCow", "MHF_Ocelot", "MHF_Pig", "MHF_PigZombie", "MHF_Sheep", "MHF_Slime", "MHF_Spider", "MHF_Squid", "MHF_Villager", "MHF_Cactus", "MHF_Cake", "MHF_Chest", "MHF_Melon", "MHF_OakLog", "MHF_Pumpkin", "MHF_TNT", "MHF_TNT2", "MHF_ArrowUp", "MHF_ArrowDown", "MHF_ArrowLeft", "MHF_ArrowRight", "MHF_Exclamation", "MHF_Question"].include?(self.ign) - # end - - # def ign_is_not_mojang - # if self.ign.start_with?("mojang_secret_ign_") - # self.ign = self.ign[18..-1] - # else - # errors.add(:ign, "If that's really you, contact us in-game.") if ["mollstam", "carlmanneh", "MinecraftChick", "Notch", "jeb_", "xlson", "jonkagstrom", "KrisJelbring", "marc", "Marc_IRL", "MidnightEnforcer", "YoloSwag4Lyfe", "EvilSeph", "Grumm", "Dinnerbone", "geuder", "eldrone", "JahKob", "BomBoy", "MansOlson", "pgeuder", "91maan90", "vubui", "PoiPoiChen", "mamirm", "eldrone", "_tomcc"].include?(self.ign) - # end - # end end \ No newline at end of file diff --git a/config/database.yml b/config/database.yml index efae840..f421bef 100644 --- a/config/database.yml +++ b/config/database.yml @@ -12,7 +12,6 @@ development: database: redstoner-web username: root - production: <<: *default # please set ENV["DATABASE_URL"] -- 2.52.0 From 6138b8d4352bc3c4cf0743b27442fe471bb32657 Mon Sep 17 00:00:00 2001 From: jomo Date: Mon, 25 Jan 2016 17:11:51 +0100 Subject: [PATCH 015/214] fix IPv6 style email validation example: jsmith@[IPv6:2001:db8::1] --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 7bb67e8..c422e28 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,7 +18,7 @@ class User < ActiveRecord::Base validates_length_of :about, maximum: 5000 validates_length_of :ign, minimum: 1, maximum: 16 - 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,}|\[(IPv6)?[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, _)."} has_many :blogposts -- 2.52.0 From 0aa32d363272a8f44a9adf4c42c026994bed9288 Mon Sep 17 00:00:00 2001 From: jomo Date: Mon, 25 Jan 2016 20:51:53 +0100 Subject: [PATCH 016/214] update rails for security See https://github.com/rails/rails/commit/2c8f567e53580872d8c6dfe61201e58793ca131e for info --- Gemfile.lock | 68 ++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8e09425..1e638b9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -25,58 +25,58 @@ GIT GIT remote: git://github.com/rails/rails.git - revision: dd750a33c854bcd9eefe7ea46b0b0bb52c06767f + revision: 2c8f567e53580872d8c6dfe61201e58793ca131e branch: 4-2-stable specs: - actionmailer (4.2.5) - actionpack (= 4.2.5) - actionview (= 4.2.5) - activejob (= 4.2.5) + actionmailer (4.2.5.1) + actionpack (= 4.2.5.1) + actionview (= 4.2.5.1) + activejob (= 4.2.5.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.5) - actionview (= 4.2.5) - activesupport (= 4.2.5) + actionpack (4.2.5.1) + actionview (= 4.2.5.1) + activesupport (= 4.2.5.1) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.5) - activesupport (= 4.2.5) + actionview (4.2.5.1) + activesupport (= 4.2.5.1) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.5) - activesupport (= 4.2.5) + activejob (4.2.5.1) + activesupport (= 4.2.5.1) globalid (>= 0.3.0) - activemodel (4.2.5) - activesupport (= 4.2.5) + activemodel (4.2.5.1) + activesupport (= 4.2.5.1) builder (~> 3.1) - activerecord (4.2.5) - activemodel (= 4.2.5) - activesupport (= 4.2.5) + activerecord (4.2.5.1) + activemodel (= 4.2.5.1) + activesupport (= 4.2.5.1) arel (~> 6.0) - activesupport (4.2.5) + activesupport (4.2.5.1) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - rails (4.2.5) - actionmailer (= 4.2.5) - actionpack (= 4.2.5) - actionview (= 4.2.5) - activejob (= 4.2.5) - activemodel (= 4.2.5) - activerecord (= 4.2.5) - activesupport (= 4.2.5) + rails (4.2.5.1) + actionmailer (= 4.2.5.1) + actionpack (= 4.2.5.1) + actionview (= 4.2.5.1) + activejob (= 4.2.5.1) + activemodel (= 4.2.5.1) + activerecord (= 4.2.5.1) + activesupport (= 4.2.5.1) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.5) + railties (= 4.2.5.1) sprockets-rails - railties (4.2.5) - actionpack (= 4.2.5) - activesupport (= 4.2.5) + railties (4.2.5.1) + actionpack (= 4.2.5.1) + activesupport (= 4.2.5.1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) @@ -103,7 +103,7 @@ GEM capistrano-bundler (1.1.4) capistrano (~> 3.1) sshkit (~> 1.2) - capistrano-rails (1.1.5) + capistrano-rails (1.1.6) capistrano (~> 3.1) capistrano-bundler (~> 1.1) capistrano-rbenv (2.0.4) @@ -143,13 +143,13 @@ GEM mime-types (>= 1.16, < 3) mime-types (2.99) mini_portile2 (2.0.0) - minitest (5.8.3) + minitest (5.8.4) mysql2 (0.4.2) net-scp (1.2.1) net-ssh (>= 2.6.5) net-ssh (3.0.2) netrc (0.11.0) - nokogiri (1.6.7.1) + nokogiri (1.6.7.2) mini_portile2 (~> 2.0.0.rc2) nokogumbo (1.4.7) nokogiri @@ -167,7 +167,7 @@ GEM activesupport (>= 3.2) choice (~> 0.2.0) ruby-graphviz (~> 1.2) - rails-html-sanitizer (1.0.2) + rails-html-sanitizer (1.0.3) loofah (~> 2.0) raindrops (0.15.0) rake (10.5.0) -- 2.52.0 From f47b2b5129bbc4c99d80630950cf55ba95cf436f Mon Sep 17 00:00:00 2001 From: jomo Date: Thu, 28 Jan 2016 21:50:05 +0100 Subject: [PATCH 017/214] ruby 2.3.0 \o/ --- config/deploy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/deploy.rb b/config/deploy.rb index fc4dc93..83d7948 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -15,7 +15,7 @@ set :keep_releases, 5 set :deploy_to, -> { "/home/www-data/apps/#{fetch(:application)}" } -set :rbenv_ruby, '2.0.0-p247' +set :rbenv_ruby, '2.3.0' set :bundle_without, %w{development test}.join(' ') -- 2.52.0 From e9ca7e790dc29499ef220e5cfb7462f935c51bf0 Mon Sep 17 00:00:00 2001 From: jomo Date: Fri, 29 Jan 2016 00:29:07 +0100 Subject: [PATCH 018/214] update donation page --- app/assets/images/anonymous_skin.png | Bin 0 -> 11119 bytes app/views/statics/donate.html.erb | 50 ++++++++++----------------- 2 files changed, 18 insertions(+), 32 deletions(-) create mode 100644 app/assets/images/anonymous_skin.png diff --git a/app/assets/images/anonymous_skin.png b/app/assets/images/anonymous_skin.png new file mode 100644 index 0000000000000000000000000000000000000000..a05aec91bb334749893eaf456676bf39b949b457 GIT binary patch literal 11119 zcmeAS@N?(olHy`uVBq!ia0y~yV6b6eU})!HV_;zL`e=28fq{W7$=lt9;Xep2*t>i( z0|NtRfk$L90|U1(2s1Lwnj^u$z`$PO>Fdh=fKf(VMA~8Q?Vk(`T7NuU978H@U7ed5 z68ik>hoASh_|7)-oNcD&J2^|Zx6s9bP0-biHFe$-t*(ZKu8Ns~ZZnT?iXLT5pCaif z=$rIxOXi}^&jOck+}UE7`&j*2)%9EN@15WKd&Bvi-?hH|kAMC4ccT7-JJtNpzrXo- z^SR~u(x0zZuaC*Qzwd3)^K-J(*YE##>*@OXzpGE*-CZ90!h%!w`Slk+)<$o?QoZlb zC-2gpdxz&ME-b#7{bgVE_jfC=zbv;}R=2~;3 z-&1_~Y0&$!{(Ws4#qXER*t?ha;VRCh5IUN6fJ{z&MZD-U%5nbo}IIO{=Gd9i(WdlN8dhX@VWC=t20No zW2J+=|1~$BiyzP5vw7wAe)99A(~mxHdg@_N>HFvZlA<4_`}~$B+D*LZ^K((UMx6D7!%Ys&qw;40IB(xX7#%A_k9tPf8#4R1{Hsqe7AG`-1W29PwxL*I*Dnku&3`Q4)6buCqDUp z$^V;p-Tt(w>+5&KH_Z&3Hktgbn_a1yoDUs2!et?N?-1kWE$p_2q2w ze;*mYt^a)V(}T^=Zu&e;FgA&|-XA_|+cMj0Gh{?LPsu-;Y^XE8<6QCMSK@l&zsq;- zy*VXAF3W3IL7Drf=FQe(hiAU^yb!kEgDGp1YQ5f+bsyU1sF+90HF(H zn%lMS<}IFjf zdo3BK?K`$(;r24MnfrGX$Q;bK;0dbXs$^ly7P@N^Flp8q%YrRhOl;d!58YgrBC|o| z^v$=O&f?#e%-a9sv*q^PhvZY!65^k|PEGyj;KBOp#ZOkVU^DfXr+I4MKKh*}9(8@z zZ>hk=v)vp#*#agvTTc>s(9tG-c;2I*6VhjKz7z~jIC|*h1VKyDO^;#{Ygd`eM9Akc z$NFq|Wz1}0A?aS@;x9M+KEOzX^?umx?ga?#tZvZ`OcZ#Y?fQw({d?9o@MSThv3{zMparNDHVr5 z_I6Ksw$zj-$Gd6r*6s%mKWju^Xl!_^&A(~OG&)jbH z*c;PM&U5^k60RR#@^eFV@rRekZrrmoxhp4AdF{o@vxVEZuQhMGe$+AcTFlauTU>)p z0wz5Q@xKu$!l3(_Q;mf$>}E00x_-jkcs_shc~XfMOJ>Dhs`75Cc|PJir8 z+?(Dvg*ATvubq0fUTce3re9mYIQg*mcMBPrrs0(Hnq(zV|^z} zTk2cBoX+ht4YSg-m2%A44@Z5u*t24#)rBu7G$)8!%X$gySb0JITiyn@*UU5K-+ryc z@VMdK9b4YO4915-5;>ah4$hm@ze#DW+@-m?vNQp#`aI3>;(+U6KuD{@FN=kST2eplQM9OSx`r!jl$Bw2}v zt2fmyESUNH!>uKf)0igT4rs2N`17ps+r0SN((v$9$=6)5yk{F^y@y&)6R}~mij9?ye%^Lyzlgb)2?n*&pxz1pf%-h zx?;f&Bbh3Vs|f~*|5YyAu4VG(Ste|M!ezsj4#CT+``5bu&t2Ww^lzhxVzVmBkTH^wk8pl*f(u2b5y2IoVvj2g6*?|^S(MB zW;fU%yO!&%P5F+BThrt3UDI;Dw(Z$!qer}NJWRhPta^E@{$6X^wf@X!XTBY+2viQ7 z;*h=hxszU)$CK$iUbpTxOuMivaUpNU#%ayJFK+K&Jadx$qzms$e7MVeui4z)swou} zc$nqR1Z(y)YUVvJE*A(acTD5i<@SfiK)w1vn@RqSS>4sug zrt8hm58WS$mCeHjs+%#&pjsBPl0>tgP< zCoBhERcxE1X?A)h&(oLtHmo<{`DLblKy%BkcgG?!4#(V$>t676*NZ&M-PVUyR=Zr= zmdAGF>+&lfGydvmj3#UUy86I(MDX#6jKT$vLU zdTGDqv~^dD^75y7o|{!swsiIEokkN6xL;5&Sk$*zioe!kQOTOsdQz*Gw-)fczPIj| z#o3ydPA6DzUEIPKdhUAW)HCl4=B;Kf&fV@SU9#`8#7q8Aot9HQH#e|t)p86!?%)13 zGj2ob-54&93sHvh%@35`Zr;1?wPMCDxuBLVQ|n2(`R`7fot!DRJi6UjfzzkX-RVJy zM2R#P^PHyE_T@$!c(WhXnnf7h4`a!_y+go?Gh~MB&zRsi1vWeVi0wCG zk1}g{aO~2l727gR*JZN$>4hi!f={)s;#hd_5uK$gAec5-p+3~0oIp4y2W;|tNSx{2A;}+Mwn+~dJTh_9; z1iSN=UvWKTXtH}TOBbu>b_Uhpd%+@1sVh2dCb#EhMYJ(?*6dhp7dG>$z%F*yt;rQ~ zQYBXUb01q|?O|G6e&tR0f$T@?50szEzw&%#jPKEmxY@SsMM8IUDo-={80o#VlH0V@ zl1V1rF(Y+SwOPUs_r!!r%^8o}KP2^CjWAtdT>M9dH|)OJB#G3f>Tc(SMNf53#6Mc7 zEwh5>ZlB;j+12KvM`rm%DJai>{^)T=sl}C)9|yWvA19uh5`Xwf_`D|0{nbJ?f>oI} zR6Z2f3NG9KODDz6PksA_CwgDaH@+`ocK*8MNlxcO|Mx1B)gD-U<^R5hKg6l^P~eq& zihCwp%hEPEnfPUGvPk9YwNVQ5!#2%4b{-M@~G|mW3uPZ9sh(k zpZ!0v91YrTb|>Y{lNB1epY{7$*mac))Mx4VKJ;7U*1sT)|KSQ@gUmT+-mT!unW$A2 z)%f_T!j^=EPL8eVey-koFSIv{uF(k&bxqeceR;#|O}VJvT)xi6dWW@k%=6a&#jMpMp?$~4dCVDmH7RA;-`WelcYIHS3f)C$m12W zfaj75i=*Y!iwptl?(WoM2y%*VT_AbB@%oSX+5zu5{Tu&Zi9dLT)BkXGa$V0SmY%to%1c6k<+0Dlpt-cQw% zJ`05vF68z!saAgdsXoPW|F=VvAN)O5eC@Nzk%(XA%VwpVpX<7Mp=FolslzN6gTz?& zMn5u%2#wbEYzmgh(O4uGD*Scg7ME6bQ3Wm;Q@;Z`MOG(TS!BKWofoV;-}HaU@`K#I zH}WqT3%vWQq|&~pZDPeNu9Agu` zN+VbVR_k5Ml*4!*pxGuC@SeKk`_Kxvxs$B9KoA)?=x_=YZ-u#9&> zdX8`h$9i#*HSb^VZ}@3EzrE#vy_3~1J5yecGTCQ$GWOda=-IgB=kf#GtqIHf|EjX= z-ruoNkt29cf9l^;36pbPXKjz#v0~cYeeR6W%|46XK3Z$M^7C2msR9-HO zvI>1j^5vSgK=ah4DHGDXgd(!8a;?h$_0~b6|Ks@sH}2akRC-@Dr%EX2Ws&@xUe?5` zVryspTzVtzlXSn@pIgBKCT}fedR}hGoGbrEi!bE;@!b;Nv#+1if0}UgLR8eFZ+!RT zRTFyFh;^-FcZt2z%*x6f%yrT9<2JPwF;#iXJTxZoSz2?B1?Z*}zo|P;tFT-k3YVDWwIA7FH z?9RU*-V*JzY8g#`e=4?b)l8n>7B#18+v77mUcOcKXB+)4RyP9Ny@# zC>cC`cw^#}Ckzpe`9fhI1QIU2;?vRO{@{1yhxi7sDn9P^`*w`N@dp#0el`+WTJ>U! zm#Y`^xdmZ*HO#f&B11C;3pO0*zHxKT`m~^^&hBY9+g$z6CQM!W%qO(3Bs^D4apBUo z?^DCeJGy8cbqU++JpcPb=x))&dr*GJ3j zPt7sledbf=wtCC5KMyrO%>0rav9Ca>$*se#%*4+?>|kDwprQ`r@)J)5X4MuiO+9-! zq(b4tGQk9)O9oeW^)s)DT6<-S^W@3FE^FOe>t6kndKPu%mDik)0S_Lw#rzNROWY{% z`un7&uRoN-Vua_n-Kb11w0f~DiRb(gzr3C!&mJ6&z!CCuHd!OH+*wCh$n^SyrYG9h*8 zw@d{@e87dZ>VE z>Kh%dmbDhIwT@(}`CGnR=N8vCpKpe>d|CNTj=0l@m2?AjePx|i&A*wlRyQlK0c{GBkB14_KSKYCA+4PULxOa+7&6XW3(xrZYQb8&Ar<_*^nOq;6hXiuwkf zrF9Vpwxn;pd1*`GwUdrZ?pv6yzc$T7VU48Y%d*pbO7*Y5KKy^HbzSg{x#^CEC$BQ` zEpJc%wyy7}=O58Mp_V@0;xDcpFO1Ijy!UybR2Q_^5cixY5zpY#O}u-P4D! z3UWU@iS1e}eRzwg-DiOt(%vU3Elhjn8He4?n^CaNR4W{+;@-|)S@ya@qotRK5 z9eVxW1E$}{#O3YF*KN)4t-m};F?x0S45cD=v!{IFtt&OOrppGNvTPFfD(8Li==|F) zOu^SL3Kpziu`%<)lP3$Wnmt@#SF+-GzCzM9@2sT^%xRBPn(}sM*&2RHy!J{?=1*+J zTwYsOmemd3-_mD3*`*hIVN$kkX5!7I{p_~q-k#Q!$%y(SX!fOT?L>>Ht(jNf`ebd9 zekU3j{C-NVk>i1)C#nXGla9_g@T}1!lWWrM4IfsV`qG$F`uGgj^xg@QhQW%46*e=T z?O(@!?DLyL2lH}Hx87QqwZeA0U>E=THs0RTI-*m%eRqj66s_~v|M^X4_uJRk*X^kJ zb?xM;;@`#ZzbEZH7C7bCC3S=Ka_gQv<*52lW^z0D#r<<$-cmF6t^N2Y>~vD8@H)eC zJ-^RsE35@rc5^*Hc%{jgXCA}8;CklZ}@dWVM;w7=2%?J zRg&;4zetpze6sBN z+}-6del<6qwKb$kzhQ0)z0`SWpV+CsH0RTPb55JR%HKZW*h-y{%U;bhPq)c#P0i%< zX=Tz+eY7?DY39DHP4XsxuX9cNv_ZN_%>5rDTlbv@`DYuszFqz+7_ig#@-nvDwN>*Xy{R_ZY|rKWy$+Eg8@9yhCdBTpJgd6jwp{8^ z=_?1xZRZj-YCH7)N78SZ9R^WG0GDdN4dZJD$Bw|yCDrbg~dRXw;%54>4ky1JmZE%%>y zQI)lro`mwcd3TxOuT~t~Yc>1Lr}q4^Xy2KMo_q^`#?>yr%8|u>X4;z1@q02R`|jpC zb|?39q;kc2<`3&8eizxcw()KCG-q|k{65h-YbKx5;u(oNOBes$=1?xsJy* z;HXI0&8as(`;vp_JU<{`_9H>WNpNdEXIUi;yF_Hxq*wquXQZ1N`Y zx4y8NX7#}D;btM8gJ)&kde=2?+BY#U{l=wzO4(nXi?(sidhMHKch>ghv^Ld%@ZCPl zf8W$_zq!AcFYEO*?TZZ;>$h)BcS_8kC&c+@{c2{b0I}PJ++Ch#Pf9O4$!_>^vpr+# zf~<3)ul1aMUVphsFk*H{ZWQ0rwX4_6+U_{<&aV#|Tjb-`TOT`6pUt=7*IM3d9B(+n zI@s1^&Zv&`Ym`?q-R3m6<=@X^m#1!6xc&&=6xZ}uJY^?x*iRiVZ9K&meJ%dijRQrk z&F}bj&h@lr5JjKMsIcI z4D0D-j;n7oZm?Kq(j9fIZM&SCj5*WvFJewtXBPcUP{_Ettwh6e)?#bF1>*e24ji=G zEW1L8r(^L|gUF3c&raI^)yeSO-hXK?o4we@*$q97U0ZbeKOYUBzt&~{y$1oGU+328 zu5D&pv)MTMxslM6e&acYUfu~iJz~E1IG_9_5gh2eN%eoiwA#djKf{>jUu4$)FLjCC zfVE^5OObVvTly=O@@-M(5pD^Ua}K<#FXYV#PRXbi(7QpXU}bt`3$Ge9+gm!GQlGMub3D{$w9CF~3l3Cd_ho|34La!LVIo!~FalLkK-QOJtc(PgL zTrPZOIkl+aX;;);W?P``(med!w~JGT(ilKJK|MfgtP(Iox1M|C5c~? zTh!i)zl&*Gc{1v9m~uwy`4qeWm zLmTS%-*_${(LejiFU`!B9sW7bx9oE;)7j0X8YPWq z!`k}3?GR~8eegT{+>M{>-|i6Gvc+ueor(vE2Xy`(Kecd^QXqTHrv%NKpM|pzuXASf zlk9b6^$aZkmn>V(@@Cp2uK)W!E|Y!3zy03B$6Pb2->*8V9R8t)ZN`&hw|_tUanI&P z`?KngXZN1FrR~+@+PXREap3W#KT@g=X)EdS~{hd1gx*eYz^>j}jmoC{J zF^4gF#qSRv3#|*>8y4+d#2CCYQ%C!yMdtlGJIg|jPyKeAJHgEEkn;i^s|2Q0!2?CQ zJD#0crTCs@hW@|V{+V}C%$??`)Y3KUd#q}EEciJ+a-(~mr#sQwy zZ$B-ttqR>E)h;D>1*Homb!T_)45%ne3I{A3oo&yY=vj&Rp00$A!UvlO)<- zFXf!l>X800IP+(2TJ?k5??2r?tPviN^i=qRUXkU2z5RXJ2Y51mZaKX0W!>-0<(I#4 z?RDGmU-&`Fp8HRv?0wn2J{>#6IbmD&(GyP`f2|k#`ki?Sw}$2S{C)O*dG{9F=6fbT z{g>}Fe=FT{e=cjBd$y40_k4zQxl;`9dGwdMa{gNMUZO*{d((VfL50k#S;r2W8Nd5` z{cL&D{++df+k;!*6-NDfy!$-6kH(ZW|HB*J*Wddbap2<9i3Z2sSDv+(G&8s@e`=Ta zTP=gD3_JeX9pqaq@Is*L=k43|KR?F5zjyJi@DgACr@V!1Za?K2|33~gpH;p8SFOo` z)7zIHcr7Sga~&#Kekuy^{Th8Cz_xb(^z7?Fg@^V@&!2${jnzjoq=z z^}zCgD$@ip-x=i zGW2<;HFBHjZCuj2YuSm^)|lW8OsQ6vbmgC|+ruKqX!BHL2HTN!dy8VT*J~t3tp768 zKr?Ak?5vq`)}mo=&u`M!{XA=0V`U}7lQZR^hc>+YT;Q0sNdIr1qv1*3<4>lU7AbQ7 z5BXhjqE=sqQQCESckkP&($C*={oHA}`QcU8$8Q{tv+ZH(&K7!miN{o+IJ`Y;fsXdG zeT=J}KF(}&HI|HHHnY2}z__%mls`+d_J(D_`s9S&lHI2EQjYWIel%$jJ+poGi{PJ; zK@(Hhy(Vox;oP{%py1e^lWLi#Y)(FZH8EV}r0=nk$}E!um-f$P-hcRKAiFiUc&qrF z6PsV>^|rAvo42k3H$BFb$kc!$}lb02oU4!S)gL| z;9_3-^5R$ZarXJY{=J&;bhp0W>jNJwYU*=24xYDQJ9ck_bHbIP8rPoK){v{Mvb;XV zZWl}!UJfkYA)=J9NvKWtn8sTU3+swip4SAAb(|5LeKy+L`wtW2;s}lp|E6xXN|^S3 z{iDL$4J*vJ_?Wgi&pj8_vu{>>A9vIRmEH{%AEj2X=yiO#a?q$C>_dom+Jz9|?@yk@ z$sViy{Y0;K*Vjm)8>_AsbJ(q@^U9E$P;c3B>Qw#F`$87XeiM~z zx%sM(^^HFq{tf{`tUAwko%^g>WXYq%Les%su@*IO@?M z=e!@5v(_q_riWFZjQjn=vL&k7sAYqg2V=llw7>!Pjs|z_ML$5uXk^c-M9DKI_aiafg%=} ze9B=?Sj~RVbx)>ihP~UOQto)Q zwP>g5tN8aZ#XsM@s$}h3ARZuRBU8chW&RD8_m$ft*Gd@tTB5x0`UamX4ypxVA588p z*svgS^@7wd;X4Z@KA$+-xHZ(KXyT4LpTEwwj!*a^$KiG(jw^%1>W{$#Zh85pNo^vz zoh>^Y+BdAe;BUD6*1<_n7I8|iO(^ZqX4TR4lHQ*FbXDN9gq_#d-7P!zsri;((~i$K z_O6!qb9>;#^0#B5>W8K0Z!LW3vz2Y;ya&vd(bFRS3hGZ_P*=@5_;b+ zZwME8$t%iPT$0&2KWF;w3n%`r>7C8^s!Vj6^t)5+_FMiY6rR3f|J`)D@|#+=eZQ9n z?~p2EU9$YA^Sj2WWod6X76gbW^fR4vj@R#VfcGb6;&y-Pck<4?iR-f`x3{~RKE8L3Bh6{!k~4L&j>~@dNic5f6l|-x5@EB#LDYct zTHDUsjh}w^E?Dx?#+lh6EUc(ncAng+l!+VAk)4dk0Vm515;z|s|w=?Bc}FEd_l znOAee;CG-f$Im*pSoznhFWs`OT#oOlP?+9iB90p{2N6W%dFc&0;m@M@;qJK0ZAsFCP1C^g${%X#467 zcbxsQ;?%zX7n$*=@3aeNOiSIYmkiVH<+G@Ic5^k%SmEIi!J6~N@pSvSp11OE|7|eg z{JE8NlfZM`I63hdUXGlnf+SwDNlrJBbw6v8dLI*A2@B$WZe`i{wz_v zQuFPNOFe$me(q&l8K`I#pxG_1ziq*cp3e!7#bZyDtQM6!#*zEx%gOf*2?-(}O6D^@ zoHtpmsKO0v3@#ASPr}(YWL8vFWgXDjY`e^P%5|6a2PQk^Q)e}*GQJbopJDfV1>3ACQ&>(< z({0|e#Y9yo!tL2blg}k}uilukPM;yN<=NTU>7TxS-C9vm(a@qc)4W(qrNaLL!drbJ*tejeEP>;9S!u1(CTZ>1b%8Be>W2W>9O(%3KSu-vom;Kgq**VJaacQemG1zy#Y5v9BjD$J=KbbRoPTqccfB!E3 z$2>Dw|4Iw(J${>U`I)&)rx!WDRnq^d*~wBX@u5ppdx~hm!-Kk7KWmLQF-&|Jw)^vk z6(@A^t?jsG962m&F7t8D8b*D-kF7IaXjn%~KDmTJ=AaeRG7sPR6Q^E#d?zjNb7Evn zMz787>l`Odj#`WKv(2czdHk;EBc(%cFYz4IiQjkU#bm$6mwUaZ=>%>Nk}%DkbnQe` z*_QcBw{b2gj8gsn)X+}Lzxjj30Tm;KiT%r#EV1BrDsysWTdK;Is#x!CenCsOl6lT) z&&U6qcHLfTwB>Z%v_G3xy0hwP8pYbW&AQmK$Yl1Oz!PhFGc!}(PmJDGyD3$6ZS<8- z7WZAvq!NVc>+3&!{CH7oY2Xq`RU==|fK5D~%9Epv#5^}mduF4vd@tYkM-%G~HXoeD z$HisD%EEGk@%$W1;k5Jfa@p-}nK)0JdMuRha;kAFS%_fa$Nf4V&lx4 zbEjm_ee#OIF0-Iu1Lsj835gdM^7ro9BgZ`>At%#KokgE{w#Y1(2MG}YKF5|RPoG@0 zvsuUR?Y^YbH(!aHNwT>y3b9?kdSx+#+GiDG(ZKNM@B7#^l$Dt`ZQAt07~JfZtxcc( z(ONq4@G3@y{mnjQY;$Ti_X^HnIU6G?vzYZ+O_qo8u1!Jv>}_pjjf{;&bxtw=Im0?- z&boE$3XALw9{)|ud?mB9w0l>|b_cU}DYuUc8hA!T%wSr+>z3pO!}+I7l6AB_IZB?M zn#yCfji)DQ3 zvKVAnty*RD|EYfc&y9boE*_ux=k>lDO}?`)_v=_ZnNnzSAm`SUetG4yFA`4rOO~9S zW%_LU{kq#{1I@2WG^ccjt-EmflfmpwYutOY=car*b|>qQjI~xm^3tyzCWjZOobngE zcITd7ywumJhmEdh?Avr(Yrk{oJ==?C4&A6PD=U_~+{by;>6Y^3QkFL>E)`8nJK@jz zVuSA8FL}4NX#RM0bv566$=+rEb;MVmbX$_QUG?Uoso(V9dnx4ToD!Xqcxq=zPC(YA z15ef~Dk`p$co=q8;}TCJ-_s{gX4wCDz<__&%fXAm&?9AHT(am_wviW%i7o7;r)BNXMwW@myF|o z{^gRJ+W!5kGq2p(x9?r~mhLnE=GXr>_^Tp(^wN3eMD9Slq#Loj%UbX4D0IHu^pR2P zrPi@6pX0y(JzV6fo&D(2Qg6MCT~Ae2Rkz#y{c?G}M7hPZ*&k0I+i9bA{_p;;e-Hl` Zf3dBecW3yMBnAcs22WQ%mvv4FO#n$0kgos$ literal 0 HcmV?d00001 diff --git a/app/views/statics/donate.html.erb b/app/views/statics/donate.html.erb index cc1774b..2831807 100644 --- a/app/views/statics/donate.html.erb +++ b/app/views/statics/donate.html.erb @@ -23,38 +23,24 @@
- jomo's skin -

Donate to jomo

-

jomo is our admin. He solves problems & keeps the server running.

- -
- <% if current_user %> - - <% else %> - - <% end %> - - - -
-
-
-
- Dico's skin -

Donate to Dico

-

Dico spends a lot of his time developing custom features for the server.

- -
- <% if current_user %> - - <% else %> - - <% end %> - - - -
-
+
+ " alt="sponsor's skin" class="body"> +
+
+

Donate to our server sponsor

+

They pay for our server, but prefer to stay anonymous

+
+ <% if current_user %> + + <% else %> + + <% end %> + + + +
+
+

-- 2.52.0 From 138a98f086aae986083b597511a0c79da121eadc Mon Sep 17 00:00:00 2001 From: jomo Date: Fri, 29 Jan 2016 21:36:17 +0100 Subject: [PATCH 019/214] Revert "ruby 2.3.0 \o/" This reverts commit f47b2b5129bbc4c99d80630950cf55ba95cf436f. --- config/deploy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/deploy.rb b/config/deploy.rb index 83d7948..fc4dc93 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -15,7 +15,7 @@ set :keep_releases, 5 set :deploy_to, -> { "/home/www-data/apps/#{fetch(:application)}" } -set :rbenv_ruby, '2.3.0' +set :rbenv_ruby, '2.0.0-p247' set :bundle_without, %w{development test}.join(' ') -- 2.52.0 From 7987e37f11dc53fc8a4daef84b15d6f02af552fc Mon Sep 17 00:00:00 2001 From: jomo Date: Fri, 29 Jan 2016 22:01:33 +0100 Subject: [PATCH 020/214] use ruby 2.0.0-p648 --- config/deploy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/deploy.rb b/config/deploy.rb index fc4dc93..7088897 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -15,7 +15,7 @@ set :keep_releases, 5 set :deploy_to, -> { "/home/www-data/apps/#{fetch(:application)}" } -set :rbenv_ruby, '2.0.0-p247' +set :rbenv_ruby, '2.0.0-p648' set :bundle_without, %w{development test}.join(' ') -- 2.52.0 From 1a04b3c8822e131536073a48c29b9f4e920733e3 Mon Sep 17 00:00:00 2001 From: jomo Date: Fri, 29 Jan 2016 23:53:13 +0100 Subject: [PATCH 021/214] try fixing mysql utf8mb4 issues --- .../mysql_modern_column_type_defaults.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 config/initializers/mysql_modern_column_type_defaults.rb diff --git a/config/initializers/mysql_modern_column_type_defaults.rb b/config/initializers/mysql_modern_column_type_defaults.rb new file mode 100644 index 0000000..4189537 --- /dev/null +++ b/config/initializers/mysql_modern_column_type_defaults.rb @@ -0,0 +1,17 @@ +require 'active_record/connection_adapters/abstract_mysql_adapter' + +ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::NATIVE_DATABASE_TYPES.tap do |defaults| + # Decrease default string length from 255 -> 191 chars so *_type columns + # can be indexed with utf8mb4 without blowing 767 byte max key length. + defaults[:string][:limit] = 191 + + # Use microsecond precision for all timestamps. High-precision times are + # first available in MySQL 5.6, but default to second precision for + # backward compatibility. + defaults[:datetime][:limit] = 6 + defaults[:time][:limit] = 6 +end + + +# thanks @jeremy +# https://github.com/rails/rails/pull/23009#issuecomment-171406595 \ No newline at end of file -- 2.52.0 From ceaec53d39b6a51135ece76d0ffdc098a3058e08 Mon Sep 17 00:00:00 2001 From: jomo Date: Fri, 29 Jan 2016 23:57:44 +0100 Subject: [PATCH 022/214] remove mysql 5.6 fix --- config/initializers/mysql_modern_column_type_defaults.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/config/initializers/mysql_modern_column_type_defaults.rb b/config/initializers/mysql_modern_column_type_defaults.rb index 4189537..1a8e411 100644 --- a/config/initializers/mysql_modern_column_type_defaults.rb +++ b/config/initializers/mysql_modern_column_type_defaults.rb @@ -4,12 +4,6 @@ ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::NATIVE_DATABASE_TYPES.ta # Decrease default string length from 255 -> 191 chars so *_type columns # can be indexed with utf8mb4 without blowing 767 byte max key length. defaults[:string][:limit] = 191 - - # Use microsecond precision for all timestamps. High-precision times are - # first available in MySQL 5.6, but default to second precision for - # backward compatibility. - defaults[:datetime][:limit] = 6 - defaults[:time][:limit] = 6 end -- 2.52.0 From e077fd2a0a001e6d0474e14e00e25ac2c11f4e99 Mon Sep 17 00:00:00 2001 From: jomo Date: Sat, 30 Jan 2016 00:01:57 +0100 Subject: [PATCH 023/214] Revert "remove mysql 5.6 fix" This reverts commit ceaec53d39b6a51135ece76d0ffdc098a3058e08. Revert "try fixing mysql utf8mb4 issues" This reverts commit 1a04b3c8822e131536073a48c29b9f4e920733e3. --- .../initializers/mysql_modern_column_type_defaults.rb | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 config/initializers/mysql_modern_column_type_defaults.rb diff --git a/config/initializers/mysql_modern_column_type_defaults.rb b/config/initializers/mysql_modern_column_type_defaults.rb deleted file mode 100644 index 1a8e411..0000000 --- a/config/initializers/mysql_modern_column_type_defaults.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'active_record/connection_adapters/abstract_mysql_adapter' - -ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::NATIVE_DATABASE_TYPES.tap do |defaults| - # Decrease default string length from 255 -> 191 chars so *_type columns - # can be indexed with utf8mb4 without blowing 767 byte max key length. - defaults[:string][:limit] = 191 -end - - -# thanks @jeremy -# https://github.com/rails/rails/pull/23009#issuecomment-171406595 \ No newline at end of file -- 2.52.0 From ce304ece433cea150e2fc8507ea07627f9292ee7 Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 7 Feb 2016 14:25:53 +0100 Subject: [PATCH 024/214] fix utf8mb4 / MySQL5.5 crap --- config/initializers/mysql_utf8mb4.rb | 10 ++++++ db/schema.rb | 48 ++++++++++++++-------------- 2 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 config/initializers/mysql_utf8mb4.rb diff --git a/config/initializers/mysql_utf8mb4.rb b/config/initializers/mysql_utf8mb4.rb new file mode 100644 index 0000000..5166977 --- /dev/null +++ b/config/initializers/mysql_utf8mb4.rb @@ -0,0 +1,10 @@ +# https://github.com/rails/rails/issues/9855#issuecomment-28874587 +require 'active_record/connection_adapters/abstract_mysql_adapter' + +module ActiveRecord + module ConnectionAdapters + class AbstractMysqlAdapter + NATIVE_DATABASE_TYPES[:string] = { :name => "varchar", :limit => 191 } + end + end +end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index 586de61..376e758 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -14,7 +14,7 @@ ActiveRecord::Schema.define(version: 20150825232749) do create_table "blogposts", force: :cascade do |t| - t.string "title", limit: 255 + t.string "title" t.text "content", limit: 65535 t.integer "user_author_id", limit: 4 t.integer "user_editor_id", limit: 4 @@ -32,14 +32,14 @@ ActiveRecord::Schema.define(version: 20150825232749) do end create_table "forumgroups", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name" t.integer "position", limit: 4 t.integer "role_read_id", limit: 4 t.integer "role_write_id", limit: 4 end create_table "forums", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name" t.integer "position", limit: 4 t.integer "role_read_id", limit: 4 t.integer "role_write_id", limit: 4 @@ -52,7 +52,7 @@ ActiveRecord::Schema.define(version: 20150825232749) do end create_table "forumthreads", force: :cascade do |t| - t.string "title", limit: 255 + t.string "title" t.text "content", limit: 65535 t.boolean "sticky", default: false t.boolean "locked", default: false @@ -65,34 +65,34 @@ ActiveRecord::Schema.define(version: 20150825232749) do end create_table "info", force: :cascade do |t| - t.string "title", limit: 255 + t.string "title" t.text "content", limit: 65535 t.datetime "created_at" t.datetime "updated_at" end create_table "labels", force: :cascade do |t| - t.string "name", limit: 255 - t.string "color", limit: 255 + t.string "name" + t.string "color" end create_table "register_tokens", force: :cascade do |t| - t.string "uuid", limit: 32, null: false - t.string "token", limit: 6, null: false - t.string "email", limit: 255, null: false + t.string "uuid", null: false + t.string "token", null: false + t.string "email", null: false end add_index "register_tokens", ["email"], name: "index_register_tokens_on_email", unique: true, using: :btree add_index "register_tokens", ["uuid"], name: "index_register_tokens_on_uuid", unique: true, using: :btree create_table "roles", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name" t.integer "value", limit: 4 - t.string "color", limit: 255 + t.string "color" end create_table "sessions", force: :cascade do |t| - t.string "session_id", limit: 255, null: false + t.string "session_id", null: false t.text "data", limit: 65535 t.datetime "created_at" t.datetime "updated_at" @@ -111,20 +111,20 @@ ActiveRecord::Schema.define(version: 20150825232749) do end create_table "users", force: :cascade do |t| - t.string "uuid", limit: 255, null: false - t.string "name", limit: 255, null: false - t.string "password_digest", limit: 255, null: false - t.string "ign", limit: 255, null: false - t.string "email", limit: 255, null: false + t.string "uuid", null: false + t.string "name", null: false + t.string "password_digest", null: false + t.string "ign", null: false + t.string "email", null: false t.text "about", limit: 65535 - t.string "last_ip", limit: 255 - t.string "skype", limit: 255 + t.string "last_ip" + t.string "skype" t.boolean "skype_public", default: false - t.string "youtube", limit: 255 - t.string "youtube_channelname", limit: 255 - t.string "twitter", limit: 255 + t.string "youtube" + t.string "youtube_channelname" + t.string "twitter" t.boolean "donor", default: false - t.string "email_token", limit: 255 + t.string "email_token" t.boolean "confirmed", default: false t.datetime "last_seen" t.integer "role_id", limit: 4, null: false -- 2.52.0 From 854dc4d8347078b4faf434431ab468714fe094d1 Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 7 Feb 2016 14:27:57 +0100 Subject: [PATCH 025/214] fix old migration file names --- db/migrate/{01_create_roles.rb => 20140617183701_create_roles.rb} | 0 db/migrate/{02_create_users.rb => 20140617183702_create_users.rb} | 0 ...{03_create_blogposts.rb => 20140617183703_create_blogposts.rb} | 0 .../{04_create_comments.rb => 20140617183704_create_comments.rb} | 0 ...create_forumgroups.rb => 20140617183705_create_forumgroups.rb} | 0 .../{06_create_forums.rb => 20140617183706_create_forums.rb} | 0 ...eate_forumthreads.rb => 20140617183707_create_forumthreads.rb} | 0 .../{08_create_sessions.rb => 20140617183708_create_sessions.rb} | 0 ...egister_tokens.rb => 20140617183709_create_register_tokens.rb} | 0 ...te_threadreplies.rb => 20140617183710_create_threadreplies.rb} | 0 db/migrate/{11_create_info.rb => 20140617183711_create_info.rb} | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename db/migrate/{01_create_roles.rb => 20140617183701_create_roles.rb} (100%) rename db/migrate/{02_create_users.rb => 20140617183702_create_users.rb} (100%) rename db/migrate/{03_create_blogposts.rb => 20140617183703_create_blogposts.rb} (100%) rename db/migrate/{04_create_comments.rb => 20140617183704_create_comments.rb} (100%) rename db/migrate/{05_create_forumgroups.rb => 20140617183705_create_forumgroups.rb} (100%) rename db/migrate/{06_create_forums.rb => 20140617183706_create_forums.rb} (100%) rename db/migrate/{07_create_forumthreads.rb => 20140617183707_create_forumthreads.rb} (100%) rename db/migrate/{08_create_sessions.rb => 20140617183708_create_sessions.rb} (100%) rename db/migrate/{09_create_register_tokens.rb => 20140617183709_create_register_tokens.rb} (100%) rename db/migrate/{10_create_threadreplies.rb => 20140617183710_create_threadreplies.rb} (100%) rename db/migrate/{11_create_info.rb => 20140617183711_create_info.rb} (100%) diff --git a/db/migrate/01_create_roles.rb b/db/migrate/20140617183701_create_roles.rb similarity index 100% rename from db/migrate/01_create_roles.rb rename to db/migrate/20140617183701_create_roles.rb diff --git a/db/migrate/02_create_users.rb b/db/migrate/20140617183702_create_users.rb similarity index 100% rename from db/migrate/02_create_users.rb rename to db/migrate/20140617183702_create_users.rb diff --git a/db/migrate/03_create_blogposts.rb b/db/migrate/20140617183703_create_blogposts.rb similarity index 100% rename from db/migrate/03_create_blogposts.rb rename to db/migrate/20140617183703_create_blogposts.rb diff --git a/db/migrate/04_create_comments.rb b/db/migrate/20140617183704_create_comments.rb similarity index 100% rename from db/migrate/04_create_comments.rb rename to db/migrate/20140617183704_create_comments.rb diff --git a/db/migrate/05_create_forumgroups.rb b/db/migrate/20140617183705_create_forumgroups.rb similarity index 100% rename from db/migrate/05_create_forumgroups.rb rename to db/migrate/20140617183705_create_forumgroups.rb diff --git a/db/migrate/06_create_forums.rb b/db/migrate/20140617183706_create_forums.rb similarity index 100% rename from db/migrate/06_create_forums.rb rename to db/migrate/20140617183706_create_forums.rb diff --git a/db/migrate/07_create_forumthreads.rb b/db/migrate/20140617183707_create_forumthreads.rb similarity index 100% rename from db/migrate/07_create_forumthreads.rb rename to db/migrate/20140617183707_create_forumthreads.rb diff --git a/db/migrate/08_create_sessions.rb b/db/migrate/20140617183708_create_sessions.rb similarity index 100% rename from db/migrate/08_create_sessions.rb rename to db/migrate/20140617183708_create_sessions.rb diff --git a/db/migrate/09_create_register_tokens.rb b/db/migrate/20140617183709_create_register_tokens.rb similarity index 100% rename from db/migrate/09_create_register_tokens.rb rename to db/migrate/20140617183709_create_register_tokens.rb diff --git a/db/migrate/10_create_threadreplies.rb b/db/migrate/20140617183710_create_threadreplies.rb similarity index 100% rename from db/migrate/10_create_threadreplies.rb rename to db/migrate/20140617183710_create_threadreplies.rb diff --git a/db/migrate/11_create_info.rb b/db/migrate/20140617183711_create_info.rb similarity index 100% rename from db/migrate/11_create_info.rb rename to db/migrate/20140617183711_create_info.rb -- 2.52.0 From 82d4b1d27b7ae34ca9651e6e100b2bc4cd44ff98 Mon Sep 17 00:00:00 2001 From: jomo Date: Tue, 8 Mar 2016 23:46:07 +0100 Subject: [PATCH 026/214] link to correct user in profile edit view --- app/views/users/edit.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index b2d1bd5..f07ea62 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -6,7 +6,7 @@ end %> -<%= link_to @user.name, current_user %> → Edit +<%= link_to @user.name, @user %> → Edit

Edit profile

<%= form_for @user do |f| %> -- 2.52.0 From 78ddfadb342b715fdd4430495c5ba07152ace597 Mon Sep 17 00:00:00 2001 From: jomo Date: Tue, 8 Mar 2016 23:58:07 +0100 Subject: [PATCH 027/214] don't ignore :label_id on thread creation --- app/controllers/forumthreads_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index aa4aeec..ac090f5 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -22,7 +22,7 @@ class ForumthreadsController < ApplicationController end def create - @thread = Forumthread.new(mod? ? thread_params([:sticky, :locked, :forum_id]) : thread_params([:forum_id])) + @thread = Forumthread.new(mod? ? thread_params([:sticky, :locked, :forum_id, :label_id]) : thread_params([:forum_id, :label_id])) if @thread.forum.can_write?(current_user) @thread.user_author = current_user if @thread.save -- 2.52.0 From ff84cee5527a9ce23506f6f4cfdfb5b203c49e35 Mon Sep 17 00:00:00 2001 From: jomo Date: Wed, 9 Mar 2016 00:45:10 +0100 Subject: [PATCH 028/214] switch from youtube username to channel ID updates legacy code that really needs to be gone --- app/helpers/users_helper.rb | 12 +++++++----- app/views/users/edit.html.erb | 4 ++-- app/views/users/show.html.erb | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 93067e8..2ce1765 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -1,6 +1,7 @@ -module UsersHelper require "open-uri" +require "rexml/document" +module UsersHelper def mentions(content) users = [] words = content.scan(/@[a-zA-Z0-9_]{1,16}/) @@ -11,15 +12,16 @@ require "open-uri" users.uniq end - def get_youtube(yt_name) - yt = {channel: yt_name} - if yt_name.blank? + def get_youtube(yt_channel) + yt = {channel: yt_channel} + if yt_channel.blank? yt[:channel] = nil yt[:channel_name] = nil yt[:is_correct?] = true else begin - yt[:channel_name] = JSON.parse(open("https://gdata.youtube.com/feeds/api/users/#{CGI.escape(yt_name)}?alt=json", :read_timeout => 1).read)["entry"]["title"]["$t"] + # TODO: This whole thing needs to be gone badly + yt[:channel_name] = REXML::Document.new(open("https://www.youtube.com/feeds/videos.xml?channel_id=#{CGI.escape(yt_channel)}", :read_timeout => 1)).root.elements.find{ |n| n.name == "title" }.text yt[:is_correct?] = true rescue yt[:is_correct?] = false diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index f07ea62..6a6fe4d 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -53,9 +53,9 @@ - YouTube username + YouTube Channel ID - <%= f.text_field :youtube, placeholder: "YouTube username", disabled: !can_edit? %> + <%= f.text_field :youtube, placeholder: "YouTube Channel ID", disabled: !can_edit? %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 5be791d..4eafb2c 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -60,7 +60,7 @@ <% if !@user.youtube.blank? && !@user.youtube_channelname.blank? %> YouTube - <%= link_to @user.youtube_channelname, "https://youtube.com/user/#{CGI.escape(@user.youtube)}", :target => "_blank" %> + <%= link_to @user.youtube_channelname, "https://youtube.com/channel/#{CGI.escape(@user.youtube)}", :target => "_blank" %> <% end %> <% if !@user.twitter.blank? %> -- 2.52.0 From f110d2e0add29dd595cc0cb30f0916c845f19a2d Mon Sep 17 00:00:00 2001 From: jomo Date: Wed, 9 Mar 2016 00:56:03 +0100 Subject: [PATCH 029/214] add rendering support for youtube usernames --- app/views/users/show.html.erb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 4eafb2c..ab867e4 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -60,7 +60,13 @@ <% if !@user.youtube.blank? && !@user.youtube_channelname.blank? %> YouTube - <%= link_to @user.youtube_channelname, "https://youtube.com/channel/#{CGI.escape(@user.youtube)}", :target => "_blank" %> + + <% if @user.youtube.length == 24 && @user.youtube[0..1] == "UC" %> + <%= link_to @user.youtube_channelname, "https://youtube.com/channel/#{CGI.escape(@user.youtube)}", :target => "_blank" %> + <% else %> + <%= link_to @user.youtube_channelname, "https://youtube.com/user/#{CGI.escape(@user.youtube)}", :target => "_blank" %> + <% end %> + <% end %> <% if !@user.twitter.blank? %> -- 2.52.0 From 1f51e9d82344ba8d3e39c38db6e720740f42f8b9 Mon Sep 17 00:00:00 2001 From: jomo Date: Sat, 7 May 2016 03:52:14 +0200 Subject: [PATCH 030/214] allow relative return_path only, check validity --- app/controllers/sessions_controller.rb | 13 +++++++++++-- app/controllers/users_controller.rb | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 0e12637..b58028a 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -7,7 +7,9 @@ class SessionsController < ApplicationController flash[:alert] = "You are already logged in!" redirect_to current_user else - cookies[:return_path] = params[:return_path] if params[:return_path] + if params[:return_path] && params[:return_path][0] == "/" + cookies[:return_path] = params[:return_path] + end end end @@ -42,7 +44,14 @@ class SessionsController < ApplicationController flash[:alert] = "You are already logged in!" end if cookies[:return_path] - redirect_to cookies[:return_path] + begin + # might be invalid path + URI.parse(cookies[:return_path]) + redirect_to cookies[:return_path] + rescue URI::Error + flash[:alert] = "Invalid return path!" + redirect_to blogposts_path + end cookies.delete(:return_path) else redirect_to blogposts_path diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index caa5f02..f53b033 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -72,7 +72,7 @@ class UsersController < ApplicationController end else flash[:alert] = "Please login first" - cookies[:return_path] = request.fullpath + cookies[:return_path] = request.env['PATH_INFO'] redirect_to login_path end end -- 2.52.0 From 37cccdff180aab8bb67a202d35ef5b4e6974432c Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 8 May 2016 19:04:16 +0200 Subject: [PATCH 031/214] require uuid for password reset, destroy token after each try --- app/controllers/users_controller.rb | 43 ++++++++++++++++---------- app/views/users/lost_password.html.erb | 4 +++ 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f53b033..ea56ebf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -96,7 +96,7 @@ class UsersController < ApplicationController @user.ign = user_profile["name"] # correct case if validate_token(@user.uuid, @user.email, params[:registration_token]) - destroy_token(@user.email) # tokens can be used to reset password + destroy_token(params[:email]) @user.last_ip = request.remote_ip # showing in mail if @user.save session[:user_id] = @user.id @@ -125,12 +125,13 @@ class UsersController < ApplicationController end @user.email_token = SecureRandom.hex(16) else + destroy_token(params[:email]) flash[:alert] = "Token invalid for this username/email. Please generate a new token!" - destroy_token(@user.email) # no chance to brute force render action: "new" end else - flash[:alert] = "Error. Your username is not correct or Mojang's servers are down." + destroy_token(params[:email]) + flash[:alert] = "Username is not correct or Mojang's servers are down. Please generate a new token!" render action: "new" return end @@ -273,22 +274,29 @@ class UsersController < ApplicationController end def reset_password - user = User.find_by_email(params[:email]) - if user && validate_token(user.uuid, user.email, params[:secret_token]) - destroy_token(user.email) # tokens can be used to reset password - user.password = params[:new_password] - user.password_confirmation = params[:new_password] - if user.save - flash[:notice] = "Password reset" - redirect_to login_path + if profile = User.new(ign: params[:ign]).get_profile + uuid = profile && profile["id"] + user = uuid && User.find_by(email: params[:email], uuid: uuid) + if user && validate_token(user.uuid, user.email, params[:secret_token]) + destroy_token(params[:email]) + user.password = params[:new_password] + user.password_confirmation = params[:new_password] + if user.save + flash[:notice] = "Password has been reset" + redirect_to login_path + return + else + flash[:alert] = "Failed to update password. Please generate a new token!" + end else - flash[:alert] = "Failed to update password, please generate a new Token!" - render action: "lost_password" + destroy_token(params[:email]) + flash[:alert] = "Token or Email address invalid. Please generate a new token!" end else - flash[:alert] = "Token or Email address invalid!" - render action: "lost_password" + destroy_token(params[:email]) + flash[:alert] = "Username is not correct or Mojang's servers are down. Please generate a new token!" end + render action: "lost_password" end def suggestions @@ -312,9 +320,10 @@ class UsersController < ApplicationController user_token && user_token.token == token end + # delete tokens that have been queried, regardless of matching token + # prevents brute forcing def destroy_token(email) - user_token = RegisterToken.where(email: email).first - user_token && user_token.destroy + RegisterToken.where(email: email).destroy_all end def set_user diff --git a/app/views/users/lost_password.html.erb b/app/views/users/lost_password.html.erb index 9be7bf3..85d4140 100644 --- a/app/views/users/lost_password.html.erb +++ b/app/views/users/lost_password.html.erb @@ -5,6 +5,10 @@

Luckily for you, you can reset your password. Please use the command /gettoken <your email address>, then fill in the form below:

<%= form_tag reset_password_users_path do |f| %> + + + + -- 2.52.0 From bd061d344169c200a799b25b3c7cb6d50787a31e Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 8 May 2016 19:30:52 +0200 Subject: [PATCH 032/214] fix thread & reply navigator links --- app/views/forumthreads/edit.html.erb | 2 +- app/views/forumthreads/new.html.erb | 2 +- app/views/threadreplies/edit.html.erb | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/views/forumthreads/edit.html.erb b/app/views/forumthreads/edit.html.erb index cab2dd8..5297249 100644 --- a/app/views/forumthreads/edit.html.erb +++ b/app/views/forumthreads/edit.html.erb @@ -12,7 +12,7 @@ %>

Edit thread

-<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → New thread +<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → <%= link_to @thread, @thread %> → Edit thread <%= form_for @thread do |f|%>
<%= label_tag :ign, "Minecraft name" %><%= text_field_tag :ign, nil, placeholder: "Steve", pattern: "[a-zA-Z0-9_]{2,16}", required: true, title: "Your IGN" %>
<%= label_tag :email %> <%= text_field_tag :email, nil, placeholder: "steve@example.com", required: true, pattern: ".+@.+", title: "enter valid email address", "x-moz-errormessage" => "enter valid email address" %>
<% if mod? %> diff --git a/app/views/forumthreads/new.html.erb b/app/views/forumthreads/new.html.erb index 021e907..2e1d7e0 100644 --- a/app/views/forumthreads/new.html.erb +++ b/app/views/forumthreads/new.html.erb @@ -7,7 +7,7 @@ end %> -<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → New thread +<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → New thread

New thread

<%= form_for @thread do |f|%>
diff --git a/app/views/threadreplies/edit.html.erb b/app/views/threadreplies/edit.html.erb index d3218cd..c009cb0 100644 --- a/app/views/threadreplies/edit.html.erb +++ b/app/views/threadreplies/edit.html.erb @@ -1,6 +1,11 @@ <% title "Edit Thread Reply: #{@reply.thread.title}" %> -<%= link_to @reply.thread.forum.group, forumgroup_path(@reply.thread.forum.group) %> → <%= link_to @reply.thread.forum, @reply.thread.forum %> → <%= link_to @reply.thread, @reply.thread %> → Edit reply +<% + position = @reply.thread.replies.index(@reply) + page = position / Kaminari.config.default_per_page + 1 +%> + +<%= link_to @reply.thread.forum.group, forumgroup_path(@reply.thread.forum.group) %> → <%= link_to @reply.thread.forum, @reply.thread.forum %> → <%= link_to @reply.thread, forumthread_path(@reply.thread, page: page) + "#reply-#{@reply.id}" %> → Edit reply

Edit reply

<%= form_for [@reply.thread, @reply] do |f| %> <%= render partial: "md_editor", locals: {name: "threadreply[content]", content: @reply.content} %> -- 2.52.0 From f633b49eca7e7cc54897370fbb61b5379307cd6c Mon Sep 17 00:00:00 2001 From: jomo Date: Thu, 19 May 2016 20:15:07 +0200 Subject: [PATCH 033/214] fix potential XSS --- app/views/layouts/application.html.erb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 34dd727..a0a5f83 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -15,8 +15,12 @@ <%= render partial: "/layouts/head" %>
- <%= "
#{alert}
".html_safe if alert %> - <%= "
#{notice}
".html_safe if notice %> + <% if alert %> +
<%= alert %>
+ <% end %> + <% if notice %> +
<%= notice %>
+ <% end %> <%= yield %>
<%= render partial: "/layouts/footer" %> -- 2.52.0 From 8beb2d39db57661ff156cdb2981588fa962065c2 Mon Sep 17 00:00:00 2001 From: jomo Date: Thu, 19 May 2016 20:23:34 +0200 Subject: [PATCH 034/214] remove a few unnecessary html_safe --- app/views/layouts/_head.html.erb | 2 +- app/views/users/show.html.erb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb index 44e5d67..183a615 100644 --- a/app/views/layouts/_head.html.erb +++ b/app/views/layouts/_head.html.erb @@ -29,7 +29,7 @@
-
> +
"> <% if current_user %> <%= link_to current_user.name, current_user %>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index ab867e4..56ece88 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -102,5 +102,9 @@
About:
- <%= @user.about.blank? ? "nothing".html_safe : render_md(@user.about).html_safe %> + <% if @user.about.blank? %> + nothing + <% else %> + <%= render_md(@user.about).html_safe %> + <% end %> \ No newline at end of file -- 2.52.0 From 44839b08ae1ad1f5c2e837c5d6130496da287cce Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 12 Jun 2016 00:44:39 +0200 Subject: [PATCH 035/214] fix syntax error when deleting invalid role from POST params --- app/controllers/users_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ea56ebf..ae9424e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -147,11 +147,11 @@ class UsersController < ApplicationController end if userdata[:role] role = Role.get(userdata[:role]) - if role <= current_user.role + if role && role <= current_user.role userdata[:role] = role else # don't change role - userdata.delete[:role] + userdata.delete(:role) end end if @user.youtube != userdata[:youtube] -- 2.52.0 From c8e964c23f542811ce60866fb629ef77a65c3899 Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 12 Jun 2016 00:54:28 +0200 Subject: [PATCH 036/214] clarify write-only notice --- app/views/forums/show.html.erb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 0612dad..60f3185 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -6,7 +6,13 @@ <% end %> <% if @forum.role_read && @forum.role_write && @forum.role_write < @forum.role_read %> -
This forum is write-only. You can only see your own posts.
+
+ <% if @forum.role_read > current_user.role %> + This forum is write-only. You can only see your own posts. + <% else %> + This forum is write-only for users ranked under <%= @forum.role_read %>. They can only see their own posts. + <% end %> +
<% end %>
-- 2.52.0 From db1c10eb9b89900db2e1f1c48a8d76cf669ab277 Mon Sep 17 00:00:00 2001 From: Jonas Folvik Date: Sun, 12 Jun 2016 20:36:53 +0200 Subject: [PATCH 037/214] An Option to resend the confirmation mail You should now be able to resend the confirmation mail with the click of a link that is next to the warning that the mail isn't confirmed. Resend the confirmation mail cleaning Just a way to re use the files and stuff we already have instead of the file I created even though I could use the register_mail we have. Change of route and link to button I changed the route from GET to POST because of security reasons, and changed the link_to to a button_to changed the notice I changed the notice so it said check for the mail instead of check for the link Changed notice and button Changed the notice to say "Check your inbox" instead of "Check your mail" also changed the way the class looks --- app/controllers/users_controller.rb | 8 +++++++- app/mailers/redstoner_mailer.rb | 2 +- app/views/users/show.html.erb | 3 ++- config/routes.rb | 3 ++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ea56ebf..aec4c36 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -138,6 +138,12 @@ class UsersController < ApplicationController end end + def resend_mail + RedstonerMailer.register_mail(@user, false).deliver_now + flash[:notice] = "Check your inbox for the confirmation mail." + redirect_to users_path(@user) + end + def update if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?) if mod? @@ -344,4 +350,4 @@ class UsersController < ApplicationController a = [:ign, :email, :password, :password_confirmation, :mail_own_thread_reply, :mail_other_thread_reply, :mail_own_blogpost_comment, :mail_other_blogpost_comment, :mail_mention] + add params.require(:user).permit(a) end -end \ No newline at end of file +end diff --git a/app/mailers/redstoner_mailer.rb b/app/mailers/redstoner_mailer.rb index 38e9956..1b387f8 100644 --- a/app/mailers/redstoner_mailer.rb +++ b/app/mailers/redstoner_mailer.rb @@ -44,4 +44,4 @@ class RedstonerMailer < ActionMailer::Base @user = user mail(to: @user.email, subject: "Email change on Redstoner.com") end -end \ No newline at end of file +end diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 56ece88..eabe78e 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -23,6 +23,7 @@ <% if !@user.confirmed? %> <% if @user.is?(current_user) %> Please confirm your email <%= @user.email %> ! + <%= button_to "Resend the confirmation mail", resend_mail_user_path, class: "btn red" %> <% else %> This user hasn't confirmed their email yet! <% end %> @@ -107,4 +108,4 @@ <% else %> <%= render_md(@user.about).html_safe %> <% end %> -
\ No newline at end of file + diff --git a/config/routes.rb b/config/routes.rb index 1caa0ca..584c94f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,6 +18,7 @@ Redstoner::Application.routes.draw do member do get 'confirm' get 'edit_login' + post 'resend_mail' get 'edit_notifications' put 'update_login' end @@ -51,4 +52,4 @@ Redstoner::Application.routes.draw do get '/dmca' => redirect('https://www.youtube.com/watch?v=oHg5SJYRHA0') root to: 'statics#index' -end \ No newline at end of file +end -- 2.52.0 From eabf773ba39ea18c9bcb9a2eedf8617e2a12dadb Mon Sep 17 00:00:00 2001 From: jomo Date: Tue, 21 Jun 2016 23:26:56 +0200 Subject: [PATCH 038/214] fix resend button style --- app/assets/stylesheets/style.css.scss | 5 +++++ app/views/users/show.html.erb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/style.css.scss b/app/assets/stylesheets/style.css.scss index 6be17f0..83908c5 100644 --- a/app/assets/stylesheets/style.css.scss +++ b/app/assets/stylesheets/style.css.scss @@ -654,6 +654,7 @@ tr.spacer { font-weight: bold; padding: 4px 10px; display: inline-block; + vertical-align: middle; border-radius: 3px; margin: 10px 0; } @@ -939,6 +940,10 @@ img { color: #888; } +.inline-block { + display: inline-block; +} + #footer { padding: 30px 0; width: 1600px; diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index eabe78e..0a5431c 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -23,7 +23,7 @@ <% if !@user.confirmed? %> <% if @user.is?(current_user) %> Please confirm your email <%= @user.email %> ! - <%= button_to "Resend the confirmation mail", resend_mail_user_path, class: "btn red" %> + <%= button_to "Resend the confirmation mail", resend_mail_user_path, class: "btn dark", form_class: "inline-block", data: {confirm: "Did you check your spam folder?"} %> <% else %> This user hasn't confirmed their email yet! <% end %> -- 2.52.0 From 3f91e1a099346c9207914340ff8d0a8d5f08878e Mon Sep 17 00:00:00 2001 From: jomo Date: Tue, 21 Jun 2016 23:28:42 +0200 Subject: [PATCH 039/214] fix confirmation redirect --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ff21d8c..0755c03 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -141,7 +141,7 @@ class UsersController < ApplicationController def resend_mail RedstonerMailer.register_mail(@user, false).deliver_now flash[:notice] = "Check your inbox for the confirmation mail." - redirect_to users_path(@user) + redirect_to user_path(@user) end def update -- 2.52.0 From e0ac5fac131342874c4e9f814a5943f38a39fa91 Mon Sep 17 00:00:00 2001 From: jomo Date: Tue, 21 Jun 2016 23:35:41 +0200 Subject: [PATCH 040/214] don't allow other users or confirmed users to resend confirmation email --- app/controllers/users_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0755c03..bd511df 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -139,8 +139,12 @@ class UsersController < ApplicationController end def resend_mail - RedstonerMailer.register_mail(@user, false).deliver_now - flash[:notice] = "Check your inbox for the confirmation mail." + if @user.is?(current_user) && !confirmed? + RedstonerMailer.register_mail(@user, false).deliver_now + flash[:notice] = "Check your inbox for the confirmation mail." + else + flash[:alert] = "You're not allowed to resend this user's confirmation email" + end redirect_to user_path(@user) end -- 2.52.0 From 81d9fabe7bf2d8249402dea99871ea0a8897f746 Mon Sep 17 00:00:00 2001 From: jomo Date: Tue, 21 Jun 2016 23:41:04 +0200 Subject: [PATCH 041/214] allow mods to resend confirmation emails for other users --- app/controllers/users_controller.rb | 2 +- app/views/users/show.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bd511df..db46cd8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -139,7 +139,7 @@ class UsersController < ApplicationController end def resend_mail - if @user.is?(current_user) && !confirmed? + if (@user.is?(current_user) || mod) && !confirmed? RedstonerMailer.register_mail(@user, false).deliver_now flash[:notice] = "Check your inbox for the confirmation mail." else diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 0a5431c..e371a09 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -21,7 +21,7 @@ <% end %> <% if !@user.confirmed? %> - <% if @user.is?(current_user) %> + <% if @user.is?(current_user) || mod? %> Please confirm your email <%= @user.email %> ! <%= button_to "Resend the confirmation mail", resend_mail_user_path, class: "btn dark", form_class: "inline-block", data: {confirm: "Did you check your spam folder?"} %> <% else %> -- 2.52.0 From bb1d2c0c3e2ae1444145cf07cee1e2ef933f546c Mon Sep 17 00:00:00 2001 From: Jonas Folvik Date: Fri, 24 Jun 2016 13:47:28 +0200 Subject: [PATCH 042/214] resend mail bug fix We can now send the mail when you are mod and you also don't need to be unconfirmed yourself. a better fix this is just a better fix to my last commit --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index db46cd8..5dc0e80 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -139,7 +139,7 @@ class UsersController < ApplicationController end def resend_mail - if (@user.is?(current_user) || mod) && !confirmed? + if (@user.is?(current_user) || mod?) && !@user.confirmed? RedstonerMailer.register_mail(@user, false).deliver_now flash[:notice] = "Check your inbox for the confirmation mail." else -- 2.52.0 From d9ae4e7d3a3fbfd19d7d549692dc71b6e76060f7 Mon Sep 17 00:00:00 2001 From: jomo Date: Mon, 11 Jul 2016 21:06:12 +0200 Subject: [PATCH 043/214] restrict edit page access to users allowed to update --- app/controllers/forums_controller.rb | 4 ++++ app/controllers/forumthreads_controller.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 2841be9..ecf570e 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -16,6 +16,10 @@ class ForumsController < ApplicationController end def edit + unless admin? + flash[:alert] = "You are not allowed to change a forum" + redirect_to forums_path + end end def new diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index ac090f5..b9b5714 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -11,6 +11,10 @@ class ForumthreadsController < ApplicationController end def edit + unless mod? || @thread.author.is?(current_user) + flash[:alert] = "You are not allowed to edit this thread!" + redirect_to @thread + end end def new -- 2.52.0 From 072f38a373562e2f14a9ee4c0abcf09ae311b9f3 Mon Sep 17 00:00:00 2001 From: jomo Date: Tue, 19 Jul 2016 14:50:03 +0200 Subject: [PATCH 044/214] check mod+ rank when updating comment --- app/controllers/comments_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 49975cd..b69053e 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -33,7 +33,7 @@ class CommentsController < ApplicationController def update @comment = Comment.find(params[:id]) - if mod? || @comment.author.is?(current_user) + if (mod? && current_user.role >= @comment.author.role) || @comment.author.is?(current_user) @comment.user_editor = current_user @comment.attributes = comment_params old_content = @comment.content_was -- 2.52.0 From f6929da548880fa18ed14a9b6a24442ad680fa2e Mon Sep 17 00:00:00 2001 From: jomo Date: Tue, 19 Jul 2016 14:53:41 +0200 Subject: [PATCH 045/214] check mod+ rank when dealing with thread replies --- app/controllers/threadreplies_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/threadreplies_controller.rb b/app/controllers/threadreplies_controller.rb index 946155d..235f037 100644 --- a/app/controllers/threadreplies_controller.rb +++ b/app/controllers/threadreplies_controller.rb @@ -2,7 +2,7 @@ class ThreadrepliesController < ApplicationController def edit @reply = Threadreply.find(params[:id]) - if mod? || @reply.author.is?(current_user) + if (mod? && current_user.role >= @reply.author.role) || @reply.author.is?(current_user) else flash[:alert] = "You are not allowed to edit this reply" redirect_to @reply.thread @@ -32,7 +32,7 @@ class ThreadrepliesController < ApplicationController def update @reply = Threadreply.find(params[:id]) - if mod? || @reply.author.is?(current_user) + if (mod? && current_user.role >= @reply.author.role) || @reply.author.is?(current_user) old_content = @reply.content_was if @reply.update_attributes(reply_params) @reply.send_new_reply_mail(old_content) @@ -52,7 +52,7 @@ class ThreadrepliesController < ApplicationController def destroy @reply = Threadreply.find(params[:id]) - if mod? || @reply.author.is?(current_user) + if (mod? && current_user.role >= @reply.author.role) || @reply.author.is?(current_user) if @reply.destroy flash[:notice] = "Reply deleted!" else -- 2.52.0 From f2353eebcc22212f3fe5e817f1fdee4edb810805 Mon Sep 17 00:00:00 2001 From: jomo Date: Tue, 19 Jul 2016 14:56:00 +0200 Subject: [PATCH 046/214] check mod+ rank when dealing with forum threads --- app/controllers/forumthreads_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index b9b5714..f9d31a3 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -11,7 +11,7 @@ class ForumthreadsController < ApplicationController end def edit - unless mod? || @thread.author.is?(current_user) + unless (mod? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user) flash[:alert] = "You are not allowed to edit this thread!" redirect_to @thread end @@ -46,7 +46,7 @@ class ForumthreadsController < ApplicationController end def update - if mod? || @thread.author.is?(current_user) + if (mod? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user) @thread.user_editor = current_user @thread.attributes = (mod? ? thread_params([:sticky, :locked, :forum_id, :label_id]) : thread_params) old_content = @thread.content_was @@ -64,7 +64,7 @@ class ForumthreadsController < ApplicationController end def destroy - if mod? || @thread.author.is?(current_user) + if (mod? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user) if @thread.destroy flash[:notice] = "Thread deleted!" else -- 2.52.0 From 76076bbdf2c80279bcc9a34e31c960e9d58d7ed4 Mon Sep 17 00:00:00 2001 From: jomo Date: Tue, 19 Jul 2016 15:06:40 +0200 Subject: [PATCH 047/214] fix edit link permission checks for comments, threads, replies --- app/views/comments/_comment.html.erb | 2 +- app/views/forumthreads/show.html.erb | 2 +- app/views/threadreplies/_reply.html.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 286cf1b..147e85b 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -6,7 +6,7 @@ <%= ago c.created_at %> <% end %> - <%= link_to "edit", edit_blogpost_comment_path(c.blogpost, c), class: "editlink" if (mod? || c.author.is?(current_user)) %> + <%= link_to "edit", edit_blogpost_comment_path(c.blogpost, c), class: "editlink" if (mod? && current_user.role >= c.author.role) || c.author.is?(current_user) %>
diff --git a/app/views/forumthreads/show.html.erb b/app/views/forumthreads/show.html.erb index 10cfeb6..206ae09 100644 --- a/app/views/forumthreads/show.html.erb +++ b/app/views/forumthreads/show.html.erb @@ -8,7 +8,7 @@ <%= link_to p do %> <%= ago @thread.created_at %> <% end %> - <%= link_to "edit", edit_forumthread_path( @thread), class: "editlink" if (@thread.author.is?(current_user) || mod?) %> + <%= link_to "edit", edit_forumthread_path( @thread), class: "editlink" if (mod? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user) %>
diff --git a/app/views/threadreplies/_reply.html.erb b/app/views/threadreplies/_reply.html.erb index 88e4bfb..b3a344e 100644 --- a/app/views/threadreplies/_reply.html.erb +++ b/app/views/threadreplies/_reply.html.erb @@ -6,7 +6,7 @@ <%= ago reply.created_at %> <% end %> - <%= link_to "edit", edit_forumthread_threadreply_path(reply.thread, reply), class: "editlink" if mod? || reply.author.is?(current_user) %> + <%= link_to "edit", edit_forumthread_threadreply_path(reply.thread, reply), class: "editlink" if (mod? && current_user.role >= reply.author.role) || reply.author.is?(current_user) %>
-- 2.52.0 From c9e7015f4c675aa3f1320ab70836edd05d7a1208 Mon Sep 17 00:00:00 2001 From: jomo Date: Wed, 20 Jul 2016 14:21:41 +0200 Subject: [PATCH 048/214] update slack URL --- app/views/layouts/_footer.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index c4c81d0..930eb26 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -15,8 +15,8 @@ Twitter <%= image_tag("twitter.png") %> <% end %> <% if current_user %> - | <%= link_to "http://slack.redstoner.com/?" + {mail: current_user.try(:email)}.to_param do %> - Join us on Slack + | <%= link_to "/slack/?" + {mail: current_user.try(:email)}.to_param do %> + Join us on Slack <% end %> <% end %>
-- 2.52.0 From b057cb591344828ceead2d8b156832d332a9991d Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 24 Jul 2016 22:30:00 +0200 Subject: [PATCH 049/214] remove annoying permission check for comments, forums, threads, replies --- app/controllers/comments_controller.rb | 6 +++--- app/controllers/forumthreads_controller.rb | 6 +++--- app/controllers/threadreplies_controller.rb | 6 +++--- app/views/comments/_comment.html.erb | 2 +- app/views/forumthreads/show.html.erb | 2 +- app/views/threadreplies/_reply.html.erb | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index b69053e..3c2f57d 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -4,7 +4,7 @@ class CommentsController < ApplicationController def edit @comment = Comment.find(params[:id]) - if (mod? && current_user.role >= @comment.author.role) || @comment.author.is?(current_user) + if mod? || @comment.author.is?(current_user) else flash[:alert] = "You are not allowed to edit this comment" redirect_to @comment.blogpost @@ -33,7 +33,7 @@ class CommentsController < ApplicationController def update @comment = Comment.find(params[:id]) - if (mod? && current_user.role >= @comment.author.role) || @comment.author.is?(current_user) + if mod? || @comment.author.is?(current_user) @comment.user_editor = current_user @comment.attributes = comment_params old_content = @comment.content_was @@ -55,7 +55,7 @@ class CommentsController < ApplicationController def destroy @comment = Comment.find(params[:id]) - if (mod? && current_user.role >= @comment.author.role) || @comment.author.is?(current_user) + if mod? || @comment.author.is?(current_user) if @comment.destroy flash[:notice] = "Comment deleted!" else diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index f9d31a3..b9b5714 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -11,7 +11,7 @@ class ForumthreadsController < ApplicationController end def edit - unless (mod? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user) + unless mod? || @thread.author.is?(current_user) flash[:alert] = "You are not allowed to edit this thread!" redirect_to @thread end @@ -46,7 +46,7 @@ class ForumthreadsController < ApplicationController end def update - if (mod? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user) + if mod? || @thread.author.is?(current_user) @thread.user_editor = current_user @thread.attributes = (mod? ? thread_params([:sticky, :locked, :forum_id, :label_id]) : thread_params) old_content = @thread.content_was @@ -64,7 +64,7 @@ class ForumthreadsController < ApplicationController end def destroy - if (mod? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user) + if mod? || @thread.author.is?(current_user) if @thread.destroy flash[:notice] = "Thread deleted!" else diff --git a/app/controllers/threadreplies_controller.rb b/app/controllers/threadreplies_controller.rb index 235f037..946155d 100644 --- a/app/controllers/threadreplies_controller.rb +++ b/app/controllers/threadreplies_controller.rb @@ -2,7 +2,7 @@ class ThreadrepliesController < ApplicationController def edit @reply = Threadreply.find(params[:id]) - if (mod? && current_user.role >= @reply.author.role) || @reply.author.is?(current_user) + if mod? || @reply.author.is?(current_user) else flash[:alert] = "You are not allowed to edit this reply" redirect_to @reply.thread @@ -32,7 +32,7 @@ class ThreadrepliesController < ApplicationController def update @reply = Threadreply.find(params[:id]) - if (mod? && current_user.role >= @reply.author.role) || @reply.author.is?(current_user) + if mod? || @reply.author.is?(current_user) old_content = @reply.content_was if @reply.update_attributes(reply_params) @reply.send_new_reply_mail(old_content) @@ -52,7 +52,7 @@ class ThreadrepliesController < ApplicationController def destroy @reply = Threadreply.find(params[:id]) - if (mod? && current_user.role >= @reply.author.role) || @reply.author.is?(current_user) + if mod? || @reply.author.is?(current_user) if @reply.destroy flash[:notice] = "Reply deleted!" else diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 147e85b..b5a05e5 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -6,7 +6,7 @@ <%= ago c.created_at %> <% end %> - <%= link_to "edit", edit_blogpost_comment_path(c.blogpost, c), class: "editlink" if (mod? && current_user.role >= c.author.role) || c.author.is?(current_user) %> + <%= link_to "edit", edit_blogpost_comment_path(c.blogpost, c), class: "editlink" if mod? || c.author.is?(current_user) %>
diff --git a/app/views/forumthreads/show.html.erb b/app/views/forumthreads/show.html.erb index 206ae09..876d55d 100644 --- a/app/views/forumthreads/show.html.erb +++ b/app/views/forumthreads/show.html.erb @@ -8,7 +8,7 @@ <%= link_to p do %> <%= ago @thread.created_at %> <% end %> - <%= link_to "edit", edit_forumthread_path( @thread), class: "editlink" if (mod? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user) %> + <%= link_to "edit", edit_forumthread_path( @thread), class: "editlink" if mod? || @thread.author.is?(current_user) %>
diff --git a/app/views/threadreplies/_reply.html.erb b/app/views/threadreplies/_reply.html.erb index b3a344e..88e4bfb 100644 --- a/app/views/threadreplies/_reply.html.erb +++ b/app/views/threadreplies/_reply.html.erb @@ -6,7 +6,7 @@ <%= ago reply.created_at %> <% end %> - <%= link_to "edit", edit_forumthread_threadreply_path(reply.thread, reply), class: "editlink" if (mod? && current_user.role >= reply.author.role) || reply.author.is?(current_user) %> + <%= link_to "edit", edit_forumthread_threadreply_path(reply.thread, reply), class: "editlink" if mod? || reply.author.is?(current_user) %>
-- 2.52.0 From cce749deef267b464c4cb8886d39bfa2d4001fbf Mon Sep 17 00:00:00 2001 From: jomo Date: Tue, 27 Sep 2016 00:15:01 +0200 Subject: [PATCH 050/214] remove index 'email' from register_tokens only records with the same UUID are deleted before INSERTing new ones meaning a player could prevent another one from using a certain address when emails are unique. There's no good reason to force uniqueness on emails in this table --- ...20160926220738_remove_index_email_from_register_tokens.rb | 5 +++++ db/schema.rb | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20160926220738_remove_index_email_from_register_tokens.rb diff --git a/db/migrate/20160926220738_remove_index_email_from_register_tokens.rb b/db/migrate/20160926220738_remove_index_email_from_register_tokens.rb new file mode 100644 index 0000000..fc6a355 --- /dev/null +++ b/db/migrate/20160926220738_remove_index_email_from_register_tokens.rb @@ -0,0 +1,5 @@ +class RemoveIndexEmailFromRegisterTokens < ActiveRecord::Migration + def change + remove_index :register_tokens, :email + end +end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index 376e758..2c68029 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150825232749) do +ActiveRecord::Schema.define(version: 20160926220738) do create_table "blogposts", force: :cascade do |t| t.string "title" @@ -82,7 +82,6 @@ ActiveRecord::Schema.define(version: 20150825232749) do t.string "email", null: false end - add_index "register_tokens", ["email"], name: "index_register_tokens_on_email", unique: true, using: :btree add_index "register_tokens", ["uuid"], name: "index_register_tokens_on_uuid", unique: true, using: :btree create_table "roles", force: :cascade do |t| -- 2.52.0 From 00fc8b3fcd10860abb70a57fb6aaab3c476259f2 Mon Sep 17 00:00:00 2001 From: Jonas Folvik Date: Mon, 3 Oct 2016 22:58:27 +0200 Subject: [PATCH 051/214] Changed the content length of forumthreads to 20k because Nemes --- app/models/forumthread.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/forumthread.rb b/app/models/forumthread.rb index 892ef15..905e4d3 100644 --- a/app/models/forumthread.rb +++ b/app/models/forumthread.rb @@ -11,7 +11,7 @@ class Forumthread < ActiveRecord::Base validates_presence_of :title, :author, :forum validates_presence_of :content - validates_length_of :content, in: 5..10000 + validates_length_of :content, in: 5..20000 accepts_nested_attributes_for :threadreplies @@ -65,4 +65,4 @@ class Forumthread < ActiveRecord::Base def to_param [id, to_s.parameterize].join("-") end -end \ No newline at end of file +end -- 2.52.0 From 5ba478339354bdb5b1c61bf258e505d8d331311e Mon Sep 17 00:00:00 2001 From: jomo Date: Fri, 14 Oct 2016 13:26:24 +0200 Subject: [PATCH 052/214] adjust max size of thread reply to that of threads, see #11 --- app/models/threadreply.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/threadreply.rb b/app/models/threadreply.rb index 0f2faca..47b0d97 100644 --- a/app/models/threadreply.rb +++ b/app/models/threadreply.rb @@ -10,7 +10,7 @@ class Threadreply < ActiveRecord::Base validates_presence_of :content - validates_length_of :content, in: 2..10000 + validates_length_of :content, in: 2..20000 def thread forumthread -- 2.52.0 From 381e6e8b5be7c9e9035ca360d04d8beac7fc9a1a Mon Sep 17 00:00:00 2001 From: jomo Date: Sat, 19 Nov 2016 21:15:03 +0100 Subject: [PATCH 053/214] ensure donor tag color is always white --- app/assets/stylesheets/style.css.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/style.css.scss b/app/assets/stylesheets/style.css.scss index 83908c5..6de5aa2 100644 --- a/app/assets/stylesheets/style.css.scss +++ b/app/assets/stylesheets/style.css.scss @@ -439,6 +439,7 @@ blockquote p { } .donor { + color: #fff; background: #f60 !important; margin-left: 2px !important; } -- 2.52.0 From abeb405bab21bcd216fd9f9b894cd23fbc53a06b Mon Sep 17 00:00:00 2001 From: jomo Date: Wed, 14 Dec 2016 23:57:08 +0100 Subject: [PATCH 054/214] rescue and fail gracefully when updated user can't be saved saving the user can fail when the new ign or name are already assigned to a different user. it's not worth implementing automatic correction because there can be multiple or even circular 'dependencies' of unique names that need to be changed --- app/controllers/sessions_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index b58028a..784647c 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -29,8 +29,11 @@ class SessionsController < ApplicationController if new_ign.present? && new_ign != user.ign user.name = new_ign if user.ign == user.name user.ign = new_ign - user.save - flash[:notice] += " Your name has been changed to #{new_ign}!" + if (user.save rescue false) + flash[:notice] += " Your name has been changed to #{new_ign}!" + else + flash[:alert] = "Failed to save your new username #{new_ign}! Please contact admins." + end end flash[:alert] = "Remember to validate your email! Your account may be deleted soon!" if !user.confirmed? -- 2.52.0 From 61edf2788833e9cc1acd5e697e31c31ed3962bdb Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 8 Jan 2017 08:06:37 +0100 Subject: [PATCH 055/214] add CookieJar patch to flag cookies as secure based on the connection protocol rails only allows to globally flag session cookies as either secure or not this patch sets the secure flag for cookies based on the protocol (http/https) this is used to send cookies via http but flag them secure for https which allows use with HTTP over Tor for an onion domain this is acceptable because nginx redirects clearnet http to https --- config/initializers/auto_secure_cookies.rb | 17 +++++++++++++++++ config/initializers/session_store.rb | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 config/initializers/auto_secure_cookies.rb diff --git a/config/initializers/auto_secure_cookies.rb b/config/initializers/auto_secure_cookies.rb new file mode 100644 index 0000000..004795f --- /dev/null +++ b/config/initializers/auto_secure_cookies.rb @@ -0,0 +1,17 @@ +# rails only allows to globally flag session cookies as either secure or not +# this patch sets the secure flag for cookies based on the protocol (@secure) +# this is used to send cookies via http but flag them secure for https +# which allows use with HTTP over Tor for an onion domain +# this is acceptable because nginx redirects clearnet http to https + +module ActionDispatch + class Cookies + class CookieJar + private + def write_cookie?(cookie) + cookie[:secure] = @secure + true + end + end + end +end \ No newline at end of file diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index d2c5fb0..b9c9633 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -6,4 +6,4 @@ Redstoner::Application.config.session_store :active_record_store, key: 'redstoner_session', expire_after: 5.days, - secure: Rails.env.production? \ No newline at end of file + secure: nil # see config/initializers/auto_secure_cookies.rb \ No newline at end of file -- 2.52.0 From 992406a20b90d47d1ef8a9b4f8d0c599590a1171 Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 8 Jan 2017 08:55:31 +0100 Subject: [PATCH 056/214] allow markdown emphasis inside of words --- app/helpers/application_helper.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a147945..1419391 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -28,7 +28,6 @@ module ApplicationHelper link_attributes: {rel: "nofollow"} }) md = Redcarpet::Markdown.new(renderer, { - no_intra_emphasis: true, tables: true, fenced_code_blocks: true, autolink: true, @@ -53,7 +52,6 @@ module ApplicationHelper hard_wrap: true, }) md = Redcarpet::Markdown.new(renderer, { - no_intra_emphasis: true, tables: true, fenced_code_blocks: true, autolink: true, -- 2.52.0 From 1b4a270038cb5055be79269fff07fab92a6c5d92 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 28 May 2017 17:39:06 -0400 Subject: [PATCH 057/214] Added badge system --- app/assets/stylesheets/style.css.scss | 12 ++-- app/controllers/users_controller.rb | 17 ++++-- app/models/badge.rb | 18 ++++++ app/models/user.rb | 3 +- app/views/statics/donate.html.erb | 4 +- app/views/users/_username.html.erb | 4 +- app/views/users/edit.html.erb | 12 ++-- app/views/users/index.html.erb | 10 +++- .../20170319193517_add_badge_id_to_users.rb | 8 +++ db/schema.rb | 10 +++- db/seeds.rb | 55 ++++++++++++++++++- 11 files changed, 124 insertions(+), 29 deletions(-) create mode 100644 app/models/badge.rb create mode 100644 db/migrate/20170319193517_add_badge_id_to_users.rb diff --git a/app/assets/stylesheets/style.css.scss b/app/assets/stylesheets/style.css.scss index 6de5aa2..da15801 100644 --- a/app/assets/stylesheets/style.css.scss +++ b/app/assets/stylesheets/style.css.scss @@ -437,18 +437,14 @@ blockquote p { color: #ddd !important; } } - - .donor { - color: #fff; - background: #f60 !important; - margin-left: 2px !important; - } - .ign { display: block; color: #000; font-style: italic; } + .badge { + margin-left: 2px !important; + } } #online-users { @@ -1026,4 +1022,4 @@ nav.pagination { padding: 0.1em 0.2em; border-radius: 0.2em; text-shadow: none; -} \ No newline at end of file +} diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5dc0e80..27e89af 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -10,8 +10,6 @@ class UsersController < ApplicationController if params[:role] if params[:role].downcase == "staff" @users = User.joins(:role).where("roles.value >= ?", Role.get(:mod).to_i) - elsif params[:role].downcase == "donor" - @users = User.joins(:role).where(donor: true) else if role = Role.get(params[:role]) @users = User.joins(:role).where(role: role) @@ -21,10 +19,18 @@ class UsersController < ApplicationController return end end + elsif params[:badge] + if badge = Badge.get(params[:badge]) + @users = User.joins(:badge).where(badge: badge) + else + flash[:alert] = "badge '#{params[:badge]}' does not exist!" + redirect_to users_path + return + end else @users = User.joins(:role).where.not(id: User.first.id) #Remove first user end - @users = @users.order("roles.value desc", "confirmed desc", :name) + @users = @users.order("roles.value desc", "confirmed desc", :name) unless params[:badge] @count = @users.size @users = @users.page(params[:page]).per(100) end @@ -151,7 +157,7 @@ class UsersController < ApplicationController def update if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?) 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, :badge, :confirmed]) else userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about]) end @@ -164,6 +170,9 @@ class UsersController < ApplicationController userdata.delete(:role) end end + if userdata[:badge] + userdata[:badge] = Badge.get(userdata[:badge]) + end if @user.youtube != userdata[:youtube] youtube = get_youtube(userdata[:youtube]) userdata[:youtube] = youtube[:channel] diff --git a/app/models/badge.rb b/app/models/badge.rb new file mode 100644 index 0000000..a7ff831 --- /dev/null +++ b/app/models/badge.rb @@ -0,0 +1,18 @@ +class Badge < ActiveRecord::Base + include Comparable + has_many :users + + def self.get (input) + if input.is_a?(String) || input.is_a?(Symbol) + Badge.find_by_name(input) + elsif input.is_a?(Fixnum) + Badge.find_by_id(input) + elsif input.is_a?(Badge) + return input + end + end + + def to_s + self.name + end +end diff --git a/app/models/user.rb b/app/models/user.rb index c422e28..ab7471e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,6 +5,7 @@ class User < ActiveRecord::Base strip_attributes belongs_to :role + belongs_to :badge has_secure_password @@ -173,4 +174,4 @@ class User < ActiveRecord::Base def set_email_token self.email_token ||= SecureRandom.hex(16) end -end \ No newline at end of file +end diff --git a/app/views/statics/donate.html.erb b/app/views/statics/donate.html.erb index 2831807..774d917 100644 --- a/app/views/statics/donate.html.erb +++ b/app/views/statics/donate.html.erb @@ -11,7 +11,7 @@
  • Donator+ ($20 or more) -

    We also have <%= link_to "list of users who donated", users_path(role: "donor") %> already!

    +

    We also have <%= link_to "list of users who donated", users_path(badge: "donor") %> already!

    Perks for you

    For Donator and Donator+

    @@ -45,4 +45,4 @@

  • -

    Please note that you are not buying anything. We do not guarantee for these perks, however, we will try hard to make sure you'll get them! Donations are processed manually, it can take a few hours.

    \ No newline at end of file +

    Please note that you are not buying anything. We do not guarantee for these perks, however, we will try hard to make sure you'll get them! Donations are processed manually, it can take a few hours.

    diff --git a/app/views/users/_username.html.erb b/app/views/users/_username.html.erb index 10adb36..4e78673 100644 --- a/app/views/users/_username.html.erb +++ b/app/views/users/_username.html.erb @@ -1,4 +1,4 @@
    <%= link_to user.name, user, class: "role #{user.role.name} #{"banned" if user.banned?} #{"disabled" if user.disabled?} #{"unconfirmed" unless user.confirmed?}", title: "#{user.ign} – #{user.role}", style: "color: #{fcolor(user.role.color)}; background-color: #{user.role.color}" %> - <%= link_to "$", donate_statics_path, class: "role donor", title: "Donator" if user.donor? %> -
    \ No newline at end of file + <%= link_to user.badge.symbol, users_path(badge: user.badge.name), class: "role badge", title: user.badge.name, style: "color: #{fcolor(user.badge.color)}; background-color: #{user.badge.color}" unless user.badge.value == 0 %> + diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 6a6fe4d..5e63c00 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -28,15 +28,17 @@ - Confirmed email address + Badge - <%= f.select :confirmed, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> + <% if current_user.role >= Role.get(:mod) %> + <%= f.select :badge, Badge.all %> + <% end %> - Donator + Confirmed email address - <%= f.select :donor, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> + <%= f.select :confirmed, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> <% end %> @@ -87,4 +89,4 @@ This user has not confirmed his email! <% end %> <% end %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 883ffb0..95ab480 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,12 +1,16 @@

    - <% if params[:role] %> + <% if params[:role] && !params[:badge]%> <%= title "All '#{params[:role]}' users" %> + <% elsif params[:badge] && !params[:role] %> + <%= title "All '#{params[:badge]}' users" %> + <% elsif params[:role] && params[:badge] %> + <%= title "All '#{params[:role]}' and '#{params[:badge]}' users" %> <% else %> <%= title "All Users" %> <% end %> (<%= @count %>)

    -<%= link_to "show all", users_path if params[:role] %> +<%= link_to "show all", users_path if params[:role] || params[:badge] %>
    <% @users.each do |u| %> @@ -19,4 +23,4 @@
    <% end %> <%= paginate @users %> - \ No newline at end of file + diff --git a/db/migrate/20170319193517_add_badge_id_to_users.rb b/db/migrate/20170319193517_add_badge_id_to_users.rb new file mode 100644 index 0000000..08328cf --- /dev/null +++ b/db/migrate/20170319193517_add_badge_id_to_users.rb @@ -0,0 +1,8 @@ +class AddBadgeIdToUsers < ActiveRecord::Migration + def change + add_column :users, :badge_id, :integer + add_column :users, :badge_id, :integer, default: 0 + User.where(donor: true).update_all(badge_id: 1) + remove_column :users, :donor + end +end diff --git a/db/schema.rb b/db/schema.rb index 2c68029..b38ae38 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160926220738) do +ActiveRecord::Schema.define(version: 20170319193517) do create_table "blogposts", force: :cascade do |t| t.string "title" @@ -90,6 +90,12 @@ ActiveRecord::Schema.define(version: 20160926220738) do t.string "color" end + create_table "badges", force: :cascade do |t| + t.string "name" + t.string "symbol" + t.string "color" + end + create_table "sessions", force: :cascade do |t| t.string "session_id", null: false t.text "data", limit: 65535 @@ -122,7 +128,6 @@ ActiveRecord::Schema.define(version: 20160926220738) do t.string "youtube" t.string "youtube_channelname" t.string "twitter" - t.boolean "donor", default: false t.string "email_token" t.boolean "confirmed", default: false t.datetime "last_seen" @@ -134,6 +139,7 @@ ActiveRecord::Schema.define(version: 20160926220738) do t.boolean "mail_own_blogpost_comment", default: true t.boolean "mail_other_blogpost_comment", default: true t.boolean "mail_mention", default: true + t.integer "badge_id" end add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree diff --git a/db/seeds.rb b/db/seeds.rb index 780ddb5..06c8d10 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -10,6 +10,14 @@ Role.create!([ {name: "superadmin", value: 500, color: "#d22"} ]) +Badge.create!([ + {name: "none", symbol: "", color: "#000"}, + {name: "donor", symbol: "$", color: "#f60"}, + {name: "developer", symbol: "D", color: "#a0a"}, + {name: "retired", symbol: "R", color: "#0aa"}, + {name: "lead", symbol: "L", color: "#a00"} +]) + userpw = SecureRandom.hex(36) @@ -23,6 +31,7 @@ deleted_user = User.create!( password: userpw, password_confirmation: userpw, role: Role.get(:disabled), + badge: Badge.get(:none), skype: "echo123", skype_public: true, last_ip: "0.0.0.0", @@ -37,5 +46,47 @@ User.create!( email: "jomo@example.com", password: "123456789", # high seructity! password_confirmation: "123456789", - role: Role.get(:superadmin) -) \ No newline at end of file + role: Role.get(:superadmin), + badge: Badge.get(:donor), + confirmed: true +) +User.create!( + uuid: "7f52491ab5d64c11b4a43806db47a101", + ign: "YummyRedstone", + email: "yummy@example.com", + password: "123456789", # high seructity! + password_confirmation: "123456789", + role: Role.get(:admin), + badge: Badge.get(:lead), + confirmed: true +) +User.create!( + uuid: "d2693e9193e14e3f929ff38e1ce8df03", + ign: "Pepich1851", + email: "pepe@example.com", + password: "123456789", # high seructity! + password_confirmation: "123456789", + role: Role.get(:superadmin), + badge: Badge.get(:retired), + confirmed: true +) +User.create!( + uuid: "c69f8316c60a4f8ca922bda933e01acd", + ign: "Doomblah", + email: "doom@example.com", + password: "123456789", # high seructity! + password_confirmation: "123456789", + role: Role.get(:normal), + badge: Badge.get(:developer), + confirmed: true +) +User.create!( + uuid: "b85a91b558b0474da2a42d5dd025f9e5", + ign: "Futsy", + email: "futsy@example.com", + password: "123456789", # high seructity! + password_confirmation: "123456789", + role: Role.get(:mod), + badge: Badge.get(:none), + confirmed: true +) -- 2.52.0 From 2c02a797b816f09460b5b3e49fb3466461ca6f6c Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 28 May 2017 17:40:50 -0400 Subject: [PATCH 058/214] Added Necropost Warning --- app/controllers/forumgroups_controller.rb | 2 +- app/controllers/forums_controller.rb | 4 +- app/views/forums/edit.html.erb | 6 ++- app/views/forums/new.html.erb | 6 ++- app/views/threadreplies/_new.html.erb | 17 +++++++- ...170409135858_add_necro_length_to_forums.rb | 5 +++ db/schema.rb | 43 ++++++++++--------- 7 files changed, 55 insertions(+), 28 deletions(-) create mode 100644 db/migrate/20170409135858_add_necro_length_to_forums.rb diff --git a/app/controllers/forumgroups_controller.rb b/app/controllers/forumgroups_controller.rb index a7b31ab..fe359af 100644 --- a/app/controllers/forumgroups_controller.rb +++ b/app/controllers/forumgroups_controller.rb @@ -77,4 +77,4 @@ class ForumgroupsController < ApplicationController params.require(:forumgroup).permit(a) end -end \ No newline at end of file +end diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index ecf570e..486d21c 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -89,7 +89,7 @@ class ForumsController < ApplicationController end def forum_params(add = []) - a = [:name, :position, :role_read_id, :role_write_id] + add + a = [:name, :position, :role_read_id, :role_write_id, :necro_length] + add params.require(:forum).permit(a) end -end \ No newline at end of file +end diff --git a/app/views/forums/edit.html.erb b/app/views/forums/edit.html.erb index 60b3fb1..571b3b7 100644 --- a/app/views/forums/edit.html.erb +++ b/app/views/forums/edit.html.erb @@ -21,8 +21,12 @@ <%= f.label :role_write_id, "Min. write role" %> <%= f.select :role_write_id, role_selection, include_blank: false %> + + <%= f.label :necro_length, "Necropost warning delay (in days)" %> + <%= f.number_field :necro_length, placeholder: "Warning Delay (leave blank for no warning)" %> +

    <%= f.submit "Update forum", class: "btn blue left" %>

    <% end %>

    <%= button_to "Delete forum", @forum, method: "delete", data: {confirm: "Delete forum forever?\nThreads won't be accessible!"}, class: "btn red right" %>

    -
    \ No newline at end of file +
    diff --git a/app/views/forums/new.html.erb b/app/views/forums/new.html.erb index f60e2b3..836a9b2 100644 --- a/app/views/forums/new.html.erb +++ b/app/views/forums/new.html.erb @@ -21,8 +21,12 @@ <%= f.label :role_write_id, "Min. write role" %> <%= f.select :role_write_id, role_selection, include_blank: false %> + + <%= f.label :necro_length, "Necropost warning delay (in days)" %> + <%= f.number_field :necro_length, placeholder: "Warning Delay (leave blank for no warning)" %> + <%= f.hidden_field :forumgroup_id %>

    <%= f.submit "Create forum", class: "btn blue left" %>

    -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/threadreplies/_new.html.erb b/app/views/threadreplies/_new.html.erb index b0c4b5e..9d716d8 100644 --- a/app/views/threadreplies/_new.html.erb +++ b/app/views/threadreplies/_new.html.erb @@ -1,4 +1,17 @@ <%= form_for [reply.thread, reply] do |f| %> <%= render partial: "md_editor", locals: {name: "threadreply[content]", content: reply.content} %> -

    <%= f.submit "Reply#{ ' (Locked)' if reply.thread.locked? }", class: "btn blue" %>

    -<% end %> \ No newline at end of file + <% nec_msg = "" %> + <% forum = Forum.find(reply.thread.forum_id) %> + <% if forum.necro_length != nil %> + <% if Threadreply.where(forumthread: reply.thread).count != 0 %> + <% prevAgo = Threadreply.where(forumthread: reply.thread).order(:id).last.created_at %> + <% if prevAgo <= forum.necro_length.days.ago.utc %> + <% nec_msg = "You may be necroposting, as the last reply was made at least #{forum.necro_length} days ago. If you still wish to make this reply, press 'Ok'." %> + <% end %> + <% elsif reply.thread.created_at <= forum.necro_length.days.ago.utc %> + <% nec_msg = "You may be necroposting, as this thread was posted at least #{forum.necro_length} days ago. If you still wish to make this reply, press 'Ok'." %> + <% end %> + <% end %> +

    <%= f.submit "Reply#{ ' (Locked)' if reply.thread.locked? }", class: "btn blue", data: { confirm: nec_msg } %>

    + <% nec_msg = "" %> +<% end %> diff --git a/db/migrate/20170409135858_add_necro_length_to_forums.rb b/db/migrate/20170409135858_add_necro_length_to_forums.rb new file mode 100644 index 0000000..53199e4 --- /dev/null +++ b/db/migrate/20170409135858_add_necro_length_to_forums.rb @@ -0,0 +1,5 @@ +class AddNecroLengthToForums < ActiveRecord::Migration + def change + add_column :forums, :necro_length, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index b38ae38..353c482 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,10 +11,10 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170319193517) do +ActiveRecord::Schema.define(version: 20170409135858) do create_table "blogposts", force: :cascade do |t| - t.string "title" + t.string "title", limit: 191 t.text "content", limit: 65535 t.integer "user_author_id", limit: 4 t.integer "user_editor_id", limit: 4 @@ -32,18 +32,19 @@ ActiveRecord::Schema.define(version: 20170319193517) do end create_table "forumgroups", force: :cascade do |t| - t.string "name" + t.string "name", limit: 191 t.integer "position", limit: 4 t.integer "role_read_id", limit: 4 t.integer "role_write_id", limit: 4 end create_table "forums", force: :cascade do |t| - t.string "name" + t.string "name", limit: 191 t.integer "position", limit: 4 t.integer "role_read_id", limit: 4 t.integer "role_write_id", limit: 4 t.integer "forumgroup_id", limit: 4 + t.integer "necro_length", limit: 4, default: -1 end create_table "forums_labels", id: false, force: :cascade do |t| @@ -52,7 +53,7 @@ ActiveRecord::Schema.define(version: 20170319193517) do end create_table "forumthreads", force: :cascade do |t| - t.string "title" + t.string "title", limit: 191 t.text "content", limit: 65535 t.boolean "sticky", default: false t.boolean "locked", default: false @@ -65,29 +66,29 @@ ActiveRecord::Schema.define(version: 20170319193517) do end create_table "info", force: :cascade do |t| - t.string "title" + t.string "title", limit: 191 t.text "content", limit: 65535 t.datetime "created_at" t.datetime "updated_at" end create_table "labels", force: :cascade do |t| - t.string "name" - t.string "color" + t.string "name", limit: 191 + t.string "color", limit: 191 end create_table "register_tokens", force: :cascade do |t| - t.string "uuid", null: false - t.string "token", null: false - t.string "email", null: false + t.string "uuid", limit: 191, null: false + t.string "token", limit: 191, null: false + t.string "email", limit: 191, null: false end add_index "register_tokens", ["uuid"], name: "index_register_tokens_on_uuid", unique: true, using: :btree create_table "roles", force: :cascade do |t| - t.string "name" + t.string "name", limit: 191 t.integer "value", limit: 4 - t.string "color" + t.string "color", limit: 191 end create_table "badges", force: :cascade do |t| @@ -97,7 +98,7 @@ ActiveRecord::Schema.define(version: 20170319193517) do end create_table "sessions", force: :cascade do |t| - t.string "session_id", null: false + t.string "session_id", limit: 191, null: false t.text "data", limit: 65535 t.datetime "created_at" t.datetime "updated_at" @@ -116,14 +117,14 @@ ActiveRecord::Schema.define(version: 20170319193517) do end create_table "users", force: :cascade do |t| - t.string "uuid", null: false - t.string "name", null: false - t.string "password_digest", null: false - t.string "ign", null: false - t.string "email", null: false + t.string "uuid", limit: 191, null: false + t.string "name", limit: 191, null: false + t.string "password_digest", limit: 191, null: false + t.string "ign", limit: 191, null: false + t.string "email", limit: 191, null: false t.text "about", limit: 65535 - t.string "last_ip" - t.string "skype" + t.string "last_ip", limit: 191 + t.string "skype", limit: 191 t.boolean "skype_public", default: false t.string "youtube" t.string "youtube_channelname" -- 2.52.0 From db3aea185b5d21a14e61ca3c1939083103cc4fb6 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 28 May 2017 17:42:39 -0400 Subject: [PATCH 059/214] Added Reply Reversal And Toggle --- app/controllers/forumthreads_controller.rb | 8 ++++++-- app/views/forumthreads/show.html.erb | 12 +++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index b9b5714..b1dffd9 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -7,7 +7,11 @@ class ForumthreadsController < ApplicationController end def show - @replies = @thread.replies.page(params[:page]) + if params[:reverse] + @replies = @thread.replies.reverse_order.page(params[:page]) + else + @replies = @thread.replies.page(params[:page]) + end end def edit @@ -92,4 +96,4 @@ class ForumthreadsController < ApplicationController a += add params.require(:forumthread).permit(a) end -end \ No newline at end of file +end diff --git a/app/views/forumthreads/show.html.erb b/app/views/forumthreads/show.html.erb index 876d55d..82f8fb3 100644 --- a/app/views/forumthreads/show.html.erb +++ b/app/views/forumthreads/show.html.erb @@ -1,6 +1,12 @@ <%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → <%=truncate(@thread.title, length: 60, omission: " …") %> -

    <%= render partial: "labels/label", locals: {label: @thread.label} %><%= title @thread.title %>

    - +

    + <%= render partial: "labels/label", locals: {label: @thread.label} %><%= title @thread.title %> + <% if params[:reverse] %> + <%= link_to "Reverse Replies", @thread, class: "btn right blue" %> + <% else %> + <%= link_to "Reverse Replies", forumthread_path(@thread, reverse: true), class: "btn right blue" %> + <% end %> +

    <%= link_to(@thread.author.avatar(64), @thread.author, title: @thread.author.ign) %> @@ -44,4 +50,4 @@ <% else %>

    Please <%= link_to "Log in", login_path(return_path: request.env['PATH_INFO']), action: "new" %> to post a reply.

    <% end %> -
    \ No newline at end of file +
    -- 2.52.0 From a24d26dd7c9c829b28732174ed5f5ff2d4448bfb Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 28 May 2017 17:46:39 -0400 Subject: [PATCH 060/214] Added Website Settings --- Gemfile | 3 +- app/assets/stylesheets/dark.css.scss | 105 ++++++++++++++++++ app/assets/stylesheets/mobi.css.scss | 15 ++- app/assets/stylesheets/style.css.scss | 24 +++- app/controllers/users_controller.rb | 11 +- app/helpers/application_helper.rb | 6 +- app/views/layouts/_head.html.erb | 9 +- app/views/layouts/application.html.erb | 11 +- app/views/users/edit.html.erb | 7 +- .../users/edit_website_settings.html.erb | 34 ++++++ config/initializers/assets.rb | 1 + .../20170320195301_add_utc_time_to_users.rb | 5 + ...170328100851_add_header_scroll_to_users.rb | 5 + .../20170515200733_add_dark_to_users.rb | 5 + db/schema.rb | 7 +- db/seeds.rb | 48 ++------ 16 files changed, 236 insertions(+), 60 deletions(-) create mode 100644 app/assets/stylesheets/dark.css.scss create mode 100644 app/views/users/edit_website_settings.html.erb create mode 100644 config/initializers/assets.rb create mode 100644 db/migrate/20170320195301_add_utc_time_to_users.rb create mode 100644 db/migrate/20170328100851_add_header_scroll_to_users.rb create mode 100644 db/migrate/20170515200733_add_dark_to_users.rb diff --git a/Gemfile b/Gemfile index 4714ee3..a277484 100644 --- a/Gemfile +++ b/Gemfile @@ -15,6 +15,7 @@ gem 'activerecord-session_store' gem 'highlight_js-rails', github: 'RedstonerServer/highlight_js-rails' gem 'kaminari', github: 'jomo/kaminari', branch: 'patch-2' # pagination gem 'jquery-textcomplete-rails', github: 'RedstonerServer/jquery-textcomplete-rails' # @mentions +gem 'actionpack-action_caching' # Gems used only for assets and not required # in production environments by default. @@ -43,4 +44,4 @@ end group :production do # Use unicorn as the app server gem 'unicorn' -end \ No newline at end of file +end diff --git a/app/assets/stylesheets/dark.css.scss b/app/assets/stylesheets/dark.css.scss new file mode 100644 index 0000000..90c7fc0 --- /dev/null +++ b/app/assets/stylesheets/dark.css.scss @@ -0,0 +1,105 @@ +body { + background-color:rgb(50, 50, 50); + text-shadow:none !important; + color:rgb(190, 190, 190) !important; +} +::selection { + background-color:rgb(100, 150, 255); +} +a { + color:rgb(203, 75, 22); + border-color:black !important; +} +a:hover { + color:rgb(215, 100, 40); +} +#main-content { + border-color:black !important; + padding:30px 100px; + box-shadow:none; +} +#main-content-scroll { + padding: 131px 100px; + border: 1px solid #000; + box-shadow: 0 0 5px #000; +} +hr { + background-color:black !important; + border-color:black !important; +} +code { + background-color:rgb(30, 30, 30) !important; + border-color:black !important; + color:white !important; +} +#head_top { + width:100%; + z-index:100; +} +#head_scroll { + @extend #head_top; + position: fixed; + width: 100%; + z-index: 1; +} +div#userbar { + background-color:rgb(90, 90, 90) !important; + border-color:black !important; + color:white !important; + text-shadow:none !important; +} +#head a { + text-shadow:none !important; + color:white !important; +} +#head a:hover { + color:rgb(190, 190, 190) !important; +} +.header { + background-color:rgb(0, 0, 0); + border:none !important; +} +input[type="email"], input[type="text"], input[type="password"] { + background-color:rgb(110, 110, 110) !important; + color:white !important; +} +::placeholder { + color:lightgray; +} +.item { + background-color:rgb(40, 40, 40) !important; + border-color:black !important; +} +.item-group { + border-color:black !important; +} +div.header { + background-color:rgb(20, 20, 20) !important; +} +.avatar { + border-color:black !important; +} +.items { + border-color:black !important; +} +.markdown-help { + background-color:rgb(90, 90, 90); + color:white; + border-color:black; +} +textarea { + background-color:rgb(100, 100, 100); + color:white; +} +.headline { + border-color:black !important; +} +.role { + opacity:0.7 !important; +} +.label { + opacity:0.7 !important; +} +.notice { + color:white; +} diff --git a/app/assets/stylesheets/mobi.css.scss b/app/assets/stylesheets/mobi.css.scss index cc437cb..c1b44fd 100644 --- a/app/assets/stylesheets/mobi.css.scss +++ b/app/assets/stylesheets/mobi.css.scss @@ -4,12 +4,12 @@ th, td { // force tables into line-mode - // it's a bit ugly, but probably the best + // it''s a bit ugly, but probably the best // solution for small screens display: block; } - #head { + #head_top { #menu { #logo { display: none; @@ -17,10 +17,19 @@ } } + #head_scroll { + @extend #head_top; + position: fixed; +} + #main-content { padding: 30px 5px; } + #main-content-scroll { + padding: 181px 5px; + } + .front-page { h1 { font-size: 2em !important; @@ -66,4 +75,4 @@ margin: 50px 20px 0; } -} \ No newline at end of file +} diff --git a/app/assets/stylesheets/style.css.scss b/app/assets/stylesheets/style.css.scss index da15801..18042ad 100644 --- a/app/assets/stylesheets/style.css.scss +++ b/app/assets/stylesheets/style.css.scss @@ -80,7 +80,7 @@ a { } } -#head { +#head_top { background: #3f3f3f; #menu { @@ -181,6 +181,13 @@ a { } } +#head_scroll { + @extend #head_top; + position: fixed; + width: 100%; + z-index: 1; +} + .front-page { margin: auto; text-align: center; @@ -260,6 +267,11 @@ span.no-about { } } +#main-content-scroll { + @extend #main-content; + padding: 131px 100px; +} + #user-info { .user-avatar { margin-bottom: 30px; @@ -454,6 +466,7 @@ blockquote p { } .md_editor { + .field_container { position: relative; @@ -461,7 +474,7 @@ blockquote p { position: absolute; top: 1em; left: 1em; - z-index: 10; + z-index: 0; } .editor_field { @@ -671,6 +684,13 @@ tr.spacer { color: #ddd; } + &.variable-size { + background: #4096ee; + @media only screen and (max-width: 500px) { + font-size: 9px; + } + } + &.blue { background: #4096ee; diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 27e89af..16f42d3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -157,9 +157,9 @@ class UsersController < ApplicationController def update if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?) if mod? - userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about, :role, :badge, :confirmed]) + userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about, :role, :badge, :confirmed, :header_scroll, :utc_time, :dark]) else - userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about]) + userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about, :header_scroll, :utc_time, :dark]) end if userdata[:role] role = Role.get(userdata[:role]) @@ -241,6 +241,13 @@ class UsersController < ApplicationController end end + def edit_website_settings + unless @user.is?(current_user) || admin? && current_user.role > @user.role || superadmin? + flash[:alert] = "You are not allowed to edit this user's website settings!" + redirect_to @user + end + end + def update_login if @user.is?(current_user) || admin? && current_user.role > @user.role || superadmin? authenticated = !@user.is?(current_user) || @user.authenticate(params[:current_password]) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1419391..a1bf22c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -11,10 +11,12 @@ module ApplicationHelper end def ago(tm) - if tm + if tm && current_user.try(:utc_time) != true content_tag :time, title: tm.strftime("%e %b %Y, %H:%M %Z"), datetime: tm.to_datetime.rfc3339 do tm.strftime("%e %b %Y, %H:%M") end + else + tm end end @@ -90,4 +92,4 @@ module ApplicationHelper https://www.youtube-nocookie.com/embed/\\1?theme=light&vq=hd720&hd=1&iv_load_policy=3&showinfo=1&showsearch=0&rel=0&modestbranding&hd=1&autohide=1&html5=1&start=\\3'> ") end -end \ No newline at end of file +end diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb index 183a615..e6b5080 100644 --- a/app/views/layouts/_head.html.erb +++ b/app/views/layouts/_head.html.erb @@ -1,4 +1,9 @@ - \ No newline at end of file + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index a0a5f83..e85d417 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -5,6 +5,9 @@ <%= stylesheet_link_tag "application", :media => "all" %> + <% if current_user.try(:dark) == true %> + <%= stylesheet_link_tag "dark", :media => "all" %> + <% end %> <%= csrf_meta_tags %> <%= favicon_link_tag "favicon.ico" %> <%= javascript_include_tag "https://cdn.rawgit.com/jomo/ago.js/v0.0.1/ago.min.js", crossorigin: :anonymous, integrity: "sha256-xw0JUUdbuZQCVO+QScoxrlEsD4nZGCjMRh9PP8GLhcY=" %> @@ -14,7 +17,11 @@ <%= render partial: "/layouts/head" %> -
    + <% content = "main-content" %> + <% if current_user.try(:header_scroll) == true %> + <% content = "main-content-scroll" %> + <% end %> +
    <% if alert %>
    <%= alert %>
    <% end %> @@ -25,4 +32,4 @@
    <%= render partial: "/layouts/footer" %> - \ No newline at end of file + diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 5e63c00..133a69d 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -75,10 +75,11 @@ -

    <%= f.submit "Save profile", class: "btn blue left", disabled: (!@user.confirmed? && @user.is?(current_user)) %>

    +

    <%= f.submit "Save profile", class: "btn variable-size left", disabled: (!@user.confirmed? && @user.is?(current_user)) %>

    - <%= link_to "Edit login details", edit_login_user_path(@user), class: "btn blue right" %> - <%= link_to "Notification settings", edit_notifications_user_path(@user), class: "btn blue right" %> + <%= link_to "Edit login details", edit_login_user_path(@user), class: "btn variable-size right" %> + <%= link_to "Notification settings", edit_notifications_user_path(@user), class: "btn variable-size right" %> + <%= link_to "Website settings", edit_website_settings_user_path(@user), class: "btn variable-size right" %>

    diff --git a/app/views/users/edit_website_settings.html.erb b/app/views/users/edit_website_settings.html.erb new file mode 100644 index 0000000..2fdeffb --- /dev/null +++ b/app/views/users/edit_website_settings.html.erb @@ -0,0 +1,34 @@ +<% title "Edit Website Settings: #{@user.name}" %> + +<%= link_to @user.name, @user %> → Edit Website Settings +

    Edit Website Settings

    + + +<%= form_for @user do |f| %> + + + + + + + + + + + + + + + +
    Header moves with scrolling (Experimental - do not report bugs) + <%= f.check_box :header_scroll %> +
    Show exact UTC times + <%= f.check_box :utc_time %> +
    Dark theme* + <%= f.check_box :dark %> +
    +

    <%= f.submit "Save changes", class: "btn blue left" %>

    +
    +<% end %> +


    +*Warning: If as a result to enabling this style your eyes get infected with a severe case of eye cancer, we are not reliable for any damage. Please contact your doctor in advance to ensure that in case of infection you will be treated accordingly. Quality theme brought to you by Redempt™. diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 0000000..ea74dfd --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1 @@ +Rails.application.config.assets.precompile += %w( dark.css ) diff --git a/db/migrate/20170320195301_add_utc_time_to_users.rb b/db/migrate/20170320195301_add_utc_time_to_users.rb new file mode 100644 index 0000000..538357c --- /dev/null +++ b/db/migrate/20170320195301_add_utc_time_to_users.rb @@ -0,0 +1,5 @@ +class AddUtcTimeToUsers < ActiveRecord::Migration + def change + add_column :users, :utc_time, :boolean, default: false + end +end diff --git a/db/migrate/20170328100851_add_header_scroll_to_users.rb b/db/migrate/20170328100851_add_header_scroll_to_users.rb new file mode 100644 index 0000000..0db36b1 --- /dev/null +++ b/db/migrate/20170328100851_add_header_scroll_to_users.rb @@ -0,0 +1,5 @@ +class AddHeaderScrollToUsers < ActiveRecord::Migration + def change + add_column :users, :header_scroll, :boolean, default: false + end +end diff --git a/db/migrate/20170515200733_add_dark_to_users.rb b/db/migrate/20170515200733_add_dark_to_users.rb new file mode 100644 index 0000000..c4bf3cc --- /dev/null +++ b/db/migrate/20170515200733_add_dark_to_users.rb @@ -0,0 +1,5 @@ +class AddDarkToUsers < ActiveRecord::Migration + def change + add_column :users, :dark, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 353c482..0a29b6b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170409135858) do +ActiveRecord::Schema.define(version: 20170515200733) do create_table "blogposts", force: :cascade do |t| t.string "title", limit: 191 @@ -133,6 +133,7 @@ ActiveRecord::Schema.define(version: 20170409135858) do t.boolean "confirmed", default: false t.datetime "last_seen" t.integer "role_id", limit: 4, null: false + t.integer "badge_id" t.datetime "created_at" t.datetime "updated_at" t.boolean "mail_own_thread_reply", default: true @@ -140,7 +141,9 @@ ActiveRecord::Schema.define(version: 20170409135858) do t.boolean "mail_own_blogpost_comment", default: true t.boolean "mail_other_blogpost_comment", default: true t.boolean "mail_mention", default: true - t.integer "badge_id" + t.boolean "header_scroll", default: false + t.boolean "utc_time", default: false + t.boolean "dark", default: false end add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree diff --git a/db/seeds.rb b/db/seeds.rb index 06c8d10..7b7530d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -36,7 +36,10 @@ deleted_user = User.create!( skype_public: true, last_ip: "0.0.0.0", confirmed: true, - last_seen: Time.utc(0).to_datetime + last_seen: Time.utc(0).to_datetime, + header_scroll: false, + utc_time: false, + dark: false ) deleted_user.update_attribute(:ign, "Steve") @@ -47,46 +50,9 @@ User.create!( password: "123456789", # high seructity! password_confirmation: "123456789", role: Role.get(:superadmin), + header_scroll: false, + utc_time: false, + dark: false badge: Badge.get(:donor), confirmed: true ) -User.create!( - uuid: "7f52491ab5d64c11b4a43806db47a101", - ign: "YummyRedstone", - email: "yummy@example.com", - password: "123456789", # high seructity! - password_confirmation: "123456789", - role: Role.get(:admin), - badge: Badge.get(:lead), - confirmed: true -) -User.create!( - uuid: "d2693e9193e14e3f929ff38e1ce8df03", - ign: "Pepich1851", - email: "pepe@example.com", - password: "123456789", # high seructity! - password_confirmation: "123456789", - role: Role.get(:superadmin), - badge: Badge.get(:retired), - confirmed: true -) -User.create!( - uuid: "c69f8316c60a4f8ca922bda933e01acd", - ign: "Doomblah", - email: "doom@example.com", - password: "123456789", # high seructity! - password_confirmation: "123456789", - role: Role.get(:normal), - badge: Badge.get(:developer), - confirmed: true -) -User.create!( - uuid: "b85a91b558b0474da2a42d5dd025f9e5", - ign: "Futsy", - email: "futsy@example.com", - password: "123456789", # high seructity! - password_confirmation: "123456789", - role: Role.get(:mod), - badge: Badge.get(:none), - confirmed: true -) -- 2.52.0 From e7463524af03a62b8ba4adbdee29efe5f547c2d4 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 28 May 2017 17:46:54 -0400 Subject: [PATCH 061/214] Added Who's Playing? screen --- app/controllers/statics_controller.rb | 6 ++++++ app/views/layouts/_head.html.erb | 3 +++ app/views/statics/online.html.erb | 17 +++++++++++++++++ config/database.yml | 2 +- config/environments/development.rb | 4 +++- config/routes.rb | 3 ++- 6 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 app/views/statics/online.html.erb diff --git a/app/controllers/statics_controller.rb b/app/controllers/statics_controller.rb index f2891f3..70d3bd8 100644 --- a/app/controllers/statics_controller.rb +++ b/app/controllers/statics_controller.rb @@ -1,5 +1,7 @@ class StaticsController < ApplicationController + caches_action :online, expires_in: 10.seconds + def index if current_user redirect_to blogposts_path @@ -14,4 +16,8 @@ class StaticsController < ApplicationController def donate end + def online + @players = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/JavaUtils/players.json"))["players"] + @players.collect!{ |p| User.find_by(uuid: p["uuid"].tr("-", "")) or User.new(name: p["name"], ign: p["name"], uuid: p["uuid"].tr("-", ""), role: Role.get("normal"), confirmed: true) }.sort_by!(&:role).reverse! + end end diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb index e6b5080..c64fe30 100644 --- a/app/views/layouts/_head.html.erb +++ b/app/views/layouts/_head.html.erb @@ -31,6 +31,9 @@
  • <%= link_to "Donate", donate_statics_path, class: ("active" if con == "statics" && params[:action] == "donate") %>
  • +
  • + <%= link_to "Who's Playing?", online_statics_path, class: ("active" if con == "statics" && params[:action] == "online") %> +
  • diff --git a/app/views/statics/online.html.erb b/app/views/statics/online.html.erb new file mode 100644 index 0000000..8c31182 --- /dev/null +++ b/app/views/statics/online.html.erb @@ -0,0 +1,17 @@ +<% title "Who's Playing?" %> +

    These players are currently playing on Redstoner:

    +
    + <% @players.each do |u| %> +
    + <%= link_to(u.avatar(64), u) %> +
    + <%= render partial: "users/username", locals: { user: u } %>
    + <%= u.ign %> + <% unless u.id %> +
    (Not signed up) + <% end %> +
    +
    + <% end %> +
    + diff --git a/config/database.yml b/config/database.yml index f421bef..db672c6 100644 --- a/config/database.yml +++ b/config/database.yml @@ -24,4 +24,4 @@ test: adapter: sqlite3 database: db/test.sqlite3 pool: 5 - timeout: 5000 \ No newline at end of file + timeout: 5000 diff --git a/config/environments/development.rb b/config/environments/development.rb index 06819fd..bfa0c96 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -6,6 +6,8 @@ Redstoner::Application.configure do # since you don't have to restart the web server when you make code changes. config.cache_classes = false + config.action_controller.perform_caching = true + # Log error messages when you accidentally call methods on nil. config.whiny_nils = true @@ -43,4 +45,4 @@ Redstoner::Application.configure do password: ENV["GMAIL_PASSWORD"], } -end \ No newline at end of file +end diff --git a/config/routes.rb b/config/routes.rb index 584c94f..f79ab5b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,10 +4,11 @@ Redstoner::Application.routes.draw do resources :comments end - resources :statics, only: [:home, :donate], path: '/' do + resources :statics, only: [:home, :donate, :online], path: '/' do collection do get 'donate' get 'home' + get 'online' get 'index' end end -- 2.52.0 From 1316d7ca0335dd4ff5f8b4c7bb46e961b37503f0 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 28 May 2017 18:08:57 -0400 Subject: [PATCH 062/214] Added Searching Features * Added Thread Search Feature * Added User Search Feature * Re-organized searching, added @mention support to author search --- app/controllers/application_controller.rb | 2 +- app/controllers/blogposts_controller.rb | 2 +- app/controllers/forums_controller.rb | 2 +- app/controllers/forumthreads_controller.rb | 23 ++++- app/controllers/users_controller.rb | 13 ++- app/helpers/mailer_helper.rb | 2 +- app/helpers/users_helper.rb | 2 +- app/models/forum.rb | 2 +- app/models/forumthread.rb | 43 ++++++++++ app/models/role.rb | 2 +- app/models/user.rb | 4 + .../application/_md_editor_user.html.erb | 8 ++ app/views/forums/index.html.erb | 4 +- app/views/forums/show.html.erb | 13 ++- app/views/forumthreads/index.html.erb | 84 +++++++++++++++++++ app/views/forumthreads/search.html.erb | 56 +++++++++++++ app/views/users/index.html.erb | 31 +++++-- config/routes.rb | 7 +- .../20170522210610_add_search_indexes.rb | 8 ++ db/schema.rb | 12 ++- 20 files changed, 293 insertions(+), 27 deletions(-) create mode 100644 app/views/application/_md_editor_user.html.erb create mode 100644 app/views/forumthreads/index.html.erb create mode 100644 app/views/forumthreads/search.html.erb create mode 100644 db/migrate/20170522210610_add_search_indexes.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a0e166e..d489611 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -75,4 +75,4 @@ class ApplicationController < ActionController::Base !!(current_user && current_user.confirmed?) end -end \ No newline at end of file +end diff --git a/app/controllers/blogposts_controller.rb b/app/controllers/blogposts_controller.rb index 79c9e5d..7a9851d 100644 --- a/app/controllers/blogposts_controller.rb +++ b/app/controllers/blogposts_controller.rb @@ -75,4 +75,4 @@ class BlogpostsController < ApplicationController end end -end \ No newline at end of file +end diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 486d21c..761a86b 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -1,4 +1,5 @@ class ForumsController < ApplicationController + before_filter :check_permission, only: [:show, :edit, :update, :destroy] def index @@ -77,7 +78,6 @@ class ForumsController < ApplicationController redirect_to forums_path end - private def check_permission diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index b1dffd9..e21c6d4 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -3,9 +3,14 @@ class ForumthreadsController < ApplicationController before_filter :check_permission, only: [:show, :edit, :update, :destroy] def index - redirect_to forum_path(@thread.forum.forumgroup, f) + if params[:label] && !Label.where("lower(name) = ?", params[:label].downcase).try(:first) && params[:label].downcase != "no label" + flash[:alert] = "'#{params[:label]}' is not a valid label." + redirect_to forumthreads_path(params.except(:label, :controller, :action)) + return + end + @threads = Forumthread.filter(current_user, params[:title], params[:content], params[:reply], params[:label], User.where("lower(ign) = ?", params[:author].to_s.downcase).try(:first), params[:query], Forum.where(id: params[:id]).try(:first)) + .page(params[:page]).per(30) end - def show if params[:reverse] @replies = @thread.replies.reverse_order.page(params[:page]) @@ -80,6 +85,20 @@ class ForumthreadsController < ApplicationController redirect_to @thread.forum end + def search + end + + def search_redirect + params.each do |key, value| + params[key] = nil if params[key] == "" + end + params[:id] = nil if params[:id] == "Search All Threads" + params[:label] = nil if params[:label] && params[:label].downcase == "label" + params[:author] = params[:author].tr("@ ", "") if params[:author] + params_list = Hash[params.except(:commit, :utf8, :authenticity_token)] + redirect_to forumthreads_path(params_list) + end + private def check_permission diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 16f42d3..6b31d22 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,7 +4,7 @@ class UsersController < ApplicationController include MailerHelper include ERB::Util - before_filter :set_user, except: [:index, :new, :create, :lost_password, :reset_password, :suggestions] + before_filter :set_user, except: [:index, :new, :create, :lost_password, :reset_password, :suggestions, :search_redirect] def index if params[:role] @@ -13,7 +13,7 @@ class UsersController < ApplicationController else if role = Role.get(params[:role]) @users = User.joins(:role).where(role: role) - else + elsif params[:search] == nil flash[:alert] = "role '#{params[:role]}' does not exist!" redirect_to users_path return @@ -30,6 +30,7 @@ class UsersController < ApplicationController else @users = User.joins(:role).where.not(id: User.first.id) #Remove first user end + @users = User.search(@users, params[:search]) if params[:search] @users = @users.order("roles.value desc", "confirmed desc", :name) unless params[:badge] @count = @users.size @users = @users.page(params[:page]).per(100) @@ -339,6 +340,14 @@ class UsersController < ApplicationController end end + def search_redirect + params.each do |key, value| + params[key] = nil if params[key] == "" + end + params_list = Hash[params.except(:commit, :utf8, :authenticity_token)] + redirect_to users_path(params_list) + end + private def validate_token(uuid, email, token) diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb index dbacf81..5e5649c 100644 --- a/app/helpers/mailer_helper.rb +++ b/app/helpers/mailer_helper.rb @@ -24,4 +24,4 @@ module MailerHelper end end end -end \ No newline at end of file +end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 2ce1765..7ad99d8 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -52,4 +52,4 @@ module UsersHelper end end -end \ No newline at end of file +end diff --git a/app/models/forum.rb b/app/models/forum.rb index 39e8f2a..a239dbc 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -32,4 +32,4 @@ class Forum < ActiveRecord::Base def to_param [id, to_s.parameterize].join("-") end -end \ No newline at end of file +end diff --git a/app/models/forumthread.rb b/app/models/forumthread.rb index 905e4d3..86823ac 100644 --- a/app/models/forumthread.rb +++ b/app/models/forumthread.rb @@ -65,4 +65,47 @@ class Forumthread < ActiveRecord::Base def to_param [id, to_s.parameterize].join("-") end + + def self.filter (user, title, content, reply, label, author, query, forum) + userid = user.try(:id).to_i + role = user.try(:role).to_i + + can_read = "COALESCE(forum_role_read.value, 0) <= ? AND COALESCE(forumgroup_role_read.value, 0) <= ?" + sticky_can_write = "sticky = true AND (COALESCE(forum_role_write.value, 0) <= ? OR COALESCE(forumgroup_role_write.value, 0) <= ?)" + + threads = forum.try(:forumthreads) || Forumthread + threads = threads.where("forumthreads.user_author_id = ? OR (#{can_read}) OR (#{sticky_can_write})", userid, role, role, role, role) + .joins("LEFT JOIN threadreplies ON forumthreads.id = threadreplies.forumthread_id") + .joins(forum: :forumgroup) + .joins("LEFT JOIN roles as forum_role_read ON forums.role_read_id = forum_role_read.id") + .joins("LEFT JOIN roles as forum_role_write ON forums.role_write_id = forum_role_write.id") + .joins("LEFT JOIN roles as forumgroup_role_read ON forumgroups.role_read_id = forumgroup_role_read.id") + .joins("LEFT JOIN roles as forumgroup_role_write ON forumgroups.role_write_id = forumgroup_role_write.id") + + if [content, title, reply, label, author, query].any? + label_o = Label.find_by(name: label) + if label_o + threads = threads.where(label: label_o) + elsif label.try(:downcase) == "no label" + threads = threads.where(label: nil) + end + + threads = threads.where(user_author: author) if author + + if query + threads = threads.where("MATCH (title, forumthreads.content) AGAINST (?) OR MATCH (threadreplies.content) AGAINST (?)", query, query) + elsif [title, content, reply].any? + query = [title, content, reply].select(&:present?).join(" ") + threads = threads.where("MATCH (title) AGAINST (?)", title) if title + threads = threads.where("MATCH (forumthreads.content) AGAINST (?)", content) if content + threads = threads.where("MATCH (threadreplies.content) AGAINST (?)", reply) if reply + threads = threads.group("threadreplies.id", "forumthreads.id") + threads = threads.order("(MATCH (title, forumthreads.content) AGAINST ('#{query}')) DESC") + end + end + + threads = threads.order("sticky desc", "threadreplies.created_at desc", "forumthreads.created_at desc") if threads.order_values.empty? + + threads + end end diff --git a/app/models/role.rb b/app/models/role.rb index 708fb40..e780b8c 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -53,4 +53,4 @@ class Role < ActiveRecord::Base Role.order(:value).select {|r| r >= from}.select {|r| r <= to} end -end \ No newline at end of file +end diff --git a/app/models/user.rb b/app/models/user.rb index ab7471e..a96410a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -174,4 +174,8 @@ class User < ActiveRecord::Base def set_email_token self.email_token ||= SecureRandom.hex(16) end + + def self.search (users, search) + return users.where("users.name like ? OR ign like ?", "%#{User.send(:sanitize_sql_like, search)}%", "%#{User.send(:sanitize_sql_like, search)}%") + end end diff --git a/app/views/application/_md_editor_user.html.erb b/app/views/application/_md_editor_user.html.erb new file mode 100644 index 0000000..25f63a4 --- /dev/null +++ b/app/views/application/_md_editor_user.html.erb @@ -0,0 +1,8 @@ +
    +
    + <% options = (defined?(options) && options || {}) %> + <% options[:class] = "#{options[:class]} editor_field" %> + <% options[:placeholder] ||= "Enter user's name. Prefix with \"@\" to get suggestions." %> + <%= text_field_tag name, content, options %> +
    +
    diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index f09ea20..0a2fbaf 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -1,5 +1,7 @@ <% title "Forums" %> +<%= link_to "All threads", forumthreads_path(params.except("controller", "action")), class: "btn blue right" %> +
    <% @groups.each do |group| %>
    @@ -56,4 +58,4 @@ <%= link_to "New group", new_forumgroup_path, class: "btn blue" %> <% elsif mod? %> <%= link_to "New group", "#", class: "btn blue", disabled: true %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 60f3185..9dcdad8 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -1,8 +1,15 @@ <%= link_to @forum.group, forumgroup_path(@forum.group) %> → <%= @forum %> -

    <%= title @forum %>

    +

    + <%= title @forum %> + <% params[:id] = params[:id].split("-")[0] %> + <%= link_to "Search Threads", forumthreads_path(params.except("action", "controller")), class: "btn blue right" %> +

    <% if @forum.can_write?(current_user) %> -

    <%= link_to "New thread", new_forumthread_path(forum: @forum), class: "btn blue" %>

    +

    + <%= link_to "New thread", new_forumthread_path(forum: @forum), class: "btn blue" %> + <% params[:id] = params[:id].split("-")[0] %> +

    <% end %> <% if @forum.role_read && @forum.role_write && @forum.role_write < @forum.role_read %> @@ -51,4 +58,4 @@
    <% end %> <%= paginate @threads %> -
    \ No newline at end of file +
    diff --git a/app/views/forumthreads/index.html.erb b/app/views/forumthreads/index.html.erb new file mode 100644 index 0000000..d765cda --- /dev/null +++ b/app/views/forumthreads/index.html.erb @@ -0,0 +1,84 @@ +<%= link_to "Forums", forums_path %> → +<% if params.to_hash.slice("label", "title", "content", "author", "reply").size > 0 %> + <%= link_to "All Threads", forumthreads_path %> → Search Results +<% else %> + <%= "All Threads" %> +<% end %> +<% params_list = params.to_hash.slice("id", "query", "label", "title", "content", "author", "reply") %> +

    + <% if params[:id] %> + <% text = "forum '#{Forum.find(params[:id]).name}'" %> + <% else %> + <% text = "all threads" %> + <% end %> + <% if params_list.size > 0 %> + <%= title "Search results in #{text} (#{@threads.length})" %> + <% else %> + <% if params[:id] %> + <%= title "All threads in #{text}" %> + <% else %> + <%= title "All Threads" %> + <% end %> + <% end %> +
    + <%= link_to "Advanced Search", search_forumthreads_path(params_list), class: "btn right blue" %> + <% if params_list.size > 0 && params[:id] %> + <%= link_to "Show All Threads", forumthreads_path(params_list.except("id")), class: "btn right blue" %> + <% elsif params_list.size > 0 && !params[:id] %> + <%= link_to "Show All Threads", forumthreads_path, class: "btn right blue" %> + <% end %> + <% if params[:id] %> + <%= link_to "Go to Forum", forum_path(params[:id]), class: "btn right blue" %> + <% end %> +

    +
    +<%= form_tag({controller: "forumthreads", action: "search_redirect"}, method: :post, style: "margin:0px;height:40px") do %> + <%= text_field_tag "query", nil, placeholder: "Search...", style: "margin:0px;height:40px;width:300px" %> + <% params.each do |key, value| %> + <%= hidden_field_tag key, params[key] if params[key] && params[key] != params[:query] %> + <% end %> + <%= submit_tag "Go", class: "btn blue", style: "margin:0px;height:40px;width:40px" %> +<% end %> + +
    + <% counter = 0 %> + <% @threads.each do |thread| %> + <% counter += 1 %> +
    +
    + <%= link_to(thread.author.avatar(64), thread.author, title: thread.author.ign) %> + <%= render partial: "users/username", locals: { user: thread.author } %> + <%= link_to thread do %> + <%= ago thread.created_at %> + <% end %> + + <%= link_to pluralize(thread.replies.count, "Reply"), thread %> + +
    +
    +
    +
    "> + <%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %> +
    + <% if rpl = thread.replies.last %> + <%= rpl.author.name %> + <% + position = thread.replies.count - 1 + page = position / Kaminari.config.default_per_page + 1 + %> + <%= link_to "replied", forumthread_path(thread, page: page) + "#reply-#{rpl.id}" %> + <%= ago rpl.created_at %>. + <% else %> + No replies yet. + <% end %> +
    +
    +
    +
    +
    + <% end %> + <% if counter == 0 %> +

    No results found

    + <% end %> + <%= paginate @threads %> +
    diff --git a/app/views/forumthreads/search.html.erb b/app/views/forumthreads/search.html.erb new file mode 100644 index 0000000..a3c631f --- /dev/null +++ b/app/views/forumthreads/search.html.erb @@ -0,0 +1,56 @@ +<% title "Thread Search" %> +

    Thread Search

    +

    Leave a field blank to ignore that search aspect.

    +<% label = Label.where(name: params[:label]).first %> + + +<%= form_tag({controller: "forumthreads", action: "search_redirect"}, method: :post) do %> + <% + forums = [] + Forum.all.sort_by{ |f| f.forumgroup && f.forumgroup.position || 0 }.each do |f| + if current_user != nil && current_user.role_id > f.role_read_id.to_i || current_user == nil && f.role_read_id == nil + forums << ["#{f.forumgroup.name} → #{f.name}", f.id] if f.forumgroup + end + end + %> + <% label_list = Label.pluck(:name).insert(0, "Label").insert(1, "No Label") %> + + + + + + + + + + + + + + + + + + + + + + + + + +<% end %> + +
    Forum<%= select_tag "id", options_for_select(["Search All Threads"] + forums, params[:id]) %>
    Label + <%= select_tag "label", options_for_select(label_list, params[:label]), class: "auto-width" %> +
    Title + <%= text_field_tag "title", params[:title], placeholder: "Search Titles" %> +
    Content + <%= text_field_tag "content", params[:content], placeholder: "Search Contents" %> +
    Author + <%= render partial: "md_editor_user", locals: {name: "author", content: params[:author]} %> +
    Replies + <%= text_field_tag "reply", params[:reply], placeholder: "Search Replies" %> +
    + <%= submit_tag "Go", class: "btn blue", style: "width:50px" %> +
    diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 95ab480..8df0fd0 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,14 +1,29 @@ +<%= form_tag({controller: "users", action: "search_redirect"}, method: :post, style: "margin:0px;height:40px") do %> + <%= text_field_tag "search", nil, placeholder: "Search for a user", style: "margin:0px;height:40px;width:300px" %> + <%= submit_tag "Go", class: "btn blue", style: "margin:0px;height:40px;width:40px" %> + <%= hidden_field_tag "role", params[:role] %> +<% end %> +

    - <% if params[:role] && !params[:badge]%> - <%= title "All '#{params[:role]}' users" %> - <% elsif params[:badge] && !params[:role] %> - <%= title "All '#{params[:badge]}' users" %> - <% elsif params[:role] && params[:badge] %> - <%= title "All '#{params[:role]}' and '#{params[:badge]}' users" %> + <% + if params[:role] && !params[:badge] + text = "All '#{params[:role]}' users" + elsif params[:badge] && !params[:role] + text = "All '#{params[:badge]}' users" + elsif params[:role] && params[:badge] + text = "All '#{params[:role]}' and '#{params[:badge]}' users" + else + text = "All users" + end + text += " that contain '#{params[:search]}'" if params[:search] + %> + <%= title text %> + <% if params[:search] %> + (<%= @users.select {|u| u.name.downcase.include?(params[:search].downcase) || u.ign.downcase.include?(params[:search].downcase) }.size %>) <% else %> - <%= title "All Users" %> + (<%= @count %>) <% end %> - (<%= @count %>) +

    <%= link_to "show all", users_path if params[:role] || params[:badge] %> diff --git a/config/routes.rb b/config/routes.rb index f79ab5b..4db3f30 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -27,14 +27,19 @@ Redstoner::Application.routes.draw do get 'lost_password' post 'reset_password' post 'suggestions' + post 'search_redirect' end end resources :forumgroups, path: '/forums/groups' - resources :forums, path: '/forums' resources :forumthreads, path: '/forums/threads' do resources :threadreplies, path: 'replies' + collection do + get 'search' + post 'search_redirect' + end end + resources :forums, path: '/forums' resources :tools do collection do diff --git a/db/migrate/20170522210610_add_search_indexes.rb b/db/migrate/20170522210610_add_search_indexes.rb new file mode 100644 index 0000000..2225d7b --- /dev/null +++ b/db/migrate/20170522210610_add_search_indexes.rb @@ -0,0 +1,8 @@ +class AddSearchIndexes < ActiveRecord::Migration + def change + add_index :forumthreads, [:title, :content], type: :fulltext + add_index :forumthreads, :title, type: :fulltext + add_index :forumthreads, :content, type: :fulltext + add_index :threadreplies, :content, type: :fulltext + end +end diff --git a/db/schema.rb b/db/schema.rb index 0a29b6b..aa35812 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170515200733) do +ActiveRecord::Schema.define(version: 20170522210610) do create_table "blogposts", force: :cascade do |t| t.string "title", limit: 191 @@ -65,6 +65,10 @@ ActiveRecord::Schema.define(version: 20170515200733) do t.integer "label_id", limit: 4 end + add_index "forumthreads", ["content"], name: "index_forumthreads_on_content", type: :fulltext + add_index "forumthreads", ["title", "content"], name: "index_forumthreads_on_title_and_content", type: :fulltext + add_index "forumthreads", ["title"], name: "index_forumthreads_on_title", type: :fulltext + create_table "info", force: :cascade do |t| t.string "title", limit: 191 t.text "content", limit: 65535 @@ -78,8 +82,8 @@ ActiveRecord::Schema.define(version: 20170515200733) do end create_table "register_tokens", force: :cascade do |t| - t.string "uuid", limit: 191, null: false - t.string "token", limit: 191, null: false + t.string "uuid", limit: 32, null: false + t.string "token", limit: 6, null: false t.string "email", limit: 191, null: false end @@ -116,6 +120,8 @@ ActiveRecord::Schema.define(version: 20170515200733) do t.datetime "updated_at" end + add_index "threadreplies", ["content"], name: "index_threadreplies_on_content", type: :fulltext + create_table "users", force: :cascade do |t| t.string "uuid", limit: 191, null: false t.string "name", limit: 191, null: false -- 2.52.0 From 4105f1c61f500c6de1b2c9764cfc8f75f5419352 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Fri, 2 Jun 2017 19:01:50 +0200 Subject: [PATCH 063/214] fixed action caching --- Gemfile | 2 +- app/controllers/statics_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index a277484..4216fe2 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ gem 'activerecord-session_store' gem 'highlight_js-rails', github: 'RedstonerServer/highlight_js-rails' gem 'kaminari', github: 'jomo/kaminari', branch: 'patch-2' # pagination gem 'jquery-textcomplete-rails', github: 'RedstonerServer/jquery-textcomplete-rails' # @mentions -gem 'actionpack-action_caching' +gem 'actionpack-action_caching', github: 'antulik/actionpack-action_caching', ref: '8c6e52c69315d67437f480da5dce4b7c8737fb32' # Gems used only for assets and not required # in production environments by default. diff --git a/app/controllers/statics_controller.rb b/app/controllers/statics_controller.rb index 70d3bd8..8ea9524 100644 --- a/app/controllers/statics_controller.rb +++ b/app/controllers/statics_controller.rb @@ -1,6 +1,6 @@ class StaticsController < ApplicationController - caches_action :online, expires_in: 10.seconds + caches_action :online, expires_in: 10.seconds, layout: false def index if current_user -- 2.52.0 From a250c411eb0a94613f5fbac3039ec979bdc06c52 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Fri, 2 Jun 2017 19:06:20 +0200 Subject: [PATCH 064/214] Added CSS for index search fields and revised regex for author search --- app/assets/javascripts/editor.js | 42 +++++++++++++++++- app/assets/stylesheets/style.css.scss | 21 +++++++++ app/views/forumthreads/index.html.erb | 63 ++++++++++++++------------- app/views/users/index.html.erb | 17 ++++---- 4 files changed, 104 insertions(+), 39 deletions(-) diff --git a/app/assets/javascripts/editor.js b/app/assets/javascripts/editor.js index 4b35aea..c977571 100644 --- a/app/assets/javascripts/editor.js +++ b/app/assets/javascripts/editor.js @@ -88,5 +88,45 @@ $(function() { }], { debounce: 300 }); + $('.md_editor .field_container_user .editor_field').textcomplete([{ + // match up to 2 words (everything except some special characters) + // each word can have up to 16 characters (up to 32 total) + // words must be separated by a single space + match: /(^|\s)(([^!"§$%&\/()=?.,;+*@\s]{1,16} ?){0,1}[^!"§$%&\/()=?.,;+*@\s]{1,16})$/, + search: function (text, callback, match) { + console.log("Searching " + text); + text = text.toLowerCase(); + $.ajax("/users/suggestions", { + type: "post", + data: {name: text}, + dataType: "json", + headers: { + "X-CSRF-Token": $('meta[name="csrf-token"]').attr("content") + }, + success: function(data) { + callback(data); + }, + error: function(xhr, status, err) { + console.error(err); + callback([]); + } + }); + }, + template: function(user) { + var name = user[0]; + var ign = user[1]; + if (name != ign) { + return name + " (" + ign + ")"; + } else { + return ign; + } + }, + cache: true, + replace: function (word) { + return "$1" + word[1] + " "; + } + }], { + debounce: 300 + }); -}); \ No newline at end of file +}); diff --git a/app/assets/stylesheets/style.css.scss b/app/assets/stylesheets/style.css.scss index 18042ad..73ab11f 100644 --- a/app/assets/stylesheets/style.css.scss +++ b/app/assets/stylesheets/style.css.scss @@ -489,6 +489,10 @@ blockquote p { padding: 4em 1em 1em; } } + .field_container_user { + .editor_field { + } + } } ul.dropdown-menu { @@ -1043,3 +1047,20 @@ nav.pagination { border-radius: 0.2em; text-shadow: none; } + +.searchfield { + margin:0px; + height:40px; + display: inline-block; + + .btn { + margin: 4px 1px 0 0; + padding: 6px; + cursor: default; + color: #fff; + border: none; + font-size: 12px; + line-height: normal; + background: #4096ee; + } +} diff --git a/app/views/forumthreads/index.html.erb b/app/views/forumthreads/index.html.erb index d765cda..f41d43d 100644 --- a/app/views/forumthreads/index.html.erb +++ b/app/views/forumthreads/index.html.erb @@ -1,49 +1,51 @@ <%= link_to "Forums", forums_path %> → -<% if params.to_hash.slice("label", "title", "content", "author", "reply").size > 0 %> +<% params_list = params.to_hash %> +<% if params_list.any? %> <%= link_to "All Threads", forumthreads_path %> → Search Results <% else %> <%= "All Threads" %> <% end %> -<% params_list = params.to_hash.slice("id", "query", "label", "title", "content", "author", "reply") %>

    - <% if params[:id] %> - <% text = "forum '#{Forum.find(params[:id]).name}'" %> - <% else %> - <% text = "all threads" %> - <% end %> - <% if params_list.size > 0 %> - <%= title "Search results in #{text} (#{@threads.length})" %> - <% else %> - <% if params[:id] %> - <%= title "All threads in #{text}" %> - <% else %> - <%= title "All Threads" %> - <% end %> - <% end %> + <% + if params[:id] + text = "forum '#{Forum.find(params[:id]).name}'" + if params_list.any? + text = "Search results in #{text} (#{@threads.length})" + else + text = text.capitalize + end + elsif params_list.any? + text = "Search results (#{@threads.length})" + else + text = "All threads" + end + %> + <%= title text %>
    <%= link_to "Advanced Search", search_forumthreads_path(params_list), class: "btn right blue" %> - <% if params_list.size > 0 && params[:id] %> - <%= link_to "Show All Threads", forumthreads_path(params_list.except("id")), class: "btn right blue" %> - <% elsif params_list.size > 0 && !params[:id] %> - <%= link_to "Show All Threads", forumthreads_path, class: "btn right blue" %> + <% if params_list.any? %> + <% if params[:id] %> + <%= link_to "Show All Threads", forumthreads_path(params_list.except("id")), class: "btn right blue" %> + <% else %> + <%= link_to "Show All Threads", forumthreads_path, class: "btn right blue" %> + <% end %> <% end %> <% if params[:id] %> <%= link_to "Go to Forum", forum_path(params[:id]), class: "btn right blue" %> <% end %>

    -
    -<%= form_tag({controller: "forumthreads", action: "search_redirect"}, method: :post, style: "margin:0px;height:40px") do %> - <%= text_field_tag "query", nil, placeholder: "Search...", style: "margin:0px;height:40px;width:300px" %> - <% params.each do |key, value| %> - <%= hidden_field_tag key, params[key] if params[key] && params[key] != params[:query] %> +
    + <%= form_tag({controller: "forumthreads", action: "index"}, method: :get, enforce_utf8: nil) do %> + <%= text_field_tag "query", params[:query], placeholder: "Search...", style: "width:300px" %> + <% params_list.compact.except("query").each do |key, value| %> + <%= hidden_field_tag key, params[key] %> + <% end %> + <%= submit_tag "Go", class: "searchfield btn", style: "width:40px", name: nil %> <% end %> - <%= submit_tag "Go", class: "btn blue", style: "margin:0px;height:40px;width:40px" %> -<% end %> +
    - <% counter = 0 %> <% @threads.each do |thread| %> - <% counter += 1 %>
    <%= link_to(thread.author.avatar(64), thread.author, title: thread.author.ign) %> @@ -77,7 +79,8 @@
    <% end %> - <% if counter == 0 %> + <% if @threads.empty? %> +

    No results found

    <% end %> <%= paginate @threads %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 8df0fd0..12e80ad 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,9 +1,11 @@ -<%= form_tag({controller: "users", action: "search_redirect"}, method: :post, style: "margin:0px;height:40px") do %> - <%= text_field_tag "search", nil, placeholder: "Search for a user", style: "margin:0px;height:40px;width:300px" %> - <%= submit_tag "Go", class: "btn blue", style: "margin:0px;height:40px;width:40px" %> - <%= hidden_field_tag "role", params[:role] %> -<% end %> - +
    + <%= form_tag({controller: "users", action: "index"}, method: :get, enforce_utf8: false) do %> + <%= text_field_tag "search", params[:search], placeholder: "Search for a user", style: "width:300px" %> + <%= submit_tag "Go", class: "searchfield btn", style: "width:40px", name: nil %> + <%= hidden_field_tag "role", params[:role] if params[:role] %> + <%= hidden_field_tag "badge", params[:badge] if params[:badge]%> + <% end %> +

    <% if params[:role] && !params[:badge] @@ -19,11 +21,10 @@ %> <%= title text %> <% if params[:search] %> - (<%= @users.select {|u| u.name.downcase.include?(params[:search].downcase) || u.ign.downcase.include?(params[:search].downcase) }.size %>) + (<%= @users.total_count %>) <% else %> (<%= @count %>) <% end %> -

    <%= link_to "show all", users_path if params[:role] || params[:badge] %> -- 2.52.0 From e2a16f3ae6e4c557a986d6170c1a7420e0ca08e0 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Fri, 2 Jun 2017 19:14:28 +0200 Subject: [PATCH 065/214] ordered searching to match SQL clauses, moved role&badge filtering to User.search --- app/controllers/forumthreads_controller.rb | 24 +++------ app/controllers/users_controller.rb | 38 ++----------- app/models/forumthread.rb | 63 +++++++++++----------- app/models/user.rb | 16 +++++- app/views/forumthreads/show.html.erb | 6 +-- 5 files changed, 56 insertions(+), 91 deletions(-) diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index e21c6d4..8827f89 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -3,16 +3,15 @@ class ForumthreadsController < ApplicationController before_filter :check_permission, only: [:show, :edit, :update, :destroy] def index - if params[:label] && !Label.where("lower(name) = ?", params[:label].downcase).try(:first) && params[:label].downcase != "no label" - flash[:alert] = "'#{params[:label]}' is not a valid label." - redirect_to forumthreads_path(params.except(:label, :controller, :action)) - return - end - @threads = Forumthread.filter(current_user, params[:title], params[:content], params[:reply], params[:label], User.where("lower(ign) = ?", params[:author].to_s.downcase).try(:first), params[:query], Forum.where(id: params[:id]).try(:first)) + params[:id] = nil if params[:id] && !Forum.find_by(id: params[:id]) + + params.each {|k,v| params[k] = nil if v==""} + + @threads = Forumthread.filter(current_user, params[:title], params[:content], params[:reply], params[:label], User.find_by(ign: params[:author].to_s.strip) || params[:author], params[:query], Forum.find_by(id: params[:id])) .page(params[:page]).per(30) end def show - if params[:reverse] + if params[:reverse] == "true" @replies = @thread.replies.reverse_order.page(params[:page]) else @replies = @thread.replies.page(params[:page]) @@ -88,17 +87,6 @@ class ForumthreadsController < ApplicationController def search end - def search_redirect - params.each do |key, value| - params[key] = nil if params[key] == "" - end - params[:id] = nil if params[:id] == "Search All Threads" - params[:label] = nil if params[:label] && params[:label].downcase == "label" - params[:author] = params[:author].tr("@ ", "") if params[:author] - params_list = Hash[params.except(:commit, :utf8, :authenticity_token)] - redirect_to forumthreads_path(params_list) - end - private def check_permission diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6b31d22..0a308c5 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,33 +4,13 @@ class UsersController < ApplicationController include MailerHelper include ERB::Util - before_filter :set_user, except: [:index, :new, :create, :lost_password, :reset_password, :suggestions, :search_redirect] + before_filter :set_user, except: [:index, :new, :create, :lost_password, :reset_password, :suggestions] def index - if params[:role] - if params[:role].downcase == "staff" - @users = User.joins(:role).where("roles.value >= ?", Role.get(:mod).to_i) - else - if role = Role.get(params[:role]) - @users = User.joins(:role).where(role: role) - elsif params[:search] == nil - flash[:alert] = "role '#{params[:role]}' does not exist!" - redirect_to users_path - return - end - end - elsif params[:badge] - if badge = Badge.get(params[:badge]) - @users = User.joins(:badge).where(badge: badge) - else - flash[:alert] = "badge '#{params[:badge]}' does not exist!" - redirect_to users_path - return - end - else - @users = User.joins(:role).where.not(id: User.first.id) #Remove first user - end - @users = User.search(@users, params[:search]) if params[:search] + params[:role] = nil if !Role.find_by(name: params[:role]) + params[:badge] = nil if !Badge.find_by(name: params[:badge]) + + @users = User.search(params[:search], params[:role], params[:badge]) @users = @users.order("roles.value desc", "confirmed desc", :name) unless params[:badge] @count = @users.size @users = @users.page(params[:page]).per(100) @@ -340,14 +320,6 @@ class UsersController < ApplicationController end end - def search_redirect - params.each do |key, value| - params[key] = nil if params[key] == "" - end - params_list = Hash[params.except(:commit, :utf8, :authenticity_token)] - redirect_to users_path(params_list) - end - private def validate_token(uuid, email, token) diff --git a/app/models/forumthread.rb b/app/models/forumthread.rb index 86823ac..9650e28 100644 --- a/app/models/forumthread.rb +++ b/app/models/forumthread.rb @@ -67,45 +67,42 @@ class Forumthread < ActiveRecord::Base end def self.filter (user, title, content, reply, label, author, query, forum) - userid = user.try(:id).to_i - role = user.try(:role).to_i + order_phrase = query || [title, content, reply].select(&:present?).join(" ") + user_id = user.try(:id).to_i + role_value = user.try(:role).to_i + can_read = "COALESCE(forum_role_read.value, 0) <= ? AND COALESCE(forumgroup_role_read.value, 0) <= ?" + # A user can view sticky threads in write-only forums without read permissions. + sticky_can_write = "sticky = true AND (COALESCE(forum_role_write.value, 0) <= ? AND COALESCE(forumgroup_role_write.value, 0) <= ?)" + match = "MATCH (title, forumthreads.content) AGAINST (?) OR MATCH (threadreplies.content) AGAINST (?)" - can_read = "COALESCE(forum_role_read.value, 0) <= ? AND COALESCE(forumgroup_role_read.value, 0) <= ?" - sticky_can_write = "sticky = true AND (COALESCE(forum_role_write.value, 0) <= ? OR COALESCE(forumgroup_role_write.value, 0) <= ?)" + threads = forum.try(:forumthreads) || Forumthread - threads = forum.try(:forumthreads) || Forumthread - threads = threads.where("forumthreads.user_author_id = ? OR (#{can_read}) OR (#{sticky_can_write})", userid, role, role, role, role) - .joins("LEFT JOIN threadreplies ON forumthreads.id = threadreplies.forumthread_id") - .joins(forum: :forumgroup) - .joins("LEFT JOIN roles as forum_role_read ON forums.role_read_id = forum_role_read.id") - .joins("LEFT JOIN roles as forum_role_write ON forums.role_write_id = forum_role_write.id") - .joins("LEFT JOIN roles as forumgroup_role_read ON forumgroups.role_read_id = forumgroup_role_read.id") - .joins("LEFT JOIN roles as forumgroup_role_write ON forumgroups.role_write_id = forumgroup_role_write.id") + threads = threads.select("forumthreads.*", "(MATCH (title, forumthreads.content) AGAINST (#{Forumthread.sanitize(order_phrase)})) AS relevance", "(MATCH (threadreplies.content) AGAINST (#{Forumthread.sanitize(order_phrase)})) AS reply_rel") - if [content, title, reply, label, author, query].any? - label_o = Label.find_by(name: label) - if label_o - threads = threads.where(label: label_o) - elsif label.try(:downcase) == "no label" - threads = threads.where(label: nil) + threads = threads.joins(forum: :forumgroup) + .joins("LEFT JOIN threadreplies ON forumthreads.id = threadreplies.forumthread_id") + .joins("LEFT JOIN roles as forum_role_read ON forums.role_read_id = forum_role_read.id") + .joins("LEFT JOIN roles as forum_role_write ON forums.role_write_id = forum_role_write.id") + .joins("LEFT JOIN roles as forumgroup_role_read ON forumgroups.role_read_id = forumgroup_role_read.id") + .joins("LEFT JOIN roles as forumgroup_role_write ON forumgroups.role_write_id = forumgroup_role_write.id") + + threads = threads.where("forumthreads.user_author_id = ? OR (#{can_read}) OR (#{sticky_can_write})", user_id, role_value, role_value, role_value, role_value) + if query + threads = threads.where("#{match}", query[0..99], query[0..99]) + elsif [title, content, reply].any? + threads = threads.where("MATCH (title) AGAINST (?)", title[0..99]) if title + threads = threads.where("MATCH (forumthreads.content) AGAINST (?)", content[0..99]) if content + threads = threads.where("MATCH (threadreplies.content) AGAINST (?)", reply[0..99]) if reply + end + if label.try(:downcase) == "no label" + threads = threads.where(label: nil) + elsif l = Label.find_by(name: label) && label + threads = threads.where(label: l) end - threads = threads.where(user_author: author) if author - if query - threads = threads.where("MATCH (title, forumthreads.content) AGAINST (?) OR MATCH (threadreplies.content) AGAINST (?)", query, query) - elsif [title, content, reply].any? - query = [title, content, reply].select(&:present?).join(" ") - threads = threads.where("MATCH (title) AGAINST (?)", title) if title - threads = threads.where("MATCH (forumthreads.content) AGAINST (?)", content) if content - threads = threads.where("MATCH (threadreplies.content) AGAINST (?)", reply) if reply - threads = threads.group("threadreplies.id", "forumthreads.id") - threads = threads.order("(MATCH (title, forumthreads.content) AGAINST ('#{query}')) DESC") - end - end + threads = threads.group("forumthreads.id") - threads = threads.order("sticky desc", "threadreplies.created_at desc", "forumthreads.created_at desc") if threads.order_values.empty? - - threads + order_phrase.presence ? threads.order("GREATEST(relevance, reply_rel) DESC") : threads.order("sticky desc", "threadreplies.created_at DESC", "forumthreads.created_at DESC") end end diff --git a/app/models/user.rb b/app/models/user.rb index a96410a..3098cfc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -175,7 +175,19 @@ class User < ActiveRecord::Base self.email_token ||= SecureRandom.hex(16) end - def self.search (users, search) - return users.where("users.name like ? OR ign like ?", "%#{User.send(:sanitize_sql_like, search)}%", "%#{User.send(:sanitize_sql_like, search)}%") + def self.search (search, role, badge) + if role + if role.downcase == "staff" + users = User.joins(:role).where("roles.value >= ?", Role.get(:mod).to_i) + elsif r = Role.get(role) + users = User.joins(:role).where(role: r) + else + end + elsif badge && b = Badge.get(badge) + users = User.joins(:badge).where(badge: b) + else + users = User.joins(:role).where.not(id: User.first.id) #Remove first user + end + return users.where("users.name like ? OR ign like ?", "%#{User.send(:sanitize_sql_like, search.to_s)}%", "%#{User.send(:sanitize_sql_like, search.to_s)}%") end end diff --git a/app/views/forumthreads/show.html.erb b/app/views/forumthreads/show.html.erb index 82f8fb3..b29d29e 100644 --- a/app/views/forumthreads/show.html.erb +++ b/app/views/forumthreads/show.html.erb @@ -1,11 +1,7 @@ <%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → <%=truncate(@thread.title, length: 60, omission: " …") %>

    <%= render partial: "labels/label", locals: {label: @thread.label} %><%= title @thread.title %> - <% if params[:reverse] %> - <%= link_to "Reverse Replies", @thread, class: "btn right blue" %> - <% else %> - <%= link_to "Reverse Replies", forumthread_path(@thread, reverse: true), class: "btn right blue" %> - <% end %> + <%= link_to "Reverse Replies", forumthread_path(@thread, reverse: params[:reverse] != "true"), class: "btn right blue" %>

    -- 2.52.0 From deba1b76e39c3528ca66e92c94a91eb3a8b4526b Mon Sep 17 00:00:00 2001 From: MrYummy Date: Fri, 2 Jun 2017 19:17:35 +0200 Subject: [PATCH 066/214] Updated find_by methods --- app/models/badge.rb | 4 ++-- app/models/comment.rb | 2 +- app/models/info.rb | 2 +- app/models/label.rb | 2 +- app/models/register_token.rb | 2 +- app/models/role.rb | 8 ++++---- app/models/threadreply.rb | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/models/badge.rb b/app/models/badge.rb index a7ff831..ee3de34 100644 --- a/app/models/badge.rb +++ b/app/models/badge.rb @@ -4,9 +4,9 @@ class Badge < ActiveRecord::Base def self.get (input) if input.is_a?(String) || input.is_a?(Symbol) - Badge.find_by_name(input) + Badge.find_by(name: input) elsif input.is_a?(Fixnum) - Badge.find_by_id(input) + Badge.find_by(id: input) elsif input.is_a?(Badge) return input end diff --git a/app/models/comment.rb b/app/models/comment.rb index 35a9a60..951d684 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -61,4 +61,4 @@ class Comment < ActiveRecord::Base background_mailer(mails) end -end \ No newline at end of file +end diff --git a/app/models/info.rb b/app/models/info.rb index b900ad0..cbfa1d3 100644 --- a/app/models/info.rb +++ b/app/models/info.rb @@ -11,4 +11,4 @@ class Info < ActiveRecord::Base [id, to_s.parameterize].join("-") end -end \ No newline at end of file +end diff --git a/app/models/label.rb b/app/models/label.rb index ee2fb56..d7cdc30 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -23,4 +23,4 @@ class Label < ActiveRecord::Base end end end -end \ No newline at end of file +end diff --git a/app/models/register_token.rb b/app/models/register_token.rb index 36c0cd1..5b956ff 100644 --- a/app/models/register_token.rb +++ b/app/models/register_token.rb @@ -1,2 +1,2 @@ class RegisterToken < ActiveRecord::Base -end \ No newline at end of file +end diff --git a/app/models/role.rb b/app/models/role.rb index e780b8c..5e5efa5 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -14,14 +14,14 @@ class Role < ActiveRecord::Base end def is? (name) - !!(Role.find_by_name(name) == self) + !!(Role.find_by(name: name) == self) end def self.get (input) if input.is_a?(String) || input.is_a?(Symbol) - Role.find_by_name(input) + Role.find_by(name: input) elsif input.is_a?(Fixnum) - Role.find_by_id(input) + Role.find_by(id: input) elsif input.is_a?(Role) return input end @@ -31,7 +31,7 @@ class Role < ActiveRecord::Base if role.is_a?(Role) self.value - role.value elsif role.is_a?(Symbol) - self <=> Role.find_by_name(role) + self <=> Role.find_by(name: role) else self.to_i <=> role end diff --git a/app/models/threadreply.rb b/app/models/threadreply.rb index 47b0d97..f285073 100644 --- a/app/models/threadreply.rb +++ b/app/models/threadreply.rb @@ -64,4 +64,4 @@ class Threadreply < ActiveRecord::Base end background_mailer(mails) end -end \ No newline at end of file +end -- 2.52.0 From 0c939f044ccd08dc741f3afaca91dbeb9b0d4b1b Mon Sep 17 00:00:00 2001 From: MrYummy Date: Fri, 2 Jun 2017 19:22:04 +0200 Subject: [PATCH 067/214] removed passing of useless params, updated placeholder for user textcomplete --- app/views/application/_md_editor_user.html.erb | 2 +- app/views/forums/index.html.erb | 2 +- app/views/forums/show.html.erb | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/views/application/_md_editor_user.html.erb b/app/views/application/_md_editor_user.html.erb index 25f63a4..d799fce 100644 --- a/app/views/application/_md_editor_user.html.erb +++ b/app/views/application/_md_editor_user.html.erb @@ -2,7 +2,7 @@
    <% options = (defined?(options) && options || {}) %> <% options[:class] = "#{options[:class]} editor_field" %> - <% options[:placeholder] ||= "Enter user's name. Prefix with \"@\" to get suggestions." %> + <% options[:placeholder] ||= "Enter user's name." %> <%= text_field_tag name, content, options %>
    diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index 0a2fbaf..5d9449d 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -1,6 +1,6 @@ <% title "Forums" %> -<%= link_to "All threads", forumthreads_path(params.except("controller", "action")), class: "btn blue right" %> +<%= link_to "All threads", forumthreads_path, class: "btn blue right" %>
    <% @groups.each do |group| %> diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 9dcdad8..36741d9 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -2,13 +2,12 @@

    <%= title @forum %> - <% params[:id] = params[:id].split("-")[0] %> - <%= link_to "Search Threads", forumthreads_path(params.except("action", "controller")), class: "btn blue right" %> + <% params[:id] = @forum.id %> + <%= link_to "Search Threads", forumthreads_path(params.to_hash), class: "btn blue right" %>

    <% if @forum.can_write?(current_user) %>

    <%= link_to "New thread", new_forumthread_path(forum: @forum), class: "btn blue" %> - <% params[:id] = params[:id].split("-")[0] %>

    <% end %> -- 2.52.0 From b99e62b7e7de3cc6c020a7a89a9d4066f6b0d797 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Fri, 2 Jun 2017 19:25:33 +0200 Subject: [PATCH 068/214] Removed all trace of search_redirect, included blanks for forum and label filters --- app/views/forumthreads/search.html.erb | 16 +++++++--------- app/views/threadreplies/_new.html.erb | 2 +- config/routes.rb | 3 +-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/app/views/forumthreads/search.html.erb b/app/views/forumthreads/search.html.erb index a3c631f..6db71a4 100644 --- a/app/views/forumthreads/search.html.erb +++ b/app/views/forumthreads/search.html.erb @@ -4,24 +4,22 @@ <% label = Label.where(name: params[:label]).first %> -<%= form_tag({controller: "forumthreads", action: "search_redirect"}, method: :post) do %> +<%= form_tag({controller: "forumthreads", action: "index"}, method: :get, enforce_utf8: false) do %> <% forums = [] - Forum.all.sort_by{ |f| f.forumgroup && f.forumgroup.position || 0 }.each do |f| - if current_user != nil && current_user.role_id > f.role_read_id.to_i || current_user == nil && f.role_read_id == nil - forums << ["#{f.forumgroup.name} → #{f.name}", f.id] if f.forumgroup - end + Forum.select{|f| f.can_read?(current_user)}.sort_by{ |f| f.forumgroup && f.forumgroup.position || 0 }.each do |f| + forums << ["#{f.forumgroup.name} → #{f.name}", f.id] if f.forumgroup end %> - <% label_list = Label.pluck(:name).insert(0, "Label").insert(1, "No Label") %> + <% label_list = Label.pluck(:name).prepend("No Label") %> - + @@ -48,7 +46,7 @@ <% end %> diff --git a/app/views/threadreplies/_new.html.erb b/app/views/threadreplies/_new.html.erb index 9d716d8..d1fc7d2 100644 --- a/app/views/threadreplies/_new.html.erb +++ b/app/views/threadreplies/_new.html.erb @@ -3,7 +3,7 @@ <% nec_msg = "" %> <% forum = Forum.find(reply.thread.forum_id) %> <% if forum.necro_length != nil %> - <% if Threadreply.where(forumthread: reply.thread).count != 0 %> + <% if Threadreply.where(forumthread: reply.thread).any? %> <% prevAgo = Threadreply.where(forumthread: reply.thread).order(:id).last.created_at %> <% if prevAgo <= forum.necro_length.days.ago.utc %> <% nec_msg = "You may be necroposting, as the last reply was made at least #{forum.necro_length} days ago. If you still wish to make this reply, press 'Ok'." %> diff --git a/config/routes.rb b/config/routes.rb index 4db3f30..5b35f95 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,12 +22,12 @@ Redstoner::Application.routes.draw do post 'resend_mail' get 'edit_notifications' put 'update_login' + get 'edit_website_settings' end collection do get 'lost_password' post 'reset_password' post 'suggestions' - post 'search_redirect' end end @@ -36,7 +36,6 @@ Redstoner::Application.routes.draw do resources :threadreplies, path: 'replies' collection do get 'search' - post 'search_redirect' end end resources :forums, path: '/forums' -- 2.52.0 From 79ad8b201edeecfa8c3402b302fa43af0c802328 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Fri, 2 Jun 2017 19:31:15 +0200 Subject: [PATCH 069/214] Changed 'no badge' check to be more reliable, added rake task for creating superadmin users --- app/views/users/_username.html.erb | 2 +- db/migrate/20140617183701_create_roles.rb | 2 +- db/migrate/20140617183702_create_users.rb | 2 +- db/schema.rb | 26 +++++++++++------------ db/seeds.rb | 14 ------------ lib/tasks/create_admin_user.rake | 18 ++++++++++++++++ 6 files changed, 34 insertions(+), 30 deletions(-) create mode 100644 lib/tasks/create_admin_user.rake diff --git a/app/views/users/_username.html.erb b/app/views/users/_username.html.erb index 4e78673..724e921 100644 --- a/app/views/users/_username.html.erb +++ b/app/views/users/_username.html.erb @@ -1,4 +1,4 @@
    <%= link_to user.name, user, class: "role #{user.role.name} #{"banned" if user.banned?} #{"disabled" if user.disabled?} #{"unconfirmed" unless user.confirmed?}", title: "#{user.ign} – #{user.role}", style: "color: #{fcolor(user.role.color)}; background-color: #{user.role.color}" %> - <%= link_to user.badge.symbol, users_path(badge: user.badge.name), class: "role badge", title: user.badge.name, style: "color: #{fcolor(user.badge.color)}; background-color: #{user.badge.color}" unless user.badge.value == 0 %> + <%= link_to user.badge.symbol, users_path(badge: user.badge.name), class: "role badge", title: user.badge.name, style: "color: #{fcolor(user.badge.color)}; background-color: #{user.badge.color}" unless user.badge.symbol.blank? %>
    diff --git a/db/migrate/20140617183701_create_roles.rb b/db/migrate/20140617183701_create_roles.rb index 3a25ea7..ad89207 100644 --- a/db/migrate/20140617183701_create_roles.rb +++ b/db/migrate/20140617183701_create_roles.rb @@ -5,4 +5,4 @@ class CreateRoles < ActiveRecord::Migration t.integer :value end end -end \ No newline at end of file +end diff --git a/db/migrate/20140617183702_create_users.rb b/db/migrate/20140617183702_create_users.rb index 1fefaf9..20e8a20 100644 --- a/db/migrate/20140617183702_create_users.rb +++ b/db/migrate/20140617183702_create_users.rb @@ -23,4 +23,4 @@ class CreateUsers < ActiveRecord::Migration t.timestamps null: true end end -end \ No newline at end of file +end diff --git a/db/schema.rb b/db/schema.rb index aa35812..916c41f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -13,6 +13,12 @@ ActiveRecord::Schema.define(version: 20170522210610) do + create_table "badges", force: :cascade do |t| + t.string "name", limit: 191 + t.string "symbol", limit: 191 + t.string "color", limit: 191 + end + create_table "blogposts", force: :cascade do |t| t.string "title", limit: 191 t.text "content", limit: 65535 @@ -44,7 +50,7 @@ ActiveRecord::Schema.define(version: 20170522210610) do t.integer "role_read_id", limit: 4 t.integer "role_write_id", limit: 4 t.integer "forumgroup_id", limit: 4 - t.integer "necro_length", limit: 4, default: -1 + t.integer "necro_length", limit: 4 end create_table "forums_labels", id: false, force: :cascade do |t| @@ -95,12 +101,6 @@ ActiveRecord::Schema.define(version: 20170522210610) do t.string "color", limit: 191 end - create_table "badges", force: :cascade do |t| - t.string "name" - t.string "symbol" - t.string "color" - end - create_table "sessions", force: :cascade do |t| t.string "session_id", limit: 191, null: false t.text "data", limit: 65535 @@ -132,14 +132,13 @@ ActiveRecord::Schema.define(version: 20170522210610) do t.string "last_ip", limit: 191 t.string "skype", limit: 191 t.boolean "skype_public", default: false - t.string "youtube" - t.string "youtube_channelname" - t.string "twitter" - t.string "email_token" + t.string "youtube", limit: 191 + t.string "youtube_channelname", limit: 191 + t.string "twitter", limit: 191 + t.string "email_token", limit: 191 t.boolean "confirmed", default: false t.datetime "last_seen" t.integer "role_id", limit: 4, null: false - t.integer "badge_id" t.datetime "created_at" t.datetime "updated_at" t.boolean "mail_own_thread_reply", default: true @@ -147,8 +146,9 @@ ActiveRecord::Schema.define(version: 20170522210610) do t.boolean "mail_own_blogpost_comment", default: true t.boolean "mail_other_blogpost_comment", default: true t.boolean "mail_mention", default: true - t.boolean "header_scroll", default: false + t.integer "badge_id", limit: 4, default: 0 t.boolean "utc_time", default: false + t.boolean "header_scroll", default: false t.boolean "dark", default: false end diff --git a/db/seeds.rb b/db/seeds.rb index 7b7530d..926d7b2 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -42,17 +42,3 @@ deleted_user = User.create!( dark: false ) deleted_user.update_attribute(:ign, "Steve") - -User.create!( - uuid: "ae795aa86327408e92ab25c8a59f3ba1", - ign: "jomo", - email: "jomo@example.com", - password: "123456789", # high seructity! - password_confirmation: "123456789", - role: Role.get(:superadmin), - header_scroll: false, - utc_time: false, - dark: false - badge: Badge.get(:donor), - confirmed: true -) diff --git a/lib/tasks/create_admin_user.rake b/lib/tasks/create_admin_user.rake new file mode 100644 index 0000000..28b7e9f --- /dev/null +++ b/lib/tasks/create_admin_user.rake @@ -0,0 +1,18 @@ +desc "Creates a superadmin user. Usage: rake create:create_admin_user[uuid, ign, email, pass]" +namespace :create do + task :create_admin_user, [:uuid, :ign, :email, :pass] => :environment do |task, args| + User.create!( + uuid: args.uuid, + ign: args.ign, + email: args.email, + password: args.pass, + password_confirmation: args.pass, + role: Role.get(:superadmin), + header_scroll: false, + utc_time: false, + dark: false, + badge: Badge.get(:donor), + confirmed: true + ) + end +end -- 2.52.0 From 617890c2097c554b69382ecfec5cc9a7f016fddd Mon Sep 17 00:00:00 2001 From: MrYummy Date: Fri, 2 Jun 2017 19:34:06 +0200 Subject: [PATCH 070/214] badge migration now contains default badges and creation of badge table --- db/migrate/20170319193517_add_badge_id_to_users.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/db/migrate/20170319193517_add_badge_id_to_users.rb b/db/migrate/20170319193517_add_badge_id_to_users.rb index 08328cf..4e9d7ed 100644 --- a/db/migrate/20170319193517_add_badge_id_to_users.rb +++ b/db/migrate/20170319193517_add_badge_id_to_users.rb @@ -1,8 +1,16 @@ class AddBadgeIdToUsers < ActiveRecord::Migration def change - add_column :users, :badge_id, :integer + + create_table "badges", force: :cascade do |t| + t.string "name" + t.string "symbol" + t.string "color" + end + + dbadge = Badge.create!({name: "donor", symbol: "$", color: "#f60"}) + add_column :users, :badge_id, :integer, default: 0 - User.where(donor: true).update_all(badge_id: 1) + User.where(donor: true).update_all(badge_id: dbadge.id) remove_column :users, :donor end end -- 2.52.0 From 1b8744abdba3e835a46efd0fcb3b518a452087e7 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Wed, 31 May 2017 21:44:22 +0200 Subject: [PATCH 071/214] Changed 'Who's Playing' code to handle revised JSON format --- app/controllers/statics_controller.rb | 5 +++-- app/views/statics/online.html.erb | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/statics_controller.rb b/app/controllers/statics_controller.rb index 8ea9524..4b0c911 100644 --- a/app/controllers/statics_controller.rb +++ b/app/controllers/statics_controller.rb @@ -17,7 +17,8 @@ class StaticsController < ApplicationController end def online - @players = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/JavaUtils/players.json"))["players"] - @players.collect!{ |p| User.find_by(uuid: p["uuid"].tr("-", "")) or User.new(name: p["name"], ign: p["name"], uuid: p["uuid"].tr("-", ""), role: Role.get("normal"), confirmed: true) }.sort_by!(&:role).reverse! + json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/JavaUtils/players.json")) + @players = json["players"].collect!{ |p| User.find_by(uuid: p["UUID"].tr("-", "")) or User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true) }.sort_by!(&:role).reverse! + @count = json["amount"] end end diff --git a/app/views/statics/online.html.erb b/app/views/statics/online.html.erb index 8c31182..8bacf6f 100644 --- a/app/views/statics/online.html.erb +++ b/app/views/statics/online.html.erb @@ -1,14 +1,15 @@ <% title "Who's Playing?" %> -

    These players are currently playing on Redstoner:

    +

    These players are currently playing on Redstoner (<%= @count %>):

    <% @players.each do |u| %>
    <%= link_to(u.avatar(64), u) %>
    <%= render partial: "users/username", locals: { user: u } %>
    - <%= u.ign %> - <% unless u.id %> -
    (Not signed up) + <% if u.id %> + <%= u.ign %> + <% else %> + (Not signed up) <% end %>
    -- 2.52.0 From 4619306744405209cae149c15dcb6bfdaaba462b Mon Sep 17 00:00:00 2001 From: MrYummy Date: Wed, 31 May 2017 22:00:22 +0200 Subject: [PATCH 072/214] Added Donator+ perk (/lol id) to the 'Donate' page and fixed spelling error on signup page ('singing' => 'signing') --- app/views/statics/donate.html.erb | 1 + app/views/users/new.html.erb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/statics/donate.html.erb b/app/views/statics/donate.html.erb index 774d917..2ca7114 100644 --- a/app/views/statics/donate.html.erb +++ b/app/views/statics/donate.html.erb @@ -19,6 +19,7 @@
  • The warm feeling of donating for a good thing, plus a huge "thank you"!
  • You can have a nickname. See <%= link_to "our nickname guidelines", info_path("12-nickname-guidelines") %>
  • A "$" next to your name (Including website) +
  • Donator+ has access to the in-game command /lol id

  • diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index c482df9..1d8a8c6 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -40,5 +40,5 @@ <%= f.submit "Sign up", class: "btn blue" %> -

    Contact us ingame if you have problems singing up!

    -<% end %> \ No newline at end of file +

    Contact us ingame if you have problems signing up!

    +<% end %> -- 2.52.0 From d2de01100ac3432baa66597730c41027ae858de7 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Fri, 2 Jun 2017 02:10:49 +0200 Subject: [PATCH 073/214] moved all search styling to CSS, removed friendly (but slow) URLs, moved WHERE strings into an array --- app/assets/javascripts/editor.js | 2 +- app/assets/stylesheets/style.css.scss | 11 +- app/controllers/#forumthreads_controller.rb# | 106 +++++++++++++++++++ app/controllers/forumthreads_controller.rb | 6 +- app/controllers/users_controller.rb | 6 +- app/models/forumthread.rb | 21 ++-- app/models/user.rb | 17 +-- app/views/forums/show.html.erb | 3 +- app/views/forumthreads/index.html.erb | 44 ++++---- app/views/forumthreads/search.html.erb | 4 +- 10 files changed, 164 insertions(+), 56 deletions(-) create mode 100644 app/controllers/#forumthreads_controller.rb# diff --git a/app/assets/javascripts/editor.js b/app/assets/javascripts/editor.js index c977571..4f4de5d 100644 --- a/app/assets/javascripts/editor.js +++ b/app/assets/javascripts/editor.js @@ -92,7 +92,7 @@ $(function() { // match up to 2 words (everything except some special characters) // each word can have up to 16 characters (up to 32 total) // words must be separated by a single space - match: /(^|\s)(([^!"§$%&\/()=?.,;+*@\s]{1,16} ?){0,1}[^!"§$%&\/()=?.,;+*@\s]{1,16})$/, + match: /(^|\s)([^!"§$%&\/()=?.,;+*@\s]{1,16})$/, search: function (text, callback, match) { console.log("Searching " + text); text = text.toLowerCase(); diff --git a/app/assets/stylesheets/style.css.scss b/app/assets/stylesheets/style.css.scss index 73ab11f..f8d1d8e 100644 --- a/app/assets/stylesheets/style.css.scss +++ b/app/assets/stylesheets/style.css.scss @@ -1049,18 +1049,17 @@ nav.pagination { } .searchfield { - margin:0px; height:40px; display: inline-block; - - .btn { + &.field { + width: 300px; + } + &.btn { margin: 4px 1px 0 0; - padding: 6px; cursor: default; color: #fff; - border: none; font-size: 12px; - line-height: normal; background: #4096ee; + width: 40px; } } diff --git a/app/controllers/#forumthreads_controller.rb# b/app/controllers/#forumthreads_controller.rb# new file mode 100644 index 0000000..1b43f15 --- /dev/null +++ b/app/controllers/#forumthreads_controller.rb# @@ -0,0 +1,106 @@ +class ForumthreadsController < ApplicationController + + before_filter :check_permission, only: [:show, :edit, :update, :destroy] + + def index + params[:id] = nil if params[:id] && !Forum.find_by(id: params[:id]) + + params.each {|k,v| params[k] = nil if v==""} + +c @threads = Forumthread.filter(current_user, params[:title], params[:content], params[:reply], params[:label], User.find_by(ign: params[:author].to_s.strip) || params[:author], params[:query], Forum.find_by(id: params[:id])) + .page(params[:page]).per(30) + end + def show + if params[:reverse] == "true" + @replies = @thread.replies.reverse_order.page(params[:page]) + else + @replies = @thread.replies.page(params[:page]) + end + end + + def edit + unless mod? || @thread.author.is?(current_user) + flash[:alert] = "You are not allowed to edit this thread!" + redirect_to @thread + end + end + + def new + @thread = Forumthread.new(forum: Forum.find(params[:forum])) + unless @thread.forum.can_write?(current_user) + flash[:alert] = "You are not allowed to write in this forum" + redirect_to forums_path + end + end + + def create + @thread = Forumthread.new(mod? ? thread_params([:sticky, :locked, :forum_id, :label_id]) : thread_params([:forum_id, :label_id])) + if @thread.forum.can_write?(current_user) + @thread.user_author = current_user + if @thread.save + @thread.send_new_mention_mail + flash[:notice] = "Thread created!" + redirect_to forumthread_path( @thread) + return + else + flash[:alert] = "Something went wrong while creating your thread." + render action: "new" + return + end + else + flash[:alert] = "You are not allowed to create a thread here!" + redirect_to @thread.forum + end + end + + def update + if mod? || @thread.author.is?(current_user) + @thread.user_editor = current_user + @thread.attributes = (mod? ? thread_params([:sticky, :locked, :forum_id, :label_id]) : thread_params) + old_content = @thread.content_was + if @thread.save + @thread.send_new_mention_mail(old_content) + redirect_to @thread, notice: 'Post has been updated.' + else + flash[:alert] = "There was a problem while updating the post" + render action: "edit" + end + else + flash[:alert] = "You are not allowed to edit this thread!" + redirect_to @thread + end + end + + def destroy + if mod? || @thread.author.is?(current_user) + if @thread.destroy + flash[:notice] = "Thread deleted!" + else + flash[:alert] = "There was a problem while deleting this thread" + end + else + flash[:alert] = "You are not allowed to delete this thread" + end + redirect_to @thread.forum + end + + def search + end + + private + + def check_permission + @thread = Forumthread.find(params[:id]) + unless @thread.can_read?(current_user) + flash[:alert] = "You are not allowed to view this thread" + redirect_to forums_path + end + end + + def thread_params(add = []) + a = [:title, :content] + a << :label_id if @thread && !@thread.locked? + a += add + params.require(:forumthread).permit(a) + end +end diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index 8827f89..81d420a 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -3,11 +3,11 @@ class ForumthreadsController < ApplicationController before_filter :check_permission, only: [:show, :edit, :update, :destroy] def index - params[:id] = nil if params[:id] && !Forum.find_by(id: params[:id]) + params[:forum] = nil if params[:forum] && !Forum.find_by(id: params[:forum]) - params.each {|k,v| params[k] = nil if v==""} + params.delete_if{|k,v| v.blank?} - @threads = Forumthread.filter(current_user, params[:title], params[:content], params[:reply], params[:label], User.find_by(ign: params[:author].to_s.strip) || params[:author], params[:query], Forum.find_by(id: params[:id])) + @threads = Forumthread.filter(current_user, params[:title].try(:slice, 0..255), params[:content].try(:slice, 0..255), params[:reply].try(:slice, 0..255), params[:label], User.find_by(ign: params[:author].to_s.strip) || params[:author], params[:query].try(:slice, 0..255), Forum.find_by(id: params[:forum])) .page(params[:page]).per(30) end def show diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0a308c5..60011a2 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -7,10 +7,10 @@ class UsersController < ApplicationController before_filter :set_user, except: [:index, :new, :create, :lost_password, :reset_password, :suggestions] def index - params[:role] = nil if !Role.find_by(name: params[:role]) - params[:badge] = nil if !Badge.find_by(name: params[:badge]) + role = Role.find_by(name: params[:role]) unless role.try(:downcase) == "staff" + badge = Badge.find_by(name: params[:badge]) - @users = User.search(params[:search], params[:role], params[:badge]) + @users = User.search(params[:search], role, badge) @users = @users.order("roles.value desc", "confirmed desc", :name) unless params[:badge] @count = @users.size @users = @users.page(params[:page]).per(100) diff --git a/app/models/forumthread.rb b/app/models/forumthread.rb index 9650e28..f8efe97 100644 --- a/app/models/forumthread.rb +++ b/app/models/forumthread.rb @@ -73,11 +73,11 @@ class Forumthread < ActiveRecord::Base can_read = "COALESCE(forum_role_read.value, 0) <= ? AND COALESCE(forumgroup_role_read.value, 0) <= ?" # A user can view sticky threads in write-only forums without read permissions. sticky_can_write = "sticky = true AND (COALESCE(forum_role_write.value, 0) <= ? AND COALESCE(forumgroup_role_write.value, 0) <= ?)" - match = "MATCH (title, forumthreads.content) AGAINST (?) OR MATCH (threadreplies.content) AGAINST (?)" + match = ["MATCH (title, forumthreads.content) AGAINST (#{Forumthread.sanitize(order_phrase)})", "MATCH (threadreplies.content) AGAINST (#{Forumthread.sanitize(order_phrase)})", "MATCH (title, forumthreads.content) AGAINST (?) OR MATCH (threadreplies.content) AGAINST (?)", "MATCH (title) AGAINST (?)", "MATCH (forumthreads.content) AGAINST (?)", "MATCH (threadreplies.content) AGAINST (?)"] threads = forum.try(:forumthreads) || Forumthread - threads = threads.select("forumthreads.*", "(MATCH (title, forumthreads.content) AGAINST (#{Forumthread.sanitize(order_phrase)})) AS relevance", "(MATCH (threadreplies.content) AGAINST (#{Forumthread.sanitize(order_phrase)})) AS reply_rel") + threads = threads.select("forumthreads.*", "#{match[0]} AS relevance", "#{match[1]} AS reply_rel") threads = threads.joins(forum: :forumgroup) .joins("LEFT JOIN threadreplies ON forumthreads.id = threadreplies.forumthread_id") @@ -88,21 +88,26 @@ class Forumthread < ActiveRecord::Base threads = threads.where("forumthreads.user_author_id = ? OR (#{can_read}) OR (#{sticky_can_write})", user_id, role_value, role_value, role_value, role_value) if query - threads = threads.where("#{match}", query[0..99], query[0..99]) + threads = threads.where("#{match[2]}", query[0..99], query[0..99]) elsif [title, content, reply].any? - threads = threads.where("MATCH (title) AGAINST (?)", title[0..99]) if title - threads = threads.where("MATCH (forumthreads.content) AGAINST (?)", content[0..99]) if content - threads = threads.where("MATCH (threadreplies.content) AGAINST (?)", reply[0..99]) if reply + threads = threads.where("#{match[3]}", title[0..99]) if title + threads = threads.where("#{match[4]}", content[0..99]) if content + threads = threads.where("#{match[5]}", reply[0..99]) if reply end if label.try(:downcase) == "no label" threads = threads.where(label: nil) - elsif l = Label.find_by(name: label) && label + elsif label && l = Label.find_by(name: label) threads = threads.where(label: l) end threads = threads.where(user_author: author) if author threads = threads.group("forumthreads.id") - order_phrase.presence ? threads.order("GREATEST(relevance, reply_rel) DESC") : threads.order("sticky desc", "threadreplies.created_at DESC", "forumthreads.created_at DESC") + if order_phrase.present? + threads = threads.order("GREATEST(relevance, reply_rel) DESC") + else + threads = threads.order("sticky desc", "threadreplies.created_at DESC", "forumthreads.created_at DESC") + end + threads end end diff --git a/app/models/user.rb b/app/models/user.rb index 3098cfc..ff09c70 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -177,17 +177,18 @@ class User < ActiveRecord::Base def self.search (search, role, badge) if role - if role.downcase == "staff" + if role.try(:downcase) == "staff" users = User.joins(:role).where("roles.value >= ?", Role.get(:mod).to_i) - elsif r = Role.get(role) - users = User.joins(:role).where(role: r) else + users = User.joins(:role).where(role: role) end - elsif badge && b = Badge.get(badge) - users = User.joins(:badge).where(badge: b) - else - users = User.joins(:role).where.not(id: User.first.id) #Remove first user end - return users.where("users.name like ? OR ign like ?", "%#{User.send(:sanitize_sql_like, search.to_s)}%", "%#{User.send(:sanitize_sql_like, search.to_s)}%") + if badge + users = User.joins(:badge).where(badge: badge) + else + users = User.joins(:role).all.where.not(id: User.first.id) + end + search_san = User.send(:sanitize_sql_like, search.to_s) + users.where("users.name like ? OR ign like ?", "%#{search_san}%", "%#{search_san}%") end end diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 36741d9..b232292 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -2,8 +2,7 @@

    <%= title @forum %> - <% params[:id] = @forum.id %> - <%= link_to "Search Threads", forumthreads_path(params.to_hash), class: "btn blue right" %> + <%= link_to "Search Threads", forumthreads_path(forum: @forum.id), class: "btn blue right" %>

    <% if @forum.can_write?(current_user) %>

    diff --git a/app/views/forumthreads/index.html.erb b/app/views/forumthreads/index.html.erb index f41d43d..3a0493b 100644 --- a/app/views/forumthreads/index.html.erb +++ b/app/views/forumthreads/index.html.erb @@ -7,8 +7,8 @@ <% end %>

    <% - if params[:id] - text = "forum '#{Forum.find(params[:id]).name}'" + if params[:forum] + text = "forum '#{Forum.find(params[:forum]).name}'" if params_list.any? text = "Search results in #{text} (#{@threads.length})" else @@ -21,29 +21,27 @@ end %> <%= title text %> -
    - <%= link_to "Advanced Search", search_forumthreads_path(params_list), class: "btn right blue" %> - <% if params_list.any? %> - <% if params[:id] %> - <%= link_to "Show All Threads", forumthreads_path(params_list.except("id")), class: "btn right blue" %> - <% else %> - <%= link_to "Show All Threads", forumthreads_path, class: "btn right blue" %> - <% end %> - <% end %> - <% if params[:id] %> - <%= link_to "Go to Forum", forum_path(params[:id]), class: "btn right blue" %> - <% end %>

    -
    - <%= form_tag({controller: "forumthreads", action: "index"}, method: :get, enforce_utf8: nil) do %> - <%= text_field_tag "query", params[:query], placeholder: "Search...", style: "width:300px" %> - <% params_list.compact.except("query").each do |key, value| %> - <%= hidden_field_tag key, params[key] %> - <% end %> - <%= submit_tag "Go", class: "searchfield btn", style: "width:40px", name: nil %> +
    +<%= form_tag(forumthreads_path, method: :get) do %> + <%= text_field_tag "query", params[:query], placeholder: "Search...", class: "searchfield field" %> + <%= submit_tag "Go", class: "searchfield btn" %> + <% params.slice(:title, :content, :reply, :label, :author).each do |key, value| %> + <%= hidden_field_tag key, params[key] %> <% end %> -
    - +<% end %> +<%= link_to "Advanced Search", search_forumthreads_path(params_list), class: "btn right blue" %> +<% if params_list.any? %> + <% if params[:forum] %> + <%= link_to "Show All Threads", forumthreads_path(params_list.except("forum")), class: "btn right blue" %> + <% elsif params_list.except(:controller, :action).any? %> + <%= link_to "Show All Threads", forumthreads_path, class: "btn right blue" %> + <% end %> +<% end %> +<% if params[:forum] %> + <%= link_to "Go to Forum", forum_path(params[:forum]), class: "btn right blue" %> +<% end %> +
    <% @threads.each do |thread| %>
    diff --git a/app/views/forumthreads/search.html.erb b/app/views/forumthreads/search.html.erb index 6db71a4..125868a 100644 --- a/app/views/forumthreads/search.html.erb +++ b/app/views/forumthreads/search.html.erb @@ -4,7 +4,7 @@ <% label = Label.where(name: params[:label]).first %>
    Forum<%= select_tag "id", options_for_select(["Search All Threads"] + forums, params[:id]) %><%= select_tag "id", options_for_select(forums, params[:id]), include_blank: "Search All Threads" %>
    Label - <%= select_tag "label", options_for_select(label_list, params[:label]), class: "auto-width" %> + <%= select_tag "label", options_for_select(label_list, params[:label]), include_blank: "Label" %>
    - <%= submit_tag "Go", class: "btn blue", style: "width:50px" %> + <%= submit_tag "Go", class: "btn blue", style: "width:50px", name: nil %>
    -<%= form_tag({controller: "forumthreads", action: "index"}, method: :get, enforce_utf8: false) do %> +<%= form_tag(forumthreads_path, method: :get) do %> <% forums = [] Forum.select{|f| f.can_read?(current_user)}.sort_by{ |f| f.forumgroup && f.forumgroup.position || 0 }.each do |f| @@ -14,7 +14,7 @@ <% label_list = Label.pluck(:name).prepend("No Label") %> - + -- 2.52.0 From 9837f12b595cbd783e835f93dd995f83b68e6749 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Fri, 2 Jun 2017 18:19:06 +0200 Subject: [PATCH 074/214] allowed role and badge filtering, made User.search take Role and Badge as params --- app/controllers/users_controller.rb | 5 ++--- app/models/user.rb | 12 +++++++++--- app/views/users/index.html.erb | 14 ++++++-------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 60011a2..dd12a98 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -7,11 +7,10 @@ class UsersController < ApplicationController before_filter :set_user, except: [:index, :new, :create, :lost_password, :reset_password, :suggestions] def index - role = Role.find_by(name: params[:role]) unless role.try(:downcase) == "staff" + role = Role.find_by(name: params[:role]) badge = Badge.find_by(name: params[:badge]) - @users = User.search(params[:search], role, badge) - @users = @users.order("roles.value desc", "confirmed desc", :name) unless params[:badge] + @users = User.search(params[:search], role, badge, params[:staff]) @count = @users.size @users = @users.page(params[:page]).per(100) end diff --git a/app/models/user.rb b/app/models/user.rb index ff09c70..24e7a2d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -151,6 +151,10 @@ class User < ActiveRecord::Base self.role ||= Role.get(:normal) end + def set_badge + self.badge ||= Badge.get(:none) + end + def set_uuid if !self.uuid.present? # idk @@ -175,9 +179,9 @@ class User < ActiveRecord::Base self.email_token ||= SecureRandom.hex(16) end - def self.search (search, role, badge) + def self.search (search, role, badge, staff) if role - if role.try(:downcase) == "staff" + if staff users = User.joins(:role).where("roles.value >= ?", Role.get(:mod).to_i) else users = User.joins(:role).where(role: role) @@ -189,6 +193,8 @@ class User < ActiveRecord::Base users = User.joins(:role).all.where.not(id: User.first.id) end search_san = User.send(:sanitize_sql_like, search.to_s) - users.where("users.name like ? OR ign like ?", "%#{search_san}%", "%#{search_san}%") + users = users.where("users.name like ? OR ign like ?", "%#{search_san}%", "%#{search_san}%") + users = users.order("roles.value desc", "confirmed desc", :name) unless badge + users end end diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 12e80ad..05e9249 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,11 +1,9 @@ -
    - <%= form_tag({controller: "users", action: "index"}, method: :get, enforce_utf8: false) do %> - <%= text_field_tag "search", params[:search], placeholder: "Search for a user", style: "width:300px" %> - <%= submit_tag "Go", class: "searchfield btn", style: "width:40px", name: nil %> - <%= hidden_field_tag "role", params[:role] if params[:role] %> - <%= hidden_field_tag "badge", params[:badge] if params[:badge]%> - <% end %> -
    +<%= form_tag(users_path, method: :get) do %> + <%= text_field_tag "search", params[:search], placeholder: "Search for a user", class: "searchfield field" %> + <%= submit_tag "Go", class: "searchfield btn", name: nil %> + <%= hidden_field_tag "role", params[:role] if params[:role] %> + <%= hidden_field_tag "badge", params[:badge] if params[:badge]%> +<% end %>

    <% if params[:role] && !params[:badge] -- 2.52.0 From 1e267a64fbca2668b3666984212d7e54b7160edd Mon Sep 17 00:00:00 2001 From: MrYummy Date: Fri, 2 Jun 2017 18:26:48 +0200 Subject: [PATCH 075/214] Addded default badge 'none' and enforced badges --- app/models/user.rb | 2 +- db/migrate/20170319193517_add_badge_id_to_users.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 24e7a2d..52b7130 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,7 +9,7 @@ class User < ActiveRecord::Base has_secure_password - before_validation :strip_whitespaces, :set_uuid, :set_name, :set_email_token, :set_role + before_validation :strip_whitespaces, :set_uuid, :set_name, :set_email_token, :set_role, :set_badge validates_presence_of :password, :password_confirmation, :email_token, on: :create validates_presence_of :name, :email, :ign diff --git a/db/migrate/20170319193517_add_badge_id_to_users.rb b/db/migrate/20170319193517_add_badge_id_to_users.rb index 4e9d7ed..19b58de 100644 --- a/db/migrate/20170319193517_add_badge_id_to_users.rb +++ b/db/migrate/20170319193517_add_badge_id_to_users.rb @@ -7,6 +7,7 @@ class AddBadgeIdToUsers < ActiveRecord::Migration t.string "color" end + Badge.create!({name: "none", symbol: "", color: "#000"}) dbadge = Badge.create!({name: "donor", symbol: "$", color: "#f60"}) add_column :users, :badge_id, :integer, default: 0 -- 2.52.0 From 65f7c3c97ff0a0d6112e95ba5c219f22ea203f17 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Fri, 2 Jun 2017 18:30:51 +0200 Subject: [PATCH 076/214] Made the default badge of 'create_admin_user' none --- lib/tasks/create_admin_user.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/create_admin_user.rake b/lib/tasks/create_admin_user.rake index 28b7e9f..22dceb3 100644 --- a/lib/tasks/create_admin_user.rake +++ b/lib/tasks/create_admin_user.rake @@ -11,7 +11,7 @@ namespace :create do header_scroll: false, utc_time: false, dark: false, - badge: Badge.get(:donor), + badge: Badge.get(:none), confirmed: true ) end -- 2.52.0 From 91169ab103234feb78d0a3882d9b89c3ef1dfad2 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Fri, 2 Jun 2017 18:39:20 +0200 Subject: [PATCH 077/214] removed '#forumthreads_controller.rb#' --- app/controllers/#forumthreads_controller.rb# | 106 ------------------- 1 file changed, 106 deletions(-) delete mode 100644 app/controllers/#forumthreads_controller.rb# diff --git a/app/controllers/#forumthreads_controller.rb# b/app/controllers/#forumthreads_controller.rb# deleted file mode 100644 index 1b43f15..0000000 --- a/app/controllers/#forumthreads_controller.rb# +++ /dev/null @@ -1,106 +0,0 @@ -class ForumthreadsController < ApplicationController - - before_filter :check_permission, only: [:show, :edit, :update, :destroy] - - def index - params[:id] = nil if params[:id] && !Forum.find_by(id: params[:id]) - - params.each {|k,v| params[k] = nil if v==""} - -c @threads = Forumthread.filter(current_user, params[:title], params[:content], params[:reply], params[:label], User.find_by(ign: params[:author].to_s.strip) || params[:author], params[:query], Forum.find_by(id: params[:id])) - .page(params[:page]).per(30) - end - def show - if params[:reverse] == "true" - @replies = @thread.replies.reverse_order.page(params[:page]) - else - @replies = @thread.replies.page(params[:page]) - end - end - - def edit - unless mod? || @thread.author.is?(current_user) - flash[:alert] = "You are not allowed to edit this thread!" - redirect_to @thread - end - end - - def new - @thread = Forumthread.new(forum: Forum.find(params[:forum])) - unless @thread.forum.can_write?(current_user) - flash[:alert] = "You are not allowed to write in this forum" - redirect_to forums_path - end - end - - def create - @thread = Forumthread.new(mod? ? thread_params([:sticky, :locked, :forum_id, :label_id]) : thread_params([:forum_id, :label_id])) - if @thread.forum.can_write?(current_user) - @thread.user_author = current_user - if @thread.save - @thread.send_new_mention_mail - flash[:notice] = "Thread created!" - redirect_to forumthread_path( @thread) - return - else - flash[:alert] = "Something went wrong while creating your thread." - render action: "new" - return - end - else - flash[:alert] = "You are not allowed to create a thread here!" - redirect_to @thread.forum - end - end - - def update - if mod? || @thread.author.is?(current_user) - @thread.user_editor = current_user - @thread.attributes = (mod? ? thread_params([:sticky, :locked, :forum_id, :label_id]) : thread_params) - old_content = @thread.content_was - if @thread.save - @thread.send_new_mention_mail(old_content) - redirect_to @thread, notice: 'Post has been updated.' - else - flash[:alert] = "There was a problem while updating the post" - render action: "edit" - end - else - flash[:alert] = "You are not allowed to edit this thread!" - redirect_to @thread - end - end - - def destroy - if mod? || @thread.author.is?(current_user) - if @thread.destroy - flash[:notice] = "Thread deleted!" - else - flash[:alert] = "There was a problem while deleting this thread" - end - else - flash[:alert] = "You are not allowed to delete this thread" - end - redirect_to @thread.forum - end - - def search - end - - private - - def check_permission - @thread = Forumthread.find(params[:id]) - unless @thread.can_read?(current_user) - flash[:alert] = "You are not allowed to view this thread" - redirect_to forums_path - end - end - - def thread_params(add = []) - a = [:title, :content] - a << :label_id if @thread && !@thread.locked? - a += add - params.require(:forumthread).permit(a) - end -end -- 2.52.0 From b73ba5d739f6c1d3a84c5ea1128cdbe5320d950e Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 18 Jun 2017 18:51:01 +0200 Subject: [PATCH 078/214] removed user 'donor?' method and changed default badge_id from 0 to 1 --- app/models/user.rb | 4 ---- db/migrate/20170319193517_add_badge_id_to_users.rb | 2 +- db/schema.rb | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 52b7130..d755646 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -30,10 +30,6 @@ class User < ActiveRecord::Base self == user end - def donor? - !!self.donor - end - def confirmed? !!self.confirmed end diff --git a/db/migrate/20170319193517_add_badge_id_to_users.rb b/db/migrate/20170319193517_add_badge_id_to_users.rb index 19b58de..4738e11 100644 --- a/db/migrate/20170319193517_add_badge_id_to_users.rb +++ b/db/migrate/20170319193517_add_badge_id_to_users.rb @@ -10,7 +10,7 @@ class AddBadgeIdToUsers < ActiveRecord::Migration Badge.create!({name: "none", symbol: "", color: "#000"}) dbadge = Badge.create!({name: "donor", symbol: "$", color: "#f60"}) - add_column :users, :badge_id, :integer, default: 0 + add_column :users, :badge_id, :integer, default: 1 User.where(donor: true).update_all(badge_id: dbadge.id) remove_column :users, :donor end diff --git a/db/schema.rb b/db/schema.rb index 916c41f..f2d73de 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -88,8 +88,8 @@ ActiveRecord::Schema.define(version: 20170522210610) do end create_table "register_tokens", force: :cascade do |t| - t.string "uuid", limit: 32, null: false - t.string "token", limit: 6, null: false + t.string "uuid", limit: 191, null: false + t.string "token", limit: 191, null: false t.string "email", limit: 191, null: false end -- 2.52.0 From 6d70fd330904e47112e890fdbe9a94a3efdfbe38 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 18 Jun 2017 18:54:04 +0200 Subject: [PATCH 079/214] made some small aesthetic changes --- app/views/forums/index.html.erb | 2 +- app/views/forumthreads/index.html.erb | 28 +++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index 5d9449d..532484b 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -1,7 +1,7 @@ <% title "Forums" %> <%= link_to "All threads", forumthreads_path, class: "btn blue right" %> - +
    <% @groups.each do |group| %>
    diff --git a/app/views/forumthreads/index.html.erb b/app/views/forumthreads/index.html.erb index 3a0493b..18b9ef4 100644 --- a/app/views/forumthreads/index.html.erb +++ b/app/views/forumthreads/index.html.erb @@ -1,5 +1,5 @@ <%= link_to "Forums", forums_path %> → -<% params_list = params.to_hash %> +<% params_list = params.except(:controller, :action) %> <% if params_list.any? %> <%= link_to "All Threads", forumthreads_path %> → Search Results <% else %> @@ -9,7 +9,7 @@ <% if params[:forum] text = "forum '#{Forum.find(params[:forum]).name}'" - if params_list.any? + if params_list.except(:forum).any? text = "Search results in #{text} (#{@threads.length})" else text = text.capitalize @@ -26,21 +26,21 @@ <%= form_tag(forumthreads_path, method: :get) do %> <%= text_field_tag "query", params[:query], placeholder: "Search...", class: "searchfield field" %> <%= submit_tag "Go", class: "searchfield btn" %> - <% params.slice(:title, :content, :reply, :label, :author).each do |key, value| %> + <%= link_to "Advanced Search", search_forumthreads_path(params_list), class: "btn right blue" %> + <% if params_list.any? %> + <% if params[:forum] %> + <%= link_to "Show All Threads", forumthreads_path(params_list.except("forum")), class: "btn right blue" %> + <% elsif params_list.except(:controller, :action).any? %> + <%= link_to "Show All Threads", forumthreads_path, class: "btn right blue" %> + <% end %> + <% end %> + <% if params[:forum] %> + <%= link_to "Go to Forum", forum_path(params[:forum]), class: "btn right blue" %> + <% end %> + <% params.slice(:forum, :title, :content, :reply, :label, :author).each do |key, value| %> <%= hidden_field_tag key, params[key] %> <% end %> <% end %> -<%= link_to "Advanced Search", search_forumthreads_path(params_list), class: "btn right blue" %> -<% if params_list.any? %> - <% if params[:forum] %> - <%= link_to "Show All Threads", forumthreads_path(params_list.except("forum")), class: "btn right blue" %> - <% elsif params_list.except(:controller, :action).any? %> - <%= link_to "Show All Threads", forumthreads_path, class: "btn right blue" %> - <% end %> -<% end %> -<% if params[:forum] %> - <%= link_to "Go to Forum", forum_path(params[:forum]), class: "btn right blue" %> -<% end %>
    <% @threads.each do |thread| %> -- 2.52.0 From 5e4e6583bba289f4c8cc1bd4e4da7d772a8423d9 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 18 Jun 2017 18:54:50 +0200 Subject: [PATCH 080/214] Added action_caching gem to Gemfile.lock --- Gemfile.lock | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index 1e638b9..c04ca64 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,6 +14,14 @@ GIT railties (>= 3.2.0) sass-rails (>= 3.2.0) +GIT + remote: git://github.com/antulik/actionpack-action_caching.git + revision: 8c6e52c69315d67437f480da5dce4b7c8737fb32 + ref: 8c6e52c69315d67437f480da5dce4b7c8737fb32 + specs: + actionpack-action_caching (1.2.0) + actionpack (>= 4.0.0, < 6) + GIT remote: git://github.com/jomo/kaminari.git revision: e49066e94d77a6abb03a0819f3c4b0cc6923cb70 @@ -223,6 +231,7 @@ PLATFORMS ruby DEPENDENCIES + actionpack-action_caching! activerecord-session_store bcrypt better_errors -- 2.52.0 From bcc1f192f5e4a3af5f0bd5384c21101fbeed8674 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 18 Jun 2017 22:44:03 +0200 Subject: [PATCH 081/214] Added warning for replies on closed threads --- app/views/threadreplies/_new.html.erb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/threadreplies/_new.html.erb b/app/views/threadreplies/_new.html.erb index d1fc7d2..c22463d 100644 --- a/app/views/threadreplies/_new.html.erb +++ b/app/views/threadreplies/_new.html.erb @@ -2,8 +2,10 @@ <%= render partial: "md_editor", locals: {name: "threadreply[content]", content: reply.content} %> <% nec_msg = "" %> <% forum = Forum.find(reply.thread.forum_id) %> - <% if forum.necro_length != nil %> - <% if Threadreply.where(forumthread: reply.thread).any? %> + <% if forum.necro_length %> + <% if reply.thread.label.try(:name).try(:downcase) == "closed" %> + <% nec_msg = "This thread is closed. Are you sure you want to make this reply? If so, press 'Ok'" %> + <% elsif Threadreply.where(forumthread: reply.thread).any? %> <% prevAgo = Threadreply.where(forumthread: reply.thread).order(:id).last.created_at %> <% if prevAgo <= forum.necro_length.days.ago.utc %> <% nec_msg = "You may be necroposting, as the last reply was made at least #{forum.necro_length} days ago. If you still wish to make this reply, press 'Ok'." %> -- 2.52.0 From 8dc051ea46ba46c0e2798495f40bfa3e2bb83074 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Tue, 20 Jun 2017 16:22:56 +0200 Subject: [PATCH 082/214] Added ban reason and expiration date to user pages --- app/controllers/users_controller.rb | 2 ++ app/views/users/show.html.erb | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5dc0e80..702d1e3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -30,6 +30,8 @@ class UsersController < ApplicationController end def show + user = User.find(params[:id]) + @ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"] == user.uuid} end # SIGNUP diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index e371a09..eb14575 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -15,11 +15,12 @@

    <%= @user.name %>

    - - <% if @user.banned? %> - This user is banned! + <% if @ban_json %> + This used is banned for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%> + <% elsif @user.banned? %> + This user is banned! <% end %> - +
    <% if !@user.confirmed? %> <% if @user.is?(current_user) || mod? %> Please confirm your email <%= @user.email %> ! -- 2.52.0 From 1ec464a4fce8db1e7f33706136639376f588632d Mon Sep 17 00:00:00 2001 From: MrYummy Date: Wed, 21 Jun 2017 01:19:02 +0200 Subject: [PATCH 083/214] utilized @user variable --- app/controllers/users_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 702d1e3..e188d01 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -30,8 +30,7 @@ class UsersController < ApplicationController end def show - user = User.find(params[:id]) - @ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"] == user.uuid} + @ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"] == @user.uuid} end # SIGNUP -- 2.52.0 From 43cee7d2e0a6b366ed5e2b195c71aa350e14c8e4 Mon Sep 17 00:00:00 2001 From: jomo Date: Mon, 3 Jul 2017 02:03:16 +0200 Subject: [PATCH 084/214] only link to badge if badge exists --- app/views/users/_username.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/users/_username.html.erb b/app/views/users/_username.html.erb index 724e921..6dfa0dd 100644 --- a/app/views/users/_username.html.erb +++ b/app/views/users/_username.html.erb @@ -1,4 +1,6 @@
    <%= link_to user.name, user, class: "role #{user.role.name} #{"banned" if user.banned?} #{"disabled" if user.disabled?} #{"unconfirmed" unless user.confirmed?}", title: "#{user.ign} – #{user.role}", style: "color: #{fcolor(user.role.color)}; background-color: #{user.role.color}" %> - <%= link_to user.badge.symbol, users_path(badge: user.badge.name), class: "role badge", title: user.badge.name, style: "color: #{fcolor(user.badge.color)}; background-color: #{user.badge.color}" unless user.badge.symbol.blank? %> + <% if user.badge + <%= link_to user.badge.symbol, users_path(badge: user.badge.name), class: "role badge", title: user.badge.name, style: "color: #{fcolor(user.badge.color)}; background-color: #{user.badge.color}" unless user.badge.symbol.blank? %> + <% end %>
    -- 2.52.0 From b84db2bc87c45bd58c746a388d4fd6bafb7ac8e8 Mon Sep 17 00:00:00 2001 From: jomo Date: Mon, 3 Jul 2017 02:03:55 +0200 Subject: [PATCH 085/214] fix typo --- app/views/users/_username.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_username.html.erb b/app/views/users/_username.html.erb index 6dfa0dd..1220995 100644 --- a/app/views/users/_username.html.erb +++ b/app/views/users/_username.html.erb @@ -1,6 +1,6 @@
    <%= link_to user.name, user, class: "role #{user.role.name} #{"banned" if user.banned?} #{"disabled" if user.disabled?} #{"unconfirmed" unless user.confirmed?}", title: "#{user.ign} – #{user.role}", style: "color: #{fcolor(user.role.color)}; background-color: #{user.role.color}" %> - <% if user.badge + <% if user.badge %> <%= link_to user.badge.symbol, users_path(badge: user.badge.name), class: "role badge", title: user.badge.name, style: "color: #{fcolor(user.badge.color)}; background-color: #{user.badge.color}" unless user.badge.symbol.blank? %> <% end %>
    -- 2.52.0 From b225dc57b2b06aee10ec9f7d0da11b9ca29f3fb0 Mon Sep 17 00:00:00 2001 From: jomo Date: Mon, 3 Jul 2017 02:47:51 +0200 Subject: [PATCH 086/214] add index forumthread_id on threadreplies --- ...d_index_forumthread_id_on_threadreplies.rb | 5 ++ db/schema.rb | 78 ++++++++++--------- 2 files changed, 46 insertions(+), 37 deletions(-) create mode 100644 db/migrate/20170703003647_add_index_forumthread_id_on_threadreplies.rb diff --git a/db/migrate/20170703003647_add_index_forumthread_id_on_threadreplies.rb b/db/migrate/20170703003647_add_index_forumthread_id_on_threadreplies.rb new file mode 100644 index 0000000..ca08f5c --- /dev/null +++ b/db/migrate/20170703003647_add_index_forumthread_id_on_threadreplies.rb @@ -0,0 +1,5 @@ +class AddIndexForumthreadIdOnThreadreplies < ActiveRecord::Migration + def change + add_index :threadreplies, :forumthread_id + end +end diff --git a/db/schema.rb b/db/schema.rb index f2d73de..5849cf5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,17 +11,18 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170522210610) do +ActiveRecord::Schema.define(version: 20170703003647) do create_table "badges", force: :cascade do |t| - t.string "name", limit: 191 - t.string "symbol", limit: 191 - t.string "color", limit: 191 + t.string "name", limit: 191 + t.string "symbol", limit: 191 + t.string "color", limit: 191 + t.integer "value", limit: 4 end create_table "blogposts", force: :cascade do |t| - t.string "title", limit: 191 - t.text "content", limit: 65535 + t.string "title", limit: 255 + t.text "content", limit: 16777215 t.integer "user_author_id", limit: 4 t.integer "user_editor_id", limit: 4 t.datetime "created_at" @@ -29,7 +30,7 @@ ActiveRecord::Schema.define(version: 20170522210610) do end create_table "comments", force: :cascade do |t| - t.text "content", limit: 65535 + t.text "content", limit: 16777215 t.integer "user_author_id", limit: 4 t.integer "user_editor_id", limit: 4 t.integer "blogpost_id", limit: 4 @@ -38,14 +39,14 @@ ActiveRecord::Schema.define(version: 20170522210610) do end create_table "forumgroups", force: :cascade do |t| - t.string "name", limit: 191 + t.string "name", limit: 255 t.integer "position", limit: 4 t.integer "role_read_id", limit: 4 t.integer "role_write_id", limit: 4 end create_table "forums", force: :cascade do |t| - t.string "name", limit: 191 + t.string "name", limit: 255 t.integer "position", limit: 4 t.integer "role_read_id", limit: 4 t.integer "role_write_id", limit: 4 @@ -59,10 +60,10 @@ ActiveRecord::Schema.define(version: 20170522210610) do end create_table "forumthreads", force: :cascade do |t| - t.string "title", limit: 191 - t.text "content", limit: 65535 - t.boolean "sticky", default: false - t.boolean "locked", default: false + t.string "title", limit: 255 + t.text "content", limit: 16777215 + t.boolean "sticky", default: false + t.boolean "locked", default: false t.integer "user_author_id", limit: 4 t.integer "user_editor_id", limit: 4 t.integer "forum_id", limit: 4 @@ -72,47 +73,49 @@ ActiveRecord::Schema.define(version: 20170522210610) do end add_index "forumthreads", ["content"], name: "index_forumthreads_on_content", type: :fulltext + add_index "forumthreads", ["title", "content"], name: "forumthreads_title_content", type: :fulltext add_index "forumthreads", ["title", "content"], name: "index_forumthreads_on_title_and_content", type: :fulltext add_index "forumthreads", ["title"], name: "index_forumthreads_on_title", type: :fulltext create_table "info", force: :cascade do |t| - t.string "title", limit: 191 - t.text "content", limit: 65535 + t.string "title", limit: 255 + t.text "content", limit: 16777215 t.datetime "created_at" t.datetime "updated_at" end create_table "labels", force: :cascade do |t| - t.string "name", limit: 191 - t.string "color", limit: 191 + t.string "name", limit: 255 + t.string "color", limit: 255 end create_table "register_tokens", force: :cascade do |t| - t.string "uuid", limit: 191, null: false - t.string "token", limit: 191, null: false - t.string "email", limit: 191, null: false + t.string "uuid", limit: 32, null: false + t.string "token", limit: 6, null: false + t.string "email", limit: 191 end + add_index "register_tokens", ["email"], name: "index_register_tokens_on_email", unique: true, using: :btree add_index "register_tokens", ["uuid"], name: "index_register_tokens_on_uuid", unique: true, using: :btree create_table "roles", force: :cascade do |t| - t.string "name", limit: 191 + t.string "name", limit: 255 t.integer "value", limit: 4 - t.string "color", limit: 191 + t.string "color", limit: 255 end create_table "sessions", force: :cascade do |t| - t.string "session_id", limit: 191, null: false - t.text "data", limit: 65535 + t.string "session_id", limit: 255, null: false + t.text "data", limit: 16777215 t.datetime "created_at" t.datetime "updated_at" end - add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree + add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", length: {"session_id"=>191}, using: :btree add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree create_table "threadreplies", force: :cascade do |t| - t.text "content", limit: 65535 + t.text "content", limit: 16777215 t.integer "user_author_id", limit: 4 t.integer "user_editor_id", limit: 4 t.integer "forumthread_id", limit: 4 @@ -121,21 +124,22 @@ ActiveRecord::Schema.define(version: 20170522210610) do end add_index "threadreplies", ["content"], name: "index_threadreplies_on_content", type: :fulltext + add_index "threadreplies", ["forumthread_id"], name: "index_threadreplies_on_forumthread_id", using: :btree create_table "users", force: :cascade do |t| - t.string "uuid", limit: 191, null: false - t.string "name", limit: 191, null: false - t.string "password_digest", limit: 191, null: false - t.string "ign", limit: 191, null: false - t.string "email", limit: 191, null: false + t.string "uuid", limit: 255, null: false + t.string "name", limit: 191 + t.string "password_digest", limit: 255, null: false + t.string "ign", limit: 255, null: false + t.string "email", limit: 191 t.text "about", limit: 65535 - t.string "last_ip", limit: 191 - t.string "skype", limit: 191 + t.string "last_ip", limit: 255 + t.string "skype", limit: 255 t.boolean "skype_public", default: false - t.string "youtube", limit: 191 - t.string "youtube_channelname", limit: 191 - t.string "twitter", limit: 191 - t.string "email_token", limit: 191 + t.string "youtube", limit: 255 + t.string "youtube_channelname", limit: 255 + t.string "twitter", limit: 255 + t.string "email_token", limit: 255 t.boolean "confirmed", default: false t.datetime "last_seen" t.integer "role_id", limit: 4, null: false -- 2.52.0 From 496e08393a5cc737fc82931fcb41aed53d61dfe7 Mon Sep 17 00:00:00 2001 From: jomo Date: Mon, 3 Jul 2017 03:05:10 +0200 Subject: [PATCH 087/214] fix user search --- app/models/user.rb | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index d755646..3743136 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -174,23 +174,19 @@ class User < ActiveRecord::Base def set_email_token self.email_token ||= SecureRandom.hex(16) end - + def self.search (search, role, badge, staff) + users = User.joins(:role) if role - if staff - users = User.joins(:role).where("roles.value >= ?", Role.get(:mod).to_i) - else - users = User.joins(:role).where(role: role) - end + users = staff ? users.where("roles.value >= ?", Role.get(:mod).to_i) : users.where(role: role) end - if badge - users = User.joins(:badge).where(badge: badge) - else - users = User.joins(:role).all.where.not(id: User.first.id) + users = users.where(badge: badge) if badge + if search + search_san = User.send(:sanitize_sql_like, search.to_s) + users = users.where("users.name like ? OR ign like ?", "%#{search_san}%", "%#{search_san}%") end - search_san = User.send(:sanitize_sql_like, search.to_s) - users = users.where("users.name like ? OR ign like ?", "%#{search_san}%", "%#{search_san}%") - users = users.order("roles.value desc", "confirmed desc", :name) unless badge + users = users.where.not(id: User.first.id) unless [search, role, badge].any? + users = users.order("roles.value desc", "confirmed desc", :name) users end end -- 2.52.0 From fcdcbe2514b0d1c95ba653e44321bdd41cdf4d32 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 2 Jul 2017 21:13:43 -0400 Subject: [PATCH 088/214] fixed issue with ?staff --- app/models/user.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 3743136..07a02ea 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -178,7 +178,9 @@ class User < ActiveRecord::Base def self.search (search, role, badge, staff) users = User.joins(:role) if role - users = staff ? users.where("roles.value >= ?", Role.get(:mod).to_i) : users.where(role: role) + users = users.where(role: role) + elsif staff + users.where("roles.value >= ?", Role.get(:mod).to_i) end users = users.where(badge: badge) if badge if search -- 2.52.0 From a8ffba8f8b2b6fd0146c3705138f8c721cbea6f2 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 2 Jul 2017 21:15:55 -0400 Subject: [PATCH 089/214] fixed issue with ?staff part 2 --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 07a02ea..b996978 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -180,7 +180,7 @@ class User < ActiveRecord::Base if role users = users.where(role: role) elsif staff - users.where("roles.value >= ?", Role.get(:mod).to_i) + users = users.where("roles.value >= ?", Role.get(:mod).to_i) end users = users.where(badge: badge) if badge if search -- 2.52.0 From 12fb7584bc6782b92802ac9a75fd80fe7cf1043f Mon Sep 17 00:00:00 2001 From: jomo Date: Mon, 3 Jul 2017 03:17:27 +0200 Subject: [PATCH 090/214] allow staff search with empty parameter value --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index dd12a98..3d49591 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -10,7 +10,7 @@ class UsersController < ApplicationController role = Role.find_by(name: params[:role]) badge = Badge.find_by(name: params[:badge]) - @users = User.search(params[:search], role, badge, params[:staff]) + @users = User.search(params[:search], role, badge, params.include?(:staff)) @count = @users.size @users = @users.page(params[:page]).per(100) end -- 2.52.0 From 170fba42dbceeed52a7335fedb4696fa978e9cbe Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 2 Jul 2017 21:21:19 -0400 Subject: [PATCH 091/214] Added "All staff" as title when doing user filter --- app/views/users/index.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 05e9249..74f65e5 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -12,6 +12,8 @@ text = "All '#{params[:badge]}' users" elsif params[:role] && params[:badge] text = "All '#{params[:role]}' and '#{params[:badge]}' users" + elsif params.include?(:staff) + text = "All staff" else text = "All users" end -- 2.52.0 From 9b64c2c6d926c4debec7477b0d042ad076bec391 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 2 Jul 2017 23:23:24 -0400 Subject: [PATCH 092/214] Thread index now counts all threads on all pages --- app/views/forumthreads/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/forumthreads/index.html.erb b/app/views/forumthreads/index.html.erb index 18b9ef4..bd68e29 100644 --- a/app/views/forumthreads/index.html.erb +++ b/app/views/forumthreads/index.html.erb @@ -10,7 +10,7 @@ if params[:forum] text = "forum '#{Forum.find(params[:forum]).name}'" if params_list.except(:forum).any? - text = "Search results in #{text} (#{@threads.length})" + text = "Search results in #{text} (#{@threads.total_count})" else text = text.capitalize end -- 2.52.0 From f90257fe73dbfee7e7796025345d126a45bac376 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Tue, 4 Jul 2017 09:23:01 -0400 Subject: [PATCH 093/214] Explicitly stated order of threadreplies --- app/controllers/forumthreads_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index 81d420a..a5e3d6d 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -12,9 +12,9 @@ class ForumthreadsController < ApplicationController end def show if params[:reverse] == "true" - @replies = @thread.replies.reverse_order.page(params[:page]) + @replies = @thread.replies.order(created_at: :desc).page(params[:page]) else - @replies = @thread.replies.page(params[:page]) + @replies = @thread.replies.order(:created_at).page(params[:page]) end end -- 2.52.0 From 4e1b6b430b58c1f6191af89f55c5c498e7a65e6d Mon Sep 17 00:00:00 2001 From: MrYummy Date: Tue, 4 Jul 2017 22:57:31 +0200 Subject: [PATCH 094/214] limited params in params_list to the 6 queries --- app/views/forumthreads/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/forumthreads/index.html.erb b/app/views/forumthreads/index.html.erb index bd68e29..02e425b 100644 --- a/app/views/forumthreads/index.html.erb +++ b/app/views/forumthreads/index.html.erb @@ -1,5 +1,5 @@ <%= link_to "Forums", forums_path %> → -<% params_list = params.except(:controller, :action) %> +<% params_list = params.slice(:query, :title, :content, :author, :label, :reply) %> <% if params_list.any? %> <%= link_to "All Threads", forumthreads_path %> → Search Results <% else %> -- 2.52.0 From 72a6dcc54ad64d1168fbab7bb3d9cd663cc3b012 Mon Sep 17 00:00:00 2001 From: jomo Date: Fri, 7 Jul 2017 01:57:30 +0200 Subject: [PATCH 095/214] order by id instead of created_at id is indexed while created_at is not --- app/controllers/blogposts_controller.rb | 2 +- app/controllers/forumthreads_controller.rb | 4 ++-- app/models/forumthread.rb | 2 +- app/views/forums/index.html.erb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/blogposts_controller.rb b/app/controllers/blogposts_controller.rb index 7a9851d..1ff310d 100644 --- a/app/controllers/blogposts_controller.rb +++ b/app/controllers/blogposts_controller.rb @@ -4,7 +4,7 @@ class BlogpostsController < ApplicationController before_filter :auth, except: [:index, :show] def index - @posts = Blogpost.order("created_at desc").page(params[:page]).per(10) + @posts = Blogpost.order(id: :desc).page(params[:page]).per(10) end def show diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index a5e3d6d..d40ce58 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -12,9 +12,9 @@ class ForumthreadsController < ApplicationController end def show if params[:reverse] == "true" - @replies = @thread.replies.order(created_at: :desc).page(params[:page]) + @replies = @thread.replies.order(id: :desc).page(params[:page]) else - @replies = @thread.replies.order(:created_at).page(params[:page]) + @replies = @thread.replies.order(:id).page(params[:page]) end end diff --git a/app/models/forumthread.rb b/app/models/forumthread.rb index f8efe97..fd8d3c1 100644 --- a/app/models/forumthread.rb +++ b/app/models/forumthread.rb @@ -106,7 +106,7 @@ class Forumthread < ActiveRecord::Base if order_phrase.present? threads = threads.order("GREATEST(relevance, reply_rel) DESC") else - threads = threads.order("sticky desc", "threadreplies.created_at DESC", "forumthreads.created_at DESC") + threads = threads.order("sticky DESC", "threadreplies.id DESC", "forumthreads.id DESC") end threads end diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index 532484b..a30730a 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -18,7 +18,7 @@ <%= link_to f.name, f, id: "forum-#{f.id}"%>
    <% if last_thread = f.threads.last %> - <% last_reply = Threadreply.where(forumthread: f.threads).order(:created_at).last %> + <% last_reply = Threadreply.where(forumthread: f.threads).order(:id).last %> <% if last_reply && last_reply.created_at > last_thread.created_at %> <% if last_reply.thread.can_read?(current_user) %> <%= last_reply.author.name %> -- 2.52.0 From 8c6eb8ac17de84ebd34bb26652889b4c93b7e75a Mon Sep 17 00:00:00 2001 From: jomo Date: Fri, 7 Jul 2017 02:05:04 +0200 Subject: [PATCH 096/214] more fixes for order of threadreplies --- app/controllers/forums_controller.rb | 2 +- app/controllers/threadreplies_controller.rb | 2 +- app/views/forums/show.html.erb | 2 +- app/views/forumthreads/index.html.erb | 2 +- app/views/threadreplies/edit.html.erb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 761a86b..206f01f 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -11,7 +11,7 @@ class ForumsController < ApplicationController @threads = @forum.forumthreads.select {|f| f.can_read?(current_user) }.to_a @threads.sort_by! do |t| # sticky goes first, then sort by last activity (new replies) - [t.sticky ? 0 : 1, -(t.replies.last.try(:created_at) || t.created_at).to_i] + [t.sticky ? 0 : 1, -(t.replies.order(:id).last.try(:created_at) || t.created_at).to_i] end @threads = Kaminari.paginate_array(@threads).page(params[:page]) end diff --git a/app/controllers/threadreplies_controller.rb b/app/controllers/threadreplies_controller.rb index 946155d..a801fbc 100644 --- a/app/controllers/threadreplies_controller.rb +++ b/app/controllers/threadreplies_controller.rb @@ -37,7 +37,7 @@ class ThreadrepliesController < ApplicationController if @reply.update_attributes(reply_params) @reply.send_new_reply_mail(old_content) flash[:notice] = "Reply updated!" - position = @reply.thread.replies.index(@reply) + position = @reply.thread.replies.order(:id).index(@reply) page = position / Kaminari.config.default_per_page + 1 redirect_to forumthread_path(@reply.thread, page: page) + "#reply-#{@reply.id}" else diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index b232292..cfe3918 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -38,7 +38,7 @@
    "> <%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %>
    - <% if rpl = thread.replies.last %> + <% if rpl = thread.replies.order(:id).last %> <%= rpl.author.name %> <% position = thread.replies.count - 1 diff --git a/app/views/forumthreads/index.html.erb b/app/views/forumthreads/index.html.erb index 02e425b..0c44352 100644 --- a/app/views/forumthreads/index.html.erb +++ b/app/views/forumthreads/index.html.erb @@ -60,7 +60,7 @@
    "> <%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %>
    - <% if rpl = thread.replies.last %> + <% if rpl = thread.replies.order(:id).last %> <%= rpl.author.name %> <% position = thread.replies.count - 1 diff --git a/app/views/threadreplies/edit.html.erb b/app/views/threadreplies/edit.html.erb index c009cb0..8296d9c 100644 --- a/app/views/threadreplies/edit.html.erb +++ b/app/views/threadreplies/edit.html.erb @@ -1,7 +1,7 @@ <% title "Edit Thread Reply: #{@reply.thread.title}" %> <% - position = @reply.thread.replies.index(@reply) + position = @reply.thread.replies.order(:id).index(@reply) page = position / Kaminari.config.default_per_page + 1 %> -- 2.52.0 From 2819989b72a38e30192cd57661bde89bc1ebfc7c Mon Sep 17 00:00:00 2001 From: MrYummy Date: Thu, 6 Jul 2017 20:08:48 -0400 Subject: [PATCH 097/214] Added total_count to thread result number (pt. 2) --- app/views/forumthreads/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/forumthreads/index.html.erb b/app/views/forumthreads/index.html.erb index 0c44352..5c3f97d 100644 --- a/app/views/forumthreads/index.html.erb +++ b/app/views/forumthreads/index.html.erb @@ -15,7 +15,7 @@ text = text.capitalize end elsif params_list.any? - text = "Search results (#{@threads.length})" + text = "Search results (#{@threads.total_count})" else text = "All threads" end -- 2.52.0 From 767084cc2f8dfba9a30a40ca12228794a427443f Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sat, 8 Jul 2017 03:23:09 +0200 Subject: [PATCH 098/214] removed skype_public column from users --- app/controllers/users_controller.rb | 4 +- app/views/users/edit.html.erb | 6 -- app/views/users/show.html.erb | 2 +- ...1014_remove_skype_visibility_from_users.rb | 6 ++ db/schema.rb | 74 +++++++++---------- 5 files changed, 44 insertions(+), 48 deletions(-) create mode 100644 db/migrate/20170708011014_remove_skype_visibility_from_users.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3d49591..c660655 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -137,9 +137,9 @@ class UsersController < ApplicationController def update if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?) if mod? - userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about, :role, :badge, :confirmed, :header_scroll, :utc_time, :dark]) + userdata = user_params([:name, :skype, :youtube, :twitter, :about, :role, :badge, :confirmed, :header_scroll, :utc_time, :dark]) else - userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about, :header_scroll, :utc_time, :dark]) + userdata = user_params([:name, :skype, :youtube, :twitter, :about, :header_scroll, :utc_time, :dark]) end if userdata[:role] role = Role.get(userdata[:role]) diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 133a69d..abd1fa4 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -48,12 +48,6 @@ <%= f.text_field :skype, placeholder: "Skype username", disabled: !can_edit? %>

    - - - - - <% if current_user && !@user.skype.blank? && (@user.skype_public || current_user == @user || mod?) %> + <% if current_user && !@user.skype.blank? %> diff --git a/db/migrate/20170708011014_remove_skype_visibility_from_users.rb b/db/migrate/20170708011014_remove_skype_visibility_from_users.rb new file mode 100644 index 0000000..92a9482 --- /dev/null +++ b/db/migrate/20170708011014_remove_skype_visibility_from_users.rb @@ -0,0 +1,6 @@ +class RemoveSkypeVisibilityFromUsers < ActiveRecord::Migration + def change + remove_column :users, :skype_public + User.update_all skype: nil + end +end diff --git a/db/schema.rb b/db/schema.rb index 5849cf5..9312bee 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,18 +11,17 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170703003647) do +ActiveRecord::Schema.define(version: 20170708011014) do create_table "badges", force: :cascade do |t| - t.string "name", limit: 191 - t.string "symbol", limit: 191 - t.string "color", limit: 191 - t.integer "value", limit: 4 + t.string "name", limit: 191 + t.string "symbol", limit: 191 + t.string "color", limit: 191 end create_table "blogposts", force: :cascade do |t| - t.string "title", limit: 255 - t.text "content", limit: 16777215 + t.string "title", limit: 191 + t.text "content", limit: 65535 t.integer "user_author_id", limit: 4 t.integer "user_editor_id", limit: 4 t.datetime "created_at" @@ -30,7 +29,7 @@ ActiveRecord::Schema.define(version: 20170703003647) do end create_table "comments", force: :cascade do |t| - t.text "content", limit: 16777215 + t.text "content", limit: 65535 t.integer "user_author_id", limit: 4 t.integer "user_editor_id", limit: 4 t.integer "blogpost_id", limit: 4 @@ -39,14 +38,14 @@ ActiveRecord::Schema.define(version: 20170703003647) do end create_table "forumgroups", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name", limit: 191 t.integer "position", limit: 4 t.integer "role_read_id", limit: 4 t.integer "role_write_id", limit: 4 end create_table "forums", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name", limit: 191 t.integer "position", limit: 4 t.integer "role_read_id", limit: 4 t.integer "role_write_id", limit: 4 @@ -60,10 +59,10 @@ ActiveRecord::Schema.define(version: 20170703003647) do end create_table "forumthreads", force: :cascade do |t| - t.string "title", limit: 255 - t.text "content", limit: 16777215 - t.boolean "sticky", default: false - t.boolean "locked", default: false + t.string "title", limit: 191 + t.text "content", limit: 65535 + t.boolean "sticky", default: false + t.boolean "locked", default: false t.integer "user_author_id", limit: 4 t.integer "user_editor_id", limit: 4 t.integer "forum_id", limit: 4 @@ -73,49 +72,47 @@ ActiveRecord::Schema.define(version: 20170703003647) do end add_index "forumthreads", ["content"], name: "index_forumthreads_on_content", type: :fulltext - add_index "forumthreads", ["title", "content"], name: "forumthreads_title_content", type: :fulltext add_index "forumthreads", ["title", "content"], name: "index_forumthreads_on_title_and_content", type: :fulltext add_index "forumthreads", ["title"], name: "index_forumthreads_on_title", type: :fulltext create_table "info", force: :cascade do |t| - t.string "title", limit: 255 - t.text "content", limit: 16777215 + t.string "title", limit: 191 + t.text "content", limit: 65535 t.datetime "created_at" t.datetime "updated_at" end create_table "labels", force: :cascade do |t| - t.string "name", limit: 255 - t.string "color", limit: 255 + t.string "name", limit: 191 + t.string "color", limit: 191 end create_table "register_tokens", force: :cascade do |t| t.string "uuid", limit: 32, null: false t.string "token", limit: 6, null: false - t.string "email", limit: 191 + t.string "email", limit: 191, null: false end - add_index "register_tokens", ["email"], name: "index_register_tokens_on_email", unique: true, using: :btree add_index "register_tokens", ["uuid"], name: "index_register_tokens_on_uuid", unique: true, using: :btree create_table "roles", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name", limit: 191 t.integer "value", limit: 4 - t.string "color", limit: 255 + t.string "color", limit: 191 end create_table "sessions", force: :cascade do |t| - t.string "session_id", limit: 255, null: false - t.text "data", limit: 16777215 + t.string "session_id", limit: 191, null: false + t.text "data", limit: 65535 t.datetime "created_at" t.datetime "updated_at" end - add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", length: {"session_id"=>191}, using: :btree + add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree create_table "threadreplies", force: :cascade do |t| - t.text "content", limit: 16777215 + t.text "content", limit: 65535 t.integer "user_author_id", limit: 4 t.integer "user_editor_id", limit: 4 t.integer "forumthread_id", limit: 4 @@ -127,19 +124,18 @@ ActiveRecord::Schema.define(version: 20170703003647) do add_index "threadreplies", ["forumthread_id"], name: "index_threadreplies_on_forumthread_id", using: :btree create_table "users", force: :cascade do |t| - t.string "uuid", limit: 255, null: false + t.string "uuid", limit: 191, null: false t.string "name", limit: 191 - t.string "password_digest", limit: 255, null: false - t.string "ign", limit: 255, null: false - t.string "email", limit: 191 + t.string "password_digest", limit: 191, null: false + t.string "ign", limit: 191, null: false + t.string "email", limit: 191, null: false t.text "about", limit: 65535 - t.string "last_ip", limit: 255 - t.string "skype", limit: 255 - t.boolean "skype_public", default: false - t.string "youtube", limit: 255 - t.string "youtube_channelname", limit: 255 - t.string "twitter", limit: 255 - t.string "email_token", limit: 255 + t.string "last_ip", limit: 191 + t.string "skype", limit: 191 + t.string "youtube", limit: 191 + t.string "youtube_channelname", limit: 191 + t.string "twitter", limit: 191 + t.string "email_token", limit: 191 t.boolean "confirmed", default: false t.datetime "last_seen" t.integer "role_id", limit: 4, null: false @@ -150,7 +146,7 @@ ActiveRecord::Schema.define(version: 20170703003647) do t.boolean "mail_own_blogpost_comment", default: true t.boolean "mail_other_blogpost_comment", default: true t.boolean "mail_mention", default: true - t.integer "badge_id", limit: 4, default: 0 + t.integer "badge_id", limit: 4, default: 1 t.boolean "utc_time", default: false t.boolean "header_scroll", default: false t.boolean "dark", default: false -- 2.52.0 From 5f17385343a357ab8beb2546bd7eee55b1e84567 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Tue, 11 Jul 2017 03:59:19 +0200 Subject: [PATCH 099/214] Fixed error when a user sets their name to that of another --- app/controllers/users_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3d49591..315b767 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -141,6 +141,11 @@ class UsersController < ApplicationController else userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about, :header_scroll, :utc_time, :dark]) end + if User.find_by(name: userdata[:name]) + flash[:alert] = "You have entered a name that belongs to someone else. Please try another." + redirect_to edit_user_path(@user) + return + end if userdata[:role] role = Role.get(userdata[:role]) if role && role <= current_user.role -- 2.52.0 From 6aee102114b35c5844ad53b5037ac59e9e90bf8a Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Mon, 31 Jul 2017 15:41:37 -0400 Subject: [PATCH 100/214] Fixed list of donators link not including donorplus badge. --- app/controllers/users_controller.rb | 2 +- app/models/user.rb | 4 +++- app/views/statics/donate.html.erb | 2 +- app/views/users/index.html.erb | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 315b767..5efed4d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -10,7 +10,7 @@ class UsersController < ApplicationController role = Role.find_by(name: params[:role]) badge = Badge.find_by(name: params[:badge]) - @users = User.search(params[:search], role, badge, params.include?(:staff)) + @users = User.search(params[:search], role, badge, params.include?(:staff), params.include?(:donor)) @count = @users.size @users = @users.page(params[:page]).per(100) end diff --git a/app/models/user.rb b/app/models/user.rb index b996978..14364ed 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -175,12 +175,14 @@ class User < ActiveRecord::Base self.email_token ||= SecureRandom.hex(16) end - def self.search (search, role, badge, staff) + def self.search (search, role, badge, staff, donor) users = User.joins(:role) if role users = users.where(role: role) elsif staff users = users.where("roles.value >= ?", Role.get(:mod).to_i) + elsif donor + users = users.where("badge_id = ? OR badge_id = ?", Badge.get(:donor), Badge.get(:donorplus)) end users = users.where(badge: badge) if badge if search diff --git a/app/views/statics/donate.html.erb b/app/views/statics/donate.html.erb index 2ca7114..ce29832 100644 --- a/app/views/statics/donate.html.erb +++ b/app/views/statics/donate.html.erb @@ -11,7 +11,7 @@
  • Donator+ ($20 or more) -

    We also have <%= link_to "list of users who donated", users_path(badge: "donor") %> already!

    +

    We also have <%= link_to "list of users who donated", users_path(donor: "") %> already!

    Perks for you

    For Donator and Donator+

    diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 74f65e5..a8888db 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -14,6 +14,8 @@ text = "All '#{params[:role]}' and '#{params[:badge]}' users" elsif params.include?(:staff) text = "All staff" + elsif params.include?(:donor) + text = "All donors" else text = "All users" end -- 2.52.0 From faeba0ec702e75ed9f88e9a7fddc8c73ffcf3e3a Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Mon, 31 Jul 2017 16:04:23 -0400 Subject: [PATCH 101/214] Fixed grammar error. --- app/views/statics/donate.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/statics/donate.html.erb b/app/views/statics/donate.html.erb index ce29832..5111d0d 100644 --- a/app/views/statics/donate.html.erb +++ b/app/views/statics/donate.html.erb @@ -11,7 +11,7 @@
  • Donator+ ($20 or more) -

    We also have <%= link_to "list of users who donated", users_path(donor: "") %> already!

    +

    We also have a <%= link_to "list of users who donated", users_path(donor: "") %> already!

    Perks for you

    For Donator and Donator+

    -- 2.52.0 From e5e8caf38e6c97ccc83cebcf5278e9e757d94681 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Mon, 31 Jul 2017 19:24:39 -0400 Subject: [PATCH 102/214] Fixed staff link in emails going to wrong URL. --- app/views/redstoner_mailer/email_change_confirm_mail.html.erb | 4 ++-- app/views/redstoner_mailer/new_post_comment_mail.html.erb | 4 ++-- app/views/redstoner_mailer/new_post_mention_mail.html.erb | 4 ++-- app/views/redstoner_mailer/new_thread_mention_mail.html.erb | 4 ++-- app/views/redstoner_mailer/new_thread_reply_mail.html.erb | 4 ++-- app/views/redstoner_mailer/register_mail.html.erb | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/views/redstoner_mailer/email_change_confirm_mail.html.erb b/app/views/redstoner_mailer/email_change_confirm_mail.html.erb index 33e853a..37a5fbe 100644 --- a/app/views/redstoner_mailer/email_change_confirm_mail.html.erb +++ b/app/views/redstoner_mailer/email_change_confirm_mail.html.erb @@ -13,7 +13,7 @@

    -

    If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game.

    +

    If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(staff: ""), style: "text-decoration: none; color: #4096EE;" %> in-game.

    Your Redstoner team

    @@ -30,4 +30,4 @@

    - \ No newline at end of file + diff --git a/app/views/redstoner_mailer/new_post_comment_mail.html.erb b/app/views/redstoner_mailer/new_post_comment_mail.html.erb index 8936087..6726535 100644 --- a/app/views/redstoner_mailer/new_post_comment_mail.html.erb +++ b/app/views/redstoner_mailer/new_post_comment_mail.html.erb @@ -14,7 +14,7 @@ %>

    <%= link_to "Click here", blogpost_url(@comment.blogpost, page: page) + "#comment-#{@comment.id}", style: "text-decoration: none; color: #4096EE;" %> to view the blog post.

    -

    If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

    +

    If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(staff: ""), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

    Your Redstoner team

    @@ -29,4 +29,4 @@

    - \ No newline at end of file + diff --git a/app/views/redstoner_mailer/new_post_mention_mail.html.erb b/app/views/redstoner_mailer/new_post_mention_mail.html.erb index 5119e7c..aef3eef 100644 --- a/app/views/redstoner_mailer/new_post_mention_mail.html.erb +++ b/app/views/redstoner_mailer/new_post_mention_mail.html.erb @@ -10,7 +10,7 @@

    <%= link_to "Click here", blogpost_url(@post), style: "text-decoration: none; color: #4096EE;" %> to view the blog post.

    -

    If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

    +

    If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(staff: ""), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

    Your Redstoner team

    @@ -26,4 +26,4 @@

    - \ No newline at end of file + diff --git a/app/views/redstoner_mailer/new_thread_mention_mail.html.erb b/app/views/redstoner_mailer/new_thread_mention_mail.html.erb index 701901e..2aeaf0b 100644 --- a/app/views/redstoner_mailer/new_thread_mention_mail.html.erb +++ b/app/views/redstoner_mailer/new_thread_mention_mail.html.erb @@ -11,7 +11,7 @@

    <%= link_to "Click here", forumthread_url(@thread), style: "text-decoration: none; color: #4096EE;" %> to view the thread.

    -

    If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

    +

    If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(staff: ""), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

    Your Redstoner team

    @@ -28,4 +28,4 @@

    - \ No newline at end of file + diff --git a/app/views/redstoner_mailer/new_thread_reply_mail.html.erb b/app/views/redstoner_mailer/new_thread_reply_mail.html.erb index eadd4f9..4081f05 100644 --- a/app/views/redstoner_mailer/new_thread_reply_mail.html.erb +++ b/app/views/redstoner_mailer/new_thread_reply_mail.html.erb @@ -15,7 +15,7 @@ %>

    <%= link_to "Click here", forumthread_url(@reply.thread, page: page) + "#reply-#{@reply.id}", style: "text-decoration: none; color: #4096EE;" %> to view the thread.

    -

    If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

    +

    If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(staff: ""), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

    Your Redstoner team

    @@ -30,4 +30,4 @@ <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>

    - \ No newline at end of file + diff --git a/app/views/redstoner_mailer/register_mail.html.erb b/app/views/redstoner_mailer/register_mail.html.erb index 3e09a1e..35ccad9 100644 --- a/app/views/redstoner_mailer/register_mail.html.erb +++ b/app/views/redstoner_mailer/register_mail.html.erb @@ -25,7 +25,7 @@

    -

    If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game.

    +

    If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(staff: ""), style: "text-decoration: none; color: #4096EE;" %> in-game.

    Your Redstoner team

    @@ -42,4 +42,4 @@

    - \ No newline at end of file + -- 2.52.0 From bd85a2c3ae8e7b58691c23439189d1d34d67fa7f Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 6 Aug 2017 13:32:21 +0200 Subject: [PATCH 103/214] fixed spelling error --- app/views/users/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index eb14575..3d9dcfe 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -16,7 +16,7 @@
    <% if @ban_json %> - This used is banned for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%> + This user is banned for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%> <% elsif @user.banned? %> This user is banned! <% end %> -- 2.52.0 From 563aa376e3200c75f423e68dc7890724c3e5241b Mon Sep 17 00:00:00 2001 From: Minenash Date: Mon, 7 Aug 2017 18:19:47 -0400 Subject: [PATCH 104/214] Update donate.html.erb --- app/views/statics/donate.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/statics/donate.html.erb b/app/views/statics/donate.html.erb index 2ca7114..c01bc2f 100644 --- a/app/views/statics/donate.html.erb +++ b/app/views/statics/donate.html.erb @@ -25,11 +25,11 @@
    - " alt="sponsor's skin" class="body"> + sponsor's skin

    Donate to our server sponsor

    -

    They pay for our server, but prefer to stay anonymous

    +

    PotatoKek pays for the server hardware. You can help him by donating here

    <% if current_user %> -- 2.52.0 From 07b96a0c2dc39867eae88e845caf37db6cfb0a62 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Tue, 22 Aug 2017 16:11:43 -0400 Subject: [PATCH 105/214] Changed the who's playing JSON file path. --- app/controllers/statics_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/statics_controller.rb b/app/controllers/statics_controller.rb index 4b0c911..08dceef 100644 --- a/app/controllers/statics_controller.rb +++ b/app/controllers/statics_controller.rb @@ -17,7 +17,7 @@ class StaticsController < ApplicationController end def online - json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/JavaUtils/players.json")) + json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/ModuleLoader/players.json")) @players = json["players"].collect!{ |p| User.find_by(uuid: p["UUID"].tr("-", "")) or User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true) }.sort_by!(&:role).reverse! @count = json["amount"] end -- 2.52.0 From 291c4fb568f00229a3dae74f39425763c8bb10fc Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Wed, 11 Oct 2017 21:50:52 -0400 Subject: [PATCH 106/214] Fixed grammar error. --- app/views/statics/donate.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/statics/donate.html.erb b/app/views/statics/donate.html.erb index c01bc2f..be6ec1c 100644 --- a/app/views/statics/donate.html.erb +++ b/app/views/statics/donate.html.erb @@ -29,7 +29,7 @@

    Donate to our server sponsor

    -

    PotatoKek pays for the server hardware. You can help him by donating here

    +

    PotatoKek pays for the server hardware. You can help him by donating here.

    <% if current_user %> -- 2.52.0 From 908e67482c7816efcde842b50faa5255ee823a40 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Thu, 12 Oct 2017 17:22:02 -0400 Subject: [PATCH 107/214] Fixed the ability to receive reply emails on threads a user can no longer read. --- app/models/threadreply.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/threadreply.rb b/app/models/threadreply.rb index f285073..aca7770 100644 --- a/app/models/threadreply.rb +++ b/app/models/threadreply.rb @@ -43,7 +43,7 @@ class Threadreply < ActiveRecord::Base unless old_content.present? posts.each do |post| # don't send mail to the author of this reply, don't send to banned/disabled users - if post.author != author && post.author.normal? && post.author.confirmed? # && + if post.author != author && post.author.normal? && post.author.confirmed? && thread.can_read?(post.author) users << post.author if post.author.mail_other_thread_reply? end end -- 2.52.0 From a323613b9a8015b0643d3b7ba2dca7a03fa81e7f Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Thu, 12 Oct 2017 17:40:32 -0400 Subject: [PATCH 108/214] Undid schema change. --- db/schema.rb | 74 +++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 9312bee..5849cf5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,17 +11,18 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170708011014) do +ActiveRecord::Schema.define(version: 20170703003647) do create_table "badges", force: :cascade do |t| - t.string "name", limit: 191 - t.string "symbol", limit: 191 - t.string "color", limit: 191 + t.string "name", limit: 191 + t.string "symbol", limit: 191 + t.string "color", limit: 191 + t.integer "value", limit: 4 end create_table "blogposts", force: :cascade do |t| - t.string "title", limit: 191 - t.text "content", limit: 65535 + t.string "title", limit: 255 + t.text "content", limit: 16777215 t.integer "user_author_id", limit: 4 t.integer "user_editor_id", limit: 4 t.datetime "created_at" @@ -29,7 +30,7 @@ ActiveRecord::Schema.define(version: 20170708011014) do end create_table "comments", force: :cascade do |t| - t.text "content", limit: 65535 + t.text "content", limit: 16777215 t.integer "user_author_id", limit: 4 t.integer "user_editor_id", limit: 4 t.integer "blogpost_id", limit: 4 @@ -38,14 +39,14 @@ ActiveRecord::Schema.define(version: 20170708011014) do end create_table "forumgroups", force: :cascade do |t| - t.string "name", limit: 191 + t.string "name", limit: 255 t.integer "position", limit: 4 t.integer "role_read_id", limit: 4 t.integer "role_write_id", limit: 4 end create_table "forums", force: :cascade do |t| - t.string "name", limit: 191 + t.string "name", limit: 255 t.integer "position", limit: 4 t.integer "role_read_id", limit: 4 t.integer "role_write_id", limit: 4 @@ -59,10 +60,10 @@ ActiveRecord::Schema.define(version: 20170708011014) do end create_table "forumthreads", force: :cascade do |t| - t.string "title", limit: 191 - t.text "content", limit: 65535 - t.boolean "sticky", default: false - t.boolean "locked", default: false + t.string "title", limit: 255 + t.text "content", limit: 16777215 + t.boolean "sticky", default: false + t.boolean "locked", default: false t.integer "user_author_id", limit: 4 t.integer "user_editor_id", limit: 4 t.integer "forum_id", limit: 4 @@ -72,47 +73,49 @@ ActiveRecord::Schema.define(version: 20170708011014) do end add_index "forumthreads", ["content"], name: "index_forumthreads_on_content", type: :fulltext + add_index "forumthreads", ["title", "content"], name: "forumthreads_title_content", type: :fulltext add_index "forumthreads", ["title", "content"], name: "index_forumthreads_on_title_and_content", type: :fulltext add_index "forumthreads", ["title"], name: "index_forumthreads_on_title", type: :fulltext create_table "info", force: :cascade do |t| - t.string "title", limit: 191 - t.text "content", limit: 65535 + t.string "title", limit: 255 + t.text "content", limit: 16777215 t.datetime "created_at" t.datetime "updated_at" end create_table "labels", force: :cascade do |t| - t.string "name", limit: 191 - t.string "color", limit: 191 + t.string "name", limit: 255 + t.string "color", limit: 255 end create_table "register_tokens", force: :cascade do |t| t.string "uuid", limit: 32, null: false t.string "token", limit: 6, null: false - t.string "email", limit: 191, null: false + t.string "email", limit: 191 end + add_index "register_tokens", ["email"], name: "index_register_tokens_on_email", unique: true, using: :btree add_index "register_tokens", ["uuid"], name: "index_register_tokens_on_uuid", unique: true, using: :btree create_table "roles", force: :cascade do |t| - t.string "name", limit: 191 + t.string "name", limit: 255 t.integer "value", limit: 4 - t.string "color", limit: 191 + t.string "color", limit: 255 end create_table "sessions", force: :cascade do |t| - t.string "session_id", limit: 191, null: false - t.text "data", limit: 65535 + t.string "session_id", limit: 255, null: false + t.text "data", limit: 16777215 t.datetime "created_at" t.datetime "updated_at" end - add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree + add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", length: {"session_id"=>191}, using: :btree add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree create_table "threadreplies", force: :cascade do |t| - t.text "content", limit: 65535 + t.text "content", limit: 16777215 t.integer "user_author_id", limit: 4 t.integer "user_editor_id", limit: 4 t.integer "forumthread_id", limit: 4 @@ -124,18 +127,19 @@ ActiveRecord::Schema.define(version: 20170708011014) do add_index "threadreplies", ["forumthread_id"], name: "index_threadreplies_on_forumthread_id", using: :btree create_table "users", force: :cascade do |t| - t.string "uuid", limit: 191, null: false + t.string "uuid", limit: 255, null: false t.string "name", limit: 191 - t.string "password_digest", limit: 191, null: false - t.string "ign", limit: 191, null: false - t.string "email", limit: 191, null: false + t.string "password_digest", limit: 255, null: false + t.string "ign", limit: 255, null: false + t.string "email", limit: 191 t.text "about", limit: 65535 - t.string "last_ip", limit: 191 - t.string "skype", limit: 191 - t.string "youtube", limit: 191 - t.string "youtube_channelname", limit: 191 - t.string "twitter", limit: 191 - t.string "email_token", limit: 191 + t.string "last_ip", limit: 255 + t.string "skype", limit: 255 + t.boolean "skype_public", default: false + t.string "youtube", limit: 255 + t.string "youtube_channelname", limit: 255 + t.string "twitter", limit: 255 + t.string "email_token", limit: 255 t.boolean "confirmed", default: false t.datetime "last_seen" t.integer "role_id", limit: 4, null: false @@ -146,7 +150,7 @@ ActiveRecord::Schema.define(version: 20170708011014) do t.boolean "mail_own_blogpost_comment", default: true t.boolean "mail_other_blogpost_comment", default: true t.boolean "mail_mention", default: true - t.integer "badge_id", limit: 4, default: 1 + t.integer "badge_id", limit: 4, default: 0 t.boolean "utc_time", default: false t.boolean "header_scroll", default: false t.boolean "dark", default: false -- 2.52.0 From 611c52223a5d7ebea1dbe73d46b061229f6918e1 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Thu, 12 Oct 2017 18:52:53 -0400 Subject: [PATCH 109/214] Fixed who's playing page returning internal server error when server is offline. --- app/controllers/statics_controller.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/statics_controller.rb b/app/controllers/statics_controller.rb index 08dceef..70b58da 100644 --- a/app/controllers/statics_controller.rb +++ b/app/controllers/statics_controller.rb @@ -17,8 +17,15 @@ class StaticsController < ApplicationController end def online - json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/ModuleLoader/players.json")) - @players = json["players"].collect!{ |p| User.find_by(uuid: p["UUID"].tr("-", "")) or User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true) }.sort_by!(&:role).reverse! - @count = json["amount"] + begin + json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/ModuleLoader/players.json")) + rescue + flash[:alert] = "The server is currently offline." + @players = {} + @count = 0 + else + @players = json["players"].collect!{ |p| User.find_by(uuid: p["UUID"].tr("-", "")) or User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true) }.sort_by!(&:role).reverse! + @count = json["amount"] + end end end -- 2.52.0 From da2e66d0b87f11c24a9946c33906c90c90e1f14b Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Thu, 12 Oct 2017 20:18:09 -0400 Subject: [PATCH 110/214] Removed skype_public from schema and seeds. --- db/schema.rb | 1 - db/seeds.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 5849cf5..2dbffc8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -135,7 +135,6 @@ ActiveRecord::Schema.define(version: 20170703003647) do t.text "about", limit: 65535 t.string "last_ip", limit: 255 t.string "skype", limit: 255 - t.boolean "skype_public", default: false t.string "youtube", limit: 255 t.string "youtube_channelname", limit: 255 t.string "twitter", limit: 255 diff --git a/db/seeds.rb b/db/seeds.rb index 926d7b2..f6b731f 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -33,7 +33,6 @@ deleted_user = User.create!( role: Role.get(:disabled), badge: Badge.get(:none), skype: "echo123", - skype_public: true, last_ip: "0.0.0.0", confirmed: true, last_seen: Time.utc(0).to_datetime, -- 2.52.0 From 3e7a0e550fa3e7730bf0b2bb44a3d93a25307514 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Thu, 12 Oct 2017 20:46:23 -0400 Subject: [PATCH 111/214] Added ability to add public key to account. --- app/controllers/users_controller.rb | 2 +- app/views/users/edit_notifications.html.erb | 5 ++++- db/migrate/20171013001146_add_public_key_to_users.rb | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20171013001146_add_public_key_to_users.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5c55976..4890a98 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -352,7 +352,7 @@ class UsersController < ApplicationController end def user_params(add = []) - a = [:ign, :email, :password, :password_confirmation, :mail_own_thread_reply, :mail_other_thread_reply, :mail_own_blogpost_comment, :mail_other_blogpost_comment, :mail_mention] + add + a = [:ign, :email, :password, :password_confirmation, :mail_own_thread_reply, :mail_other_thread_reply, :mail_own_blogpost_comment, :mail_other_blogpost_comment, :mail_mention, :public_key] + add params.require(:user).permit(a) end end diff --git a/app/views/users/edit_notifications.html.erb b/app/views/users/edit_notifications.html.erb index 4e6de12..e0e8288 100644 --- a/app/views/users/edit_notifications.html.erb +++ b/app/views/users/edit_notifications.html.erb @@ -45,6 +45,9 @@
  • Forum<%= select_tag "id", options_for_select(forums, params[:id]), include_blank: "Search All Threads" %><%= select_tag "forum", options_for_select(forums, params[:forum]), include_blank: "Search All Threads" %>
    Label
    Show Skype to - <%= f.select :skype_public, [["Staff only", false], ["All users", true]], {}, { disabled: !can_edit? } %> -
    YouTube Channel ID diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index e371a09..794d2e2 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -52,7 +52,7 @@ Role <%= link_to @user.role, users_path(:role => @user.role.name) %>
    Skype <%= link_to @user.skype, "skype:#{@user.skype}?chat", target: "_blank" %>
    +

    Public Key

    +

    All notification emails, including password resets, will be encrypted with this key if you supply it. Do not lose your private key, otherwise you won't be able to easily recover your account.

    + <%= f.text_area :public_key, placeholder: "-----BEGIN PGP PUBLIC KEY BLOCK-----" %>

    <%= f.submit "Save changes", class: "btn blue left" %>

    -<% end %> \ No newline at end of file +<% end %> diff --git a/db/migrate/20171013001146_add_public_key_to_users.rb b/db/migrate/20171013001146_add_public_key_to_users.rb new file mode 100644 index 0000000..a03743c --- /dev/null +++ b/db/migrate/20171013001146_add_public_key_to_users.rb @@ -0,0 +1,5 @@ +class AddPublicKeyToUsers < ActiveRecord::Migration + def change + add_column :users, :public_key, :text + end +end -- 2.52.0 From a6148790da639e4fccdc0638b5f5bf3e1b09b8ee Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Fri, 13 Oct 2017 22:49:54 -0400 Subject: [PATCH 112/214] Made notification emails get encrypted for accounts with a public key. --- Gemfile | 1 + app/mailers/redstoner_mailer.rb | 30 +++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 4216fe2..8c8cb60 100644 --- a/Gemfile +++ b/Gemfile @@ -16,6 +16,7 @@ gem 'highlight_js-rails', github: 'RedstonerServer/highlight_js-rails' gem 'kaminari', github: 'jomo/kaminari', branch: 'patch-2' # pagination gem 'jquery-textcomplete-rails', github: 'RedstonerServer/jquery-textcomplete-rails' # @mentions gem 'actionpack-action_caching', github: 'antulik/actionpack-action_caching', ref: '8c6e52c69315d67437f480da5dce4b7c8737fb32' +gem 'mail-gpg' # Gems used only for assets and not required # in production environments by default. diff --git a/app/mailers/redstoner_mailer.rb b/app/mailers/redstoner_mailer.rb index 1b387f8..e1e22b2 100644 --- a/app/mailers/redstoner_mailer.rb +++ b/app/mailers/redstoner_mailer.rb @@ -19,29 +19,49 @@ class RedstonerMailer < ActionMailer::Base def new_thread_mention_mail(user, thread) @user = user @thread = thread - mail(to: @user.email, subject: "#{thread.author.name} mentioned you in '#{thread.title}' on Redstoner") + if @user.public_key? + mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}}) + else + mail(to: @user.email, subject: "#{thread.author.name} mentioned you in '#{thread.title}' on Redstoner") + end end def new_thread_reply_mail(user, reply) @user = user @reply = reply - mail(to: @user.email, subject: "#{reply.author.name} replied to '#{reply.thread.title}' on Redstoner") + if @user.public_key? + mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}}) + else + mail(to: @user.email, subject: "#{reply.author.name} replied to '#{reply.thread.title}' on Redstoner") + end end def new_post_mention_mail(user, post) @user = user @post = post - mail(to: @user.email, subject: "#{post.author.name} mentioned you in '#{post.title}' on Redstoner") + if @user.public_key? + mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}}) + else + mail(to: @user.email, subject: "#{post.author.name} mentioned you in '#{post.title}' on Redstoner") + end end def new_post_comment_mail(user, comment) @user = user @comment = comment - mail(to: @user.email, subject: "#{comment.author.name} replied to '#{comment.blogpost.title}' on Redstoner") + if @user.public_key? + mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}}) + else + mail(to: @user.email, subject: "#{comment.author.name} replied to '#{comment.blogpost.title}' on Redstoner") + end end def email_change_confirm_mail(user) @user = user - mail(to: @user.email, subject: "Email change on Redstoner.com") + if @user.public_key? + mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}}) + else + mail(to: @user.email, subject: "Email change on Redstoner.com") + end end end -- 2.52.0 From 751462bbedb2e2133b630156527650ebc506d347 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Fri, 13 Oct 2017 23:28:08 -0400 Subject: [PATCH 113/214] Added public_key to schema. --- db/schema.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/db/schema.rb b/db/schema.rb index 5849cf5..2f38b71 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -154,6 +154,7 @@ ActiveRecord::Schema.define(version: 20170703003647) do t.boolean "utc_time", default: false t.boolean "header_scroll", default: false t.boolean "dark", default: false + t.text "public_key", limit: 65535 end add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree -- 2.52.0 From 8c99e9631be251500449cdf891486f879323becc Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Sun, 15 Oct 2017 15:33:22 -0400 Subject: [PATCH 114/214] Added Mastodon and onion service links to footer. --- app/assets/images/mastodon.png | Bin 0 -> 477 bytes app/assets/images/tor.png | Bin 0 -> 581 bytes app/views/layouts/_footer.html.erb | 8 +++++++- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 app/assets/images/mastodon.png create mode 100644 app/assets/images/tor.png diff --git a/app/assets/images/mastodon.png b/app/assets/images/mastodon.png new file mode 100644 index 0000000000000000000000000000000000000000..a4305d917783afa22d50edee16e8d1da1314a86c GIT binary patch literal 477 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4rT@h1`S>QUCfMPUw;05@$uL8YahI(-}>?U-@C8BkKX&d@7AZC*FP>j{ibpI z)5=YcOV&TK>Ax;kd47rE-wg~53<@Pde!&cXkNo@d`%(1IFE8($pKKuh@86e=Yv#76 zd$=la{9G8!o4{Ub%D}*I+|$J|MB=h<*K@vR10J@y8_K`SZF6R7eRuG;eH8Pn{&_my z_g^w3%=N5SI&x(CO(`Aj6r&@D53@Qn94bAg8)#h?)5z#iHh*f+`|UwjFQ;-&{CDN+ z>q0yGxYEBD1r4UYy7%(5Yk7I75dR`Yo4FIDv=7CF^uBD(Ts0|)Be&4_jYUr0HV?&X zZ%bW#zPVkWJI|@B$z;)U&V`(hWu9qRaBXb=`;+ZKgWS9B&<#9cm5kHYx|~1%u-`W; q+j92FB|m09E}9iFJ>_;?Eu%JzghpuoZd(Qh1_n=8KbLh*2~7adsOX#k literal 0 HcmV?d00001 diff --git a/app/assets/images/tor.png b/app/assets/images/tor.png new file mode 100644 index 0000000000000000000000000000000000000000..47a4a1690a234a59ea2c2fbbae37c569abc3721c GIT binary patch literal 581 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4rT@h1`S>QUbVeR|WJG;9?L>TFSu9pv=J_ znX`$(!zrSCqEp#=1`9p^#=VkxD;PK#)c6?Grr%_!-od~MGRjVz!LH>pL&JWCzkmN| ztLT6J@cHVgYhnJ8o{nLj&h9n_F52=oa$Kew3fe+UnhN4dpFX~L^ZMbVyAL1UzxnLp zv9kw{o!PhN(#g$B7tN^+oiM4Qt+${h%dxpCvbM6QrnRv;*04H6r8Hc>xG1kM&ORq4 zCfh|cyR$OGRW99DI625P!9z1H)-E={Hr9kY+TAKFH#9iNH`v!az*gVi)5Xux!Y9bX zGu+NiSKi4{!_msb)>y+jBF|Es!BmP@S3^m~Dvn#oZ`~aR1_srVAirP+7S0*!Dax{< z9PFP@pI*6g<-+L`+uK`P>+*6^BFxOp3^WvEcrH%jJITPnu*}oNF+}2Was#uUrI{$3 z$^xB(>RSCe2hQsrX*-fC;x9D8Xy)>7Bfq}u()z4*}Q$iB}dIZTi literal 0 HcmV?d00001 diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index 930eb26..cc2b2fd 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -13,6 +13,12 @@ <% end %> | <%= link_to "https://twitter.com/RedstonerServer", title: "Redstoner on Twitter" do %> Twitter <%= image_tag("twitter.png") %> + <% end %> | + <%= link_to "https://mstdn.io/@RedstonerServer", title: "Redstoner on Mastodon" do %> + Mastodon <%= image_tag("mastodon.png") %> + <% end %> | + <%= link_to "http://rdstnr4biap5nao2.onion", title: "Redstoner over Tor" do %> + Onion Service <%= image_tag("tor.png") %> <% end %> <% if current_user %> | <%= link_to "/slack/?" + {mail: current_user.try(:email)}.to_param do %> @@ -20,4 +26,4 @@ <% end %> <% end %>
    -
    \ No newline at end of file +
    -- 2.52.0 From 29ef493a1bd4c95ced33c8711add6c0ebc6fb74d Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Sun, 15 Oct 2017 15:58:06 -0400 Subject: [PATCH 115/214] Added title to donate page. --- app/views/statics/donate.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/statics/donate.html.erb b/app/views/statics/donate.html.erb index 8f82cde..c304917 100644 --- a/app/views/statics/donate.html.erb +++ b/app/views/statics/donate.html.erb @@ -1,3 +1,4 @@ +<% title "Donate" %>

    Donate

    Running a server is really stressful and requires a lot of work.
    -- 2.52.0 From 1ec1c09490c5f3481e87a599d81c7ae4b0227691 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Sun, 15 Oct 2017 20:01:56 -0400 Subject: [PATCH 116/214] Fixed schema version number. --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 2dbffc8..197024d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170703003647) do +ActiveRecord::Schema.define(version: 20170708011014) do create_table "badges", force: :cascade do |t| t.string "name", limit: 191 -- 2.52.0 From 91d6082d3759bd65a95a0dee063a46d2e6f6d2f6 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Wed, 18 Oct 2017 17:06:41 -0400 Subject: [PATCH 117/214] Fixed schema version number. --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 2f38b71..91cfe91 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170703003647) do +ActiveRecord::Schema.define(version: 20171013001146) do create_table "badges", force: :cascade do |t| t.string "name", limit: 191 -- 2.52.0 From d2d64d20f0437b5dcd3439292ab913e2e1990da2 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Wed, 18 Oct 2017 17:17:08 -0400 Subject: [PATCH 118/214] Changed the public key usage informational text. --- app/views/users/edit_notifications.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/edit_notifications.html.erb b/app/views/users/edit_notifications.html.erb index e0e8288..9c45445 100644 --- a/app/views/users/edit_notifications.html.erb +++ b/app/views/users/edit_notifications.html.erb @@ -46,7 +46,7 @@

    Public Key

    -

    All notification emails, including password resets, will be encrypted with this key if you supply it. Do not lose your private key, otherwise you won't be able to easily recover your account.

    +

    All notification emails will be encrypted with this key if you supply it.

    <%= f.text_area :public_key, placeholder: "-----BEGIN PGP PUBLIC KEY BLOCK-----" %>

    <%= f.submit "Save changes", class: "btn blue left" %>

    -- 2.52.0 From 5ab615e18f093e7654bae3c628bd3349532fdfd5 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Wed, 18 Oct 2017 17:30:42 -0400 Subject: [PATCH 119/214] Added public key validation. --- app/models/user.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 14364ed..4f682c6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -22,6 +22,8 @@ class User < ActiveRecord::Base validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@(.+\..{2,}|\[(IPv6)?[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 :public_key, format: {with: /\A(-----BEGIN PGP PUBLIC KEY BLOCK-----((.|\n)*?)-----END PGP PUBLIC KEY BLOCK-----)?\z/i, message: "That doesn't look like a PGP formatted public key."} + has_many :blogposts has_many :comments -- 2.52.0 From f66d6e9f1312a1d459239134b9114183e516b5d7 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Sun, 22 Oct 2017 16:40:06 -0400 Subject: [PATCH 120/214] Fixed the who's playing page error message staying for an extra request. --- app/controllers/statics_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/statics_controller.rb b/app/controllers/statics_controller.rb index 70b58da..c624c32 100644 --- a/app/controllers/statics_controller.rb +++ b/app/controllers/statics_controller.rb @@ -20,7 +20,7 @@ class StaticsController < ApplicationController begin json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/ModuleLoader/players.json")) rescue - flash[:alert] = "The server is currently offline." + flash.now[:alert] = "The server is currently offline." @players = {} @count = 0 else -- 2.52.0 From ff61be48f7e41be615cfac901d06bcd05b6a9f56 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Wed, 25 Oct 2017 22:02:16 -0400 Subject: [PATCH 121/214] Fixed Gemfile.lock not including mail-gpg. --- Gemfile.lock | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index c04ca64..870c3f6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -135,6 +135,8 @@ GEM execjs (2.6.0) globalid (0.3.6) activesupport (>= 4.1.0) + gpgme (2.0.11) + mini_portile (>= 0.5.0) hirb (0.7.3) http-cookie (1.0.2) domain_name (~> 0.5) @@ -149,7 +151,11 @@ GEM nokogiri (>= 1.5.9) mail (2.6.3) mime-types (>= 1.16, < 3) + mail-gpg (0.3.1) + gpgme (~> 2.0, >= 2.0.2) + mail (~> 2.5, >= 2.5.3) mime-types (2.99) + mini_portile (0.6.2) mini_portile2 (2.0.0) minitest (5.8.4) mysql2 (0.4.2) @@ -244,6 +250,7 @@ DEPENDENCIES jquery-rails jquery-textcomplete-rails! kaminari! + mail-gpg mysql2 rails! rails-erd -- 2.52.0 From 577961d122edb3352c7a62e9175fa1bfdaeecc3b Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Wed, 25 Oct 2017 22:59:01 -0400 Subject: [PATCH 122/214] Made use of jomo's patch to mail-gpg. --- Gemfile | 2 +- Gemfile.lock | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 8c8cb60..c66df69 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,7 @@ gem 'highlight_js-rails', github: 'RedstonerServer/highlight_js-rails' gem 'kaminari', github: 'jomo/kaminari', branch: 'patch-2' # pagination gem 'jquery-textcomplete-rails', github: 'RedstonerServer/jquery-textcomplete-rails' # @mentions gem 'actionpack-action_caching', github: 'antulik/actionpack-action_caching', ref: '8c6e52c69315d67437f480da5dce4b7c8737fb32' -gem 'mail-gpg' +gem 'mail-gpg', github: 'jomo/mail-gpg', ref: 'a666b48ee866dfa3eaa700f9c5edf4d195d0f8c9' # Gems used only for assets and not required # in production environments by default. diff --git a/Gemfile.lock b/Gemfile.lock index 870c3f6..f88e22b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -31,6 +31,15 @@ GIT actionpack (>= 3.0.0) activesupport (>= 3.0.0) +GIT + remote: git://github.com/jomo/mail-gpg.git + revision: a666b48ee866dfa3eaa700f9c5edf4d195d0f8c9 + ref: a666b48ee866dfa3eaa700f9c5edf4d195d0f8c9 + specs: + mail-gpg (0.3.1) + gpgme (~> 2.0, >= 2.0.2) + mail (~> 2.5, >= 2.5.3) + GIT remote: git://github.com/rails/rails.git revision: 2c8f567e53580872d8c6dfe61201e58793ca131e @@ -151,9 +160,6 @@ GEM nokogiri (>= 1.5.9) mail (2.6.3) mime-types (>= 1.16, < 3) - mail-gpg (0.3.1) - gpgme (~> 2.0, >= 2.0.2) - mail (~> 2.5, >= 2.5.3) mime-types (2.99) mini_portile (0.6.2) mini_portile2 (2.0.0) @@ -250,7 +256,7 @@ DEPENDENCIES jquery-rails jquery-textcomplete-rails! kaminari! - mail-gpg + mail-gpg! mysql2 rails! rails-erd -- 2.52.0 From 2223f88d7bd94c98108e03307b5e52f26e8437ff Mon Sep 17 00:00:00 2001 From: MrYummy Date: Thu, 26 Oct 2017 22:21:00 +0200 Subject: [PATCH 123/214] minor edits --- app/controllers/users_controller.rb | 2 ++ app/views/users/show.html.erb | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e188d01..cc77c44 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -6,6 +6,8 @@ class UsersController < ApplicationController before_filter :set_user, except: [:index, :new, :create, :lost_password, :reset_password, :suggestions] + caches_action :show, expires_in: 10.seconds, layout: false + def index if params[:role] if params[:role].downcase == "staff" diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 3d9dcfe..de784a2 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -16,9 +16,10 @@
    <% if @ban_json %> - This user is banned for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%> - <% elsif @user.banned? %> - This user is banned! + This user is banned on the server for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%> + <% end %> + <% if @user.banned? %> + This user is banned on the website! <% end %>
    <% if !@user.confirmed? %> -- 2.52.0 From b1f739f6f8a1778151a80696819ce6ae6ea2c477 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Sat, 28 Oct 2017 13:49:36 -0400 Subject: [PATCH 124/214] Fixed the inability to update profile when not changing name. --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4890a98..366ba1a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -141,7 +141,7 @@ class UsersController < ApplicationController else userdata = user_params([:name, :skype, :youtube, :twitter, :about, :header_scroll, :utc_time, :dark]) end - if User.find_by(name: userdata[:name]) + if User.find_by(name: userdata[:name]) && User.find_by(name: userdata[:name]) != current_user flash[:alert] = "You have entered a name that belongs to someone else. Please try another." redirect_to edit_user_path(@user) return -- 2.52.0 From 0093daedd9b028ae633d773b540d807238448589 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Sat, 28 Oct 2017 14:23:34 -0400 Subject: [PATCH 125/214] Fixed name reuse check sometimes using wrong account to compare against. --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 366ba1a..4c854ea 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -141,7 +141,7 @@ class UsersController < ApplicationController else userdata = user_params([:name, :skype, :youtube, :twitter, :about, :header_scroll, :utc_time, :dark]) end - if User.find_by(name: userdata[:name]) && User.find_by(name: userdata[:name]) != current_user + if User.find_by(name: userdata[:name]) && User.find_by(name: userdata[:name]) != @user flash[:alert] = "You have entered a name that belongs to someone else. Please try another." redirect_to edit_user_path(@user) return -- 2.52.0 From ea4799fc285c1bebaabfb72c176583b05edd9def Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Sat, 28 Oct 2017 15:25:39 -0400 Subject: [PATCH 126/214] Made Who's Playing page hide vanished users from non-staff ranks. --- app/controllers/statics_controller.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/controllers/statics_controller.rb b/app/controllers/statics_controller.rb index c624c32..3a46ac1 100644 --- a/app/controllers/statics_controller.rb +++ b/app/controllers/statics_controller.rb @@ -17,15 +17,23 @@ class StaticsController < ApplicationController end def online + @players = {} + @count = 0 begin json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/ModuleLoader/players.json")) rescue flash.now[:alert] = "The server is currently offline." - @players = {} - @count = 0 else - @players = json["players"].collect!{ |p| User.find_by(uuid: p["UUID"].tr("-", "")) or User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true) }.sort_by!(&:role).reverse! - @count = json["amount"] + json["players"].each do |p| + next if p["vanished"] == "true" && !mod? + if User.find_by(uuid: p["UUID"].tr("-", "")) + @players.push(User.find_by(uuid: p["UUID"].tr("-", ""))) + else + @players.push(User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true)) + end + end end + @players.sort_by!(&:role).reverse! + @count = @players.count end end -- 2.52.0 From 32c72ca01670e5ccc0a9bcb52da9b9ded5190a12 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Sat, 28 Oct 2017 20:27:25 -0400 Subject: [PATCH 127/214] Changed Google+ social link to Mastodon social link in emails. --- app/views/redstoner_mailer/email_change_confirm_mail.html.erb | 2 +- app/views/redstoner_mailer/new_post_comment_mail.html.erb | 2 +- app/views/redstoner_mailer/new_post_mention_mail.html.erb | 2 +- app/views/redstoner_mailer/new_thread_mention_mail.html.erb | 2 +- app/views/redstoner_mailer/new_thread_reply_mail.html.erb | 2 +- app/views/redstoner_mailer/register_mail.html.erb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/redstoner_mailer/email_change_confirm_mail.html.erb b/app/views/redstoner_mailer/email_change_confirm_mail.html.erb index 37a5fbe..8d108c9 100644 --- a/app/views/redstoner_mailer/email_change_confirm_mail.html.erb +++ b/app/views/redstoner_mailer/email_change_confirm_mail.html.erb @@ -25,7 +25,7 @@

    You can contact us via: <%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | <%= link_to "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | - <%= link_to "Google+", "https://google.com/+Redstoner", style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Mastodon", "https://mstdn.io/@RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>

    diff --git a/app/views/redstoner_mailer/new_post_comment_mail.html.erb b/app/views/redstoner_mailer/new_post_comment_mail.html.erb index 6726535..08e1813 100644 --- a/app/views/redstoner_mailer/new_post_comment_mail.html.erb +++ b/app/views/redstoner_mailer/new_post_comment_mail.html.erb @@ -24,7 +24,7 @@

    You can contact us via: <%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | <%= link_to "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | - <%= link_to "Google+", "https://google.com/+Redstoner", style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Mastodon", "https://mstdn.io/@RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>

    diff --git a/app/views/redstoner_mailer/new_post_mention_mail.html.erb b/app/views/redstoner_mailer/new_post_mention_mail.html.erb index aef3eef..08c8097 100644 --- a/app/views/redstoner_mailer/new_post_mention_mail.html.erb +++ b/app/views/redstoner_mailer/new_post_mention_mail.html.erb @@ -21,7 +21,7 @@

    You can contact us via: <%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | <%= link_to "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | - <%= link_to "Google+", "https://google.com/+Redstoner", style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Mastodon", "https://mstdn.io/@RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>

    diff --git a/app/views/redstoner_mailer/new_thread_mention_mail.html.erb b/app/views/redstoner_mailer/new_thread_mention_mail.html.erb index 2aeaf0b..35904d0 100644 --- a/app/views/redstoner_mailer/new_thread_mention_mail.html.erb +++ b/app/views/redstoner_mailer/new_thread_mention_mail.html.erb @@ -23,7 +23,7 @@

    You can contact us via: <%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | <%= link_to "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | - <%= link_to "Google+", "https://google.com/+Redstoner", style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Mastodon", "https://mstdn.io/@RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>

    diff --git a/app/views/redstoner_mailer/new_thread_reply_mail.html.erb b/app/views/redstoner_mailer/new_thread_reply_mail.html.erb index 4081f05..d71b136 100644 --- a/app/views/redstoner_mailer/new_thread_reply_mail.html.erb +++ b/app/views/redstoner_mailer/new_thread_reply_mail.html.erb @@ -26,7 +26,7 @@

    You can contact us via: <%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | <%= link_to "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | - <%= link_to "Google+", "https://google.com/+Redstoner", style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Mastodon", "https://mstdn.io/@RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>

    diff --git a/app/views/redstoner_mailer/register_mail.html.erb b/app/views/redstoner_mailer/register_mail.html.erb index 35ccad9..f0af4a4 100644 --- a/app/views/redstoner_mailer/register_mail.html.erb +++ b/app/views/redstoner_mailer/register_mail.html.erb @@ -37,7 +37,7 @@

    You can contact us via: <%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | <%= link_to "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | - <%= link_to "Google+", "https://google.com/+Redstoner", style: "text-decoration: none; color: #4096EE;" %> | + <%= link_to "Mastodon", "https://mstdn.io/@RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>

    -- 2.52.0 From 9aad74664970849fb33573030cd9b29299348026 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Sat, 28 Oct 2017 20:46:56 -0400 Subject: [PATCH 128/214] Added validation for length of thread title. --- app/models/forumthread.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/forumthread.rb b/app/models/forumthread.rb index fd8d3c1..fe551c3 100644 --- a/app/models/forumthread.rb +++ b/app/models/forumthread.rb @@ -11,6 +11,7 @@ class Forumthread < ActiveRecord::Base validates_presence_of :title, :author, :forum validates_presence_of :content + validates_length_of :title, in: 5..255 validates_length_of :content, in: 5..20000 accepts_nested_attributes_for :threadreplies -- 2.52.0 From 82b4dd5280379771a74e5e7d7920c73b9c95eade Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Sat, 28 Oct 2017 20:56:05 -0400 Subject: [PATCH 129/214] Added validation for length of blogpost title and content. --- app/models/blogpost.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/blogpost.rb b/app/models/blogpost.rb index 9ff64fe..7275273 100644 --- a/app/models/blogpost.rb +++ b/app/models/blogpost.rb @@ -8,6 +8,8 @@ class Blogpost < ActiveRecord::Base belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id" has_many :comments, :dependent => :destroy accepts_nested_attributes_for :comments + validates_length_of :title, in: 5..255 + validates_length_of :content, in: 5..20000 def author @author ||= if self.user_author.present? -- 2.52.0 From 7520efb683486d39dd02a98cb4a35b48382c9d90 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Sat, 28 Oct 2017 21:06:48 -0400 Subject: [PATCH 130/214] Added validation for length of forum title. --- app/models/forum.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/forum.rb b/app/models/forum.rb index a239dbc..4b6479d 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -4,6 +4,7 @@ class Forum < ActiveRecord::Base belongs_to :role_read, class_name: "Role", foreign_key: "role_read_id" belongs_to :role_write, class_name: "Role", foreign_key: "role_write_id" has_and_belongs_to_many :labels + validates_length_of :name, in: 2..30 def to_s name -- 2.52.0 From 5b3b0fe3ef30d5500c75418fd02b5d14fd04206d Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Sat, 28 Oct 2017 21:48:14 -0400 Subject: [PATCH 131/214] Increased minimum title length for forum groups and forums. --- app/models/forum.rb | 2 +- app/models/forumgroup.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/forum.rb b/app/models/forum.rb index 4b6479d..e892462 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -4,7 +4,7 @@ class Forum < ActiveRecord::Base belongs_to :role_read, class_name: "Role", foreign_key: "role_read_id" belongs_to :role_write, class_name: "Role", foreign_key: "role_write_id" has_and_belongs_to_many :labels - validates_length_of :name, in: 2..30 + validates_length_of :name, in: 4..30 def to_s name diff --git a/app/models/forumgroup.rb b/app/models/forumgroup.rb index f9d156c..0d5c1f8 100644 --- a/app/models/forumgroup.rb +++ b/app/models/forumgroup.rb @@ -7,7 +7,7 @@ class Forumgroup < ActiveRecord::Base validates_presence_of :name, :position - validates_length_of :name, in: 2..20 + validates_length_of :name, in: 4..20 def to_s name -- 2.52.0 From 7d766c8cf2043e386346a3b479875400f1f1464c Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 29 Oct 2017 22:26:16 +0100 Subject: [PATCH 132/214] Optimized @players collection from json --- app/controllers/statics_controller.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app/controllers/statics_controller.rb b/app/controllers/statics_controller.rb index 3a46ac1..a47b893 100644 --- a/app/controllers/statics_controller.rb +++ b/app/controllers/statics_controller.rb @@ -17,20 +17,15 @@ class StaticsController < ApplicationController end def online - @players = {} + @players = [] @count = 0 begin - json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/ModuleLoader/players.json")) + json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/ModuleLoader/players.json"))["players"].reject{|p| !mod? && p["vanished"] == "true"} rescue flash.now[:alert] = "The server is currently offline." else - json["players"].each do |p| - next if p["vanished"] == "true" && !mod? - if User.find_by(uuid: p["UUID"].tr("-", "")) - @players.push(User.find_by(uuid: p["UUID"].tr("-", ""))) - else - @players.push(User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true)) - end + json.each do |p| + @players.push(User.find_by(uuid: p["UUID"].tr("-", "")) || User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true)) end end @players.sort_by!(&:role).reverse! -- 2.52.0 From 2d9fdcd802b32dd17168a9317977fc7dfa30257b Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Sun, 29 Oct 2017 19:44:52 -0400 Subject: [PATCH 133/214] Added backward compatibility for old data format. --- app/controllers/statics_controller.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/controllers/statics_controller.rb b/app/controllers/statics_controller.rb index a47b893..0809dbc 100644 --- a/app/controllers/statics_controller.rb +++ b/app/controllers/statics_controller.rb @@ -20,15 +20,23 @@ class StaticsController < ApplicationController @players = [] @count = 0 begin - json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/ModuleLoader/players.json"))["players"].reject{|p| !mod? && p["vanished"] == "true"} + json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/ModuleLoader/players.json")) rescue flash.now[:alert] = "The server is currently offline." else - json.each do |p| - @players.push(User.find_by(uuid: p["UUID"].tr("-", "")) || User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true)) + case json["dataFormat"] + when "v1" + @players = json["players"].collect!{ |p| User.find_by(uuid: p["UUID"].tr("-", "")) or User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true) } + @count = json["amount"] + when "v2" + json["players"].reject{|p| !mod? && p["vanished"] == "true"}.each do |p| + @players.push(User.find_by(uuid: p["UUID"].tr("-", "")) || User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true)) + end + @count = @players.count + else + flash.now[:alert] = "The server is using an incompatible data format. Please report this error!" end + @players.sort_by!(&:role).reverse! end - @players.sort_by!(&:role).reverse! - @count = @players.count end end -- 2.52.0 From 3c7bfa93380074ce4d866196b340cdbe0f294db2 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Sun, 29 Oct 2017 20:22:00 -0400 Subject: [PATCH 134/214] Changed the invalid data format error message. --- app/controllers/statics_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/statics_controller.rb b/app/controllers/statics_controller.rb index 0809dbc..aaaf5b4 100644 --- a/app/controllers/statics_controller.rb +++ b/app/controllers/statics_controller.rb @@ -34,7 +34,7 @@ class StaticsController < ApplicationController end @count = @players.count else - flash.now[:alert] = "The server is using an incompatible data format. Please report this error!" + flash.now[:alert] = "The server is using an incompatible data format. We are aware of this issue and are most likely already working on it." end @players.sort_by!(&:role).reverse! end -- 2.52.0 From 3fb5924318dee8f023dbea5e31526a74ca1f35e8 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Tue, 31 Oct 2017 15:44:18 -0400 Subject: [PATCH 135/214] trimmed UUIDs from banned-players.json --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cc77c44..d657053 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -32,7 +32,7 @@ class UsersController < ApplicationController end def show - @ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"] == @user.uuid} + @ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"].tr("-", "") == @user.uuid} end # SIGNUP -- 2.52.0 From 553b373d5eb647f0fc2909d48400b4ceb392ca79 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Tue, 31 Oct 2017 20:53:56 -0400 Subject: [PATCH 136/214] Added privacy policy. --- app/controllers/statics_controller.rb | 3 ++ app/views/statics/privacy.html.erb | 41 +++++++++++++++++++++++++++ config/routes.rb | 1 + 3 files changed, 45 insertions(+) create mode 100644 app/views/statics/privacy.html.erb diff --git a/app/controllers/statics_controller.rb b/app/controllers/statics_controller.rb index aaaf5b4..0d42fa9 100644 --- a/app/controllers/statics_controller.rb +++ b/app/controllers/statics_controller.rb @@ -39,4 +39,7 @@ class StaticsController < ApplicationController @players.sort_by!(&:role).reverse! end end + + def privacy + end end diff --git a/app/views/statics/privacy.html.erb b/app/views/statics/privacy.html.erb new file mode 100644 index 0000000..3ff179c --- /dev/null +++ b/app/views/statics/privacy.html.erb @@ -0,0 +1,41 @@ +<% title "Privacy Policy" %> +

    Privacy Policy

    +

    Please note that this privacy policy is not legally binding. It is simply a reference intended to inform you about what is done with your information. Also, this privacy policy only applies to the Redstoner website and forums. The Minecraft server will have its own privacy policy at some point.

    +

    How your information is stored and protected

    +

    Everything on the website is stored in a database, to which access is strictly limited. Only users of the administrator rank or former administrators who are well known and are trusted by the rest of the current administrators may access the database. Offsite backups of this data are made daily only to the network and servers of at least one current administrator via an encrypted SSH connection.

    +

    Passwords are stored using the bcrypt algorithm. Plaintext passwords are never logged or stored anywhere.

    +

    The website code is <%= link_to "open source", "https://github.com/RedstonerServer/redstoner.com" %> and undergoes heavy testing and review before it is deployed to ensure no exploitable bugs or backdoors make it onto the production server.

    +

    All connections to our website are automatically forced to be made over HTTPS to ensure your data is protected while in transit. We maintain <%= link_to "good TLS paramters", "https://www.ssllabs.com/ssltest/analyze.html?d=redstoner.com" %> and also employ other techniques to ensure secure connections such as <%= link_to "being on the HSTS preload list", "https://hstspreload.org/?domain=redstoner.com" %> and OCSP stapling.

    +

    Information we collect

    +
      +
    • This information is needed in order for your account to be created:
    • +
    • Your Minecraft account's IGN and UUID.
    • +
    • Your email address.
    • +
    • A unique password.
    • +
    +

    This information is optional and is obtained only if you provide it:

    +
      +
    • Your Skype username.
    • +
    • Your YouTube channel ID.
    • +
    • Your Twitter username.
    • +
    +

    This information is also collected, however does not affect your Redstoner account directly:

    +
      +
    • Your IP address.
    • +
    +

    How your information is used and who it is visible to

    +
      +
    • Minecraft account IGN and UUID - This is used to link your Minecraft account with your Redstoner account. Anyone can see these.
    • +
    • Your email address - This is used to send you email notifications about forums activity that you are involved in. These notifications can be disabled in your account settings. This is also used to perform a password reuse check, which is explained in more detail below. Only users of the moderator rank or higher can see your email address.
    • +
    • Your password - This is used to authenticate you. This too is used to perform a password reuse check. The plaintext version is visible to no one, but the hashed version is visible only to users of the administrator rank or higher.
    • +
    • Your Skype username - This is used to add a link to your profile that allows others to easily contact you over Skype. Anyone can see this.
    • +
    • Your YouTube channel - This is used to add a link to your profile that allows others to easily find your YouTube channel. Anyone can see this.
    • +
    • Your Twitter username - This is used to add a link to your profile that allows others to easily contact you over Twitter. Anyone can see this.
    • +
    • Your IP address - This is used to help us identify and ban troublemakers from our forums. Only users of the moderator rank and above can see this.
    • +
    +

    Password reuse check

    +

    When you first sign up on our website, we use your email address and password to check if you are reusing your password with your Mojang account. This is done by attempting to log into Mojang's server using this information. If it succeeds, then your confirmation email will contain a note warning you not to reuse your password. The information used to perform this check is never used to actually take over your Minecraft account. In fact, we can't because your password is hashed after the check and is totally unusable to us. If you get this warning not to reuse your password, it is still highly recommended that you change your password for your Mojang account and also use a password manager.

    +

    Who your information is shared with

    +

    We do not share your information with any third parties. The only time we will release information is if we are legally required to.

    +
    +

    This privacy policy was last revised October 31, 2017.

    diff --git a/config/routes.rb b/config/routes.rb index 5b35f95..6ad277b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,6 +9,7 @@ Redstoner::Application.routes.draw do get 'donate' get 'home' get 'online' + get 'privacy' get 'index' end end -- 2.52.0 From 06467477803715b11e5c5267e4dba819b21133a7 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Tue, 31 Oct 2017 21:23:36 -0400 Subject: [PATCH 137/214] Fixed formatting error on privacy policy. --- app/views/statics/privacy.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/statics/privacy.html.erb b/app/views/statics/privacy.html.erb index 3ff179c..4f44697 100644 --- a/app/views/statics/privacy.html.erb +++ b/app/views/statics/privacy.html.erb @@ -7,8 +7,8 @@

    The website code is <%= link_to "open source", "https://github.com/RedstonerServer/redstoner.com" %> and undergoes heavy testing and review before it is deployed to ensure no exploitable bugs or backdoors make it onto the production server.

    All connections to our website are automatically forced to be made over HTTPS to ensure your data is protected while in transit. We maintain <%= link_to "good TLS paramters", "https://www.ssllabs.com/ssltest/analyze.html?d=redstoner.com" %> and also employ other techniques to ensure secure connections such as <%= link_to "being on the HSTS preload list", "https://hstspreload.org/?domain=redstoner.com" %> and OCSP stapling.

    Information we collect

    +

    This information is needed in order for your account to be created: