From a8a71d4376e2bdae1a856b7d8f7e69a0791a1639 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 2 Dec 2018 15:07:47 -0600 Subject: [PATCH 1/4] remove social-share-button gem --- Gemfile | 3 --- Gemfile.lock | 3 --- 2 files changed, 6 deletions(-) diff --git a/Gemfile b/Gemfile index fc285d73..eeb323f9 100644 --- a/Gemfile +++ b/Gemfile @@ -58,9 +58,6 @@ gem 'redcarpet' #markdown formatting gem 'mixpanel-ruby' gem 'barnes' -# Sharing -gem 'social-share-button' - # Apps #gem 'easy_translate' gem 'levenshtein-ffi' diff --git a/Gemfile.lock b/Gemfile.lock index 7251d8c5..d72cd5c8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -452,8 +452,6 @@ GEM simplecov-html (~> 0.10.0) simplecov-html (0.10.2) slack-notifier (2.3.2) - social-share-button (1.1.0) - coffee-rails sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -588,7 +586,6 @@ DEPENDENCIES shoulda-matchers (~> 3.1) simplecov slack-notifier - social-share-button sqlite3 stackprof stripe From c17ffe13ffc5c3d2bdf2f15057ab83ce095d4061 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 2 Dec 2018 15:29:03 -0600 Subject: [PATCH 2/4] remove levenshtein-ffi gem --- Gemfile | 2 +- Gemfile.lock | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index eeb323f9..37dbb221 100644 --- a/Gemfile +++ b/Gemfile @@ -60,7 +60,7 @@ gem 'barnes' # Apps #gem 'easy_translate' -gem 'levenshtein-ffi' +#gem 'levenshtein-ffi' # Forum gem 'thredded' diff --git a/Gemfile.lock b/Gemfile.lock index d72cd5c8..c2e25508 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -236,8 +236,6 @@ GEM kaminari-core (= 1.1.1) kaminari-core (1.1.1) kramdown (1.17.0) - levenshtein-ffi (1.1.0) - ffi (~> 1.9) libv8 (6.7.288.46.1) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) @@ -551,7 +549,6 @@ DEPENDENCIES guard guard-minitest guard-rubocop - levenshtein-ffi material_icons medium-editor-rails memory_profiler From 7924a754b08a1ef069a5418b77fbfe66f504007a Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 2 Dec 2018 16:20:59 -0600 Subject: [PATCH 3/4] install skylight --- Gemfile | 1 + Gemfile.lock | 5 +++++ config/initializers/social_share_button.rb | 5 ----- config/skylight.yml | 4 ++++ 4 files changed, 10 insertions(+), 5 deletions(-) delete mode 100644 config/initializers/social_share_button.rb create mode 100644 config/skylight.yml diff --git a/Gemfile b/Gemfile index 37dbb221..84b96363 100644 --- a/Gemfile +++ b/Gemfile @@ -57,6 +57,7 @@ gem 'redcarpet' #markdown formatting # Analytics gem 'mixpanel-ruby' gem 'barnes' +gem 'skylight' # Apps #gem 'easy_translate' diff --git a/Gemfile.lock b/Gemfile.lock index c2e25508..f61454f0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -449,6 +449,10 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) + skylight (3.1.2) + skylight-core (= 3.1.2) + skylight-core (3.1.2) + activesupport (>= 4.2.0) slack-notifier (2.3.2) sprockets (3.7.2) concurrent-ruby (~> 1.0) @@ -582,6 +586,7 @@ DEPENDENCIES serendipitous! shoulda-matchers (~> 3.1) simplecov + skylight slack-notifier sqlite3 stackprof diff --git a/config/initializers/social_share_button.rb b/config/initializers/social_share_button.rb deleted file mode 100644 index 0d17d72a..00000000 --- a/config/initializers/social_share_button.rb +++ /dev/null @@ -1,5 +0,0 @@ -SocialShareButton.configure do |config| - config.allow_sites = %w(twitter facebook google_plus weibo qq douban google_bookmark - delicious tumblr pinterest email linkedin wechat vkontakte - xing reddit hacker_news telegram odnoklassniki) -end diff --git a/config/skylight.yml b/config/skylight.yml new file mode 100644 index 00000000..cffe8227 --- /dev/null +++ b/config/skylight.yml @@ -0,0 +1,4 @@ +--- +# The authentication token for the application. +# I think this is actually ignored if the ENV var is set, but this is fine for reference / dummy data. +authentication: ENV['SKYLIGHT_AUTHENTICATION'] From 97bf9c16cbfcace3c4aa60f12113a5e3f7394ddc Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 2 Dec 2018 16:32:19 -0600 Subject: [PATCH 4/4] don't throw 500s when trying to find() nonexistent pages --- app/controllers/content_controller.rb | 3 ++- app/controllers/users_controller.rb | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index f5db9127..74ee2874 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -40,7 +40,8 @@ class ContentController < ApplicationController def show content_type = content_type_from_controller(self.class) return redirect_to root_path unless valid_content_types.map(&:name).include?(content_type.name) - @content = content_type.find(params[:id]) + @content = content_type.find_by(id: params[:id]) + return redirect_to(root_path, notice: "You don't have permission to view that content.") if @content.nil? @serialized_content = ContentSerializer.new(@content) return redirect_to(root_path) if @content.user.nil? # deleted user's content diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9435ea5a..f341616f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,7 +4,9 @@ class UsersController < ApplicationController end def show - @user = User.find(params[:id]) + @user = User.find_by(id: params[:id]) + return redirect_to(root_path, notice: 'That user does not exist.') if @user.nil? + @content = @user.public_content.select { |type, list| list.any? } @tabs = @content.keys @stream = @user.content_change_events.order('updated_at desc').limit(100).group_by do |cce|