diff --git a/Gemfile b/Gemfile index bdc17a3dc..d75f25b0a 100644 --- a/Gemfile +++ b/Gemfile @@ -97,6 +97,10 @@ gem 'mini_magick', '~> 4.11' # manually add this gem to enable questioning_authority to parse linked-data results gem 'linkeddata', '~> 3.1.6' +# Generate non-digested copies of application.css and application.js +# (allows us to reference assets in the static error pages) +gem 'non-digest-assets', '~> 2.2.0' + # system monitoring gem 'okcomputer', '~> 1.18.4' diff --git a/Gemfile.lock b/Gemfile.lock index ad0fb49e1..1f500455e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -642,8 +642,9 @@ GEM nokogiri (1.15.3) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.15.3-arm64-darwin) - racc (~> 1.4) + non-digest-assets (2.2.0) + activesupport (>= 5.2, < 7.1) + sprockets (>= 2.0, < 5.0) oai (0.4.0) builder (>= 3.1.0) faraday @@ -1087,6 +1088,7 @@ DEPENDENCIES linkeddata (~> 3.1.6) listen (>= 3.0.5, < 3.8) mini_magick (~> 4.11) + non-digest-assets (~> 2.2.0) okcomputer (~> 1.18.4) pg (~> 1.2.3) puma (~> 6.1.1) @@ -1116,4 +1118,4 @@ DEPENDENCIES webmock (~> 3.8) BUNDLED WITH - 2.4.14 + 2.4.7 diff --git a/app/controllers/error_controller.rb b/app/controllers/error_controller.rb deleted file mode 100644 index daeb747df..000000000 --- a/app/controllers/error_controller.rb +++ /dev/null @@ -1,53 +0,0 @@ -# frozen_string_literal: true -class ErrorController < ApplicationController - before_action :set_status - - respond_to :html - - def show - respond_to do |format| - format.html { render @status.to_s, status: @status.to_i } - format.json { render json: json_response, status: @status.to_i } - format.text { render plain: plain_text_response, status: @status.to_i } - end - rescue - send_honeybadger_notification! - - # fallback for statuses that we haven't created a view for - render '500', status: :internal_server_error - end - - private - - def json_response - %({"error": true, "status": #{@status.to_i}, "message": "#{status_message}"}) - end - - def plain_text_response - "#{@status} #{status_message}" - end - - def status_message - Rack::Utils::HTTP_STATUS_CODES.fetch(@status, '') - end - - def send_honeybadger_notification! - Honeybadger.notify( - 'An error occurred causing a 500 page to render', - backtrace: @exception.full_trace, - controller: self.class.name.to_s, - action: action_name, - parameters: params - ) - end - - def set_status - backtrace_cleaner = request.env['action_dispatch.backtrace_cleaner'] - raw_exception = request.env['action_dispatch.exception'] - @exception = ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, raw_exception) - @status = @exception.status_code - - # hyrax's dashboard_helper_behavior is expecting this to be defined from a route - params[:controller] = self.class.name.to_s - end -end diff --git a/app/views/error/404.html.erb b/app/views/error/404.html.erb deleted file mode 100644 index a6a2df6c8..000000000 --- a/app/views/error/404.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<% provide(:page_title) { t('spot.error.404.page_title', name: application_name) } %> - -<%= image_tag('404-splash.jpg', class: 'img-responsive') %> - -
-

Not found

-
- -

- The page you requested could not be found. -

diff --git a/app/views/error/500.html.erb b/app/views/error/500.html.erb deleted file mode 100644 index d8b779ecf..000000000 --- a/app/views/error/500.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<% provide(:page_title) { t('spot.error.500.page_title', name: application_name) } %> - -<%= image_tag('500-splash.jpg', class: 'img-responsive') %> - - - -

- Well this is embarrassing! We've encountered an error with your request. -

diff --git a/config/environments/production.rb b/config/environments/production.rb index 8433d18a9..f3faa27f4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -103,10 +103,6 @@ # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - # use our error_controller to render error pages - # (see: https://stackoverflow.com/a/24239490) - config.exceptions_app = ->(env) { ErrorController.action(:show).call(env) } - # use ssl for everything config.force_ssl = true end diff --git a/public/404.html b/public/404.html index 2be3af26f..0629b72e7 100644 --- a/public/404.html +++ b/public/404.html @@ -1,67 +1,110 @@ - - - The page you were looking for doesn't exist (404) - - - +
+ +
+ + + + + + + +
+ + - - -
-
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

+
+

Not found

-

If you are the application owner check the logs for more information.

-
- - + +

+ The page you requested could not be found. +

+ + +
+ + + + \ No newline at end of file diff --git a/public/422.html b/public/422.html deleted file mode 100644 index c08eac0d1..000000000 --- a/public/422.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - The change you wanted was rejected (422) - - - - - - -
-
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/public/500.html b/public/500.html index 78a030af2..a8685ef92 100644 --- a/public/500.html +++ b/public/500.html @@ -1,66 +1,107 @@ - - - We're sorry, but something went wrong (500) - - - - - - -
-
-

We're sorry, but something went wrong.

+
+ +
+
+
+ +
+ + + +
+ + + -

If you are the application owner check the logs for more information.

-
- - + +

+ Well this is embarrassing! We've encountered an error with your request. +

+ + + + + \ No newline at end of file diff --git a/spec/features/error_page_spec.rb b/spec/features/error_page_spec.rb deleted file mode 100644 index 3ae2d9ba2..000000000 --- a/spec/features/error_page_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true -RSpec.describe 'error page rendering', type: :request do - before { allow(Honeybadger).to receive(:notify) } - - describe '404' do - it 'renders the 404 page' do - without_detailed_exceptions do - get '/this/does/not/exist' - end - - expect(response).to have_http_status(:not_found) - expect(response.body).to include 'The page you requested could not be found.' - end - - context '.txt' do - it 'renders the error in plain text' do - without_detailed_exceptions do - get '/this/does/not/exist.txt' - end - - expect(response).to have_http_status(:not_found) - expect(response.body).to eq '404 Not Found' - end - end - - context '.json' do - let(:json_response) do - %({"error": true, "status": 404, "message": "Not Found"}) - end - - it 'renders the error as json' do - without_detailed_exceptions do - get '/this/does/not/exist.json' - end - - expect(response).to have_http_status(:not_found) - expect(response.body).to eq json_response - end - end - end - - describe '500 (catch-all)' do - before do - allow(Spot::HomepageController).to receive(:new).and_return(mock_homepage) - allow(mock_homepage).to receive(:index).and_raise('oops nope') - end - - let(:mock_homepage) { instance_double(Spot::HomepageController) } - - it 'falls-back to the 500 error page' do - without_detailed_exceptions do - get '/' - end - - expect(response).to have_http_status(:internal_server_error) - expect(response.body).to include 'Something went wrong!' - end - end -end