Skip to content
Snippets Groups Projects
Commit 225b20b1 authored by Gyan Gupta's avatar Gyan Gupta
Browse files

Fixes citations display style and custom error pages

parent 0bd11db0
Branches bug_fix/fixes-for-issues-36-32
No related tags found
2 merge requests!387Fixes citations display style and custom error pages,!346Draft: Hyrax 5 - Upgrade hyrax to v5
Pipeline #20857 failed
......@@ -83,6 +83,19 @@ a[disabled="disabled"] {
display: inline;
}
.rails-default-error-page {
color: #2e2f30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
.dialog-heading .heading-title {
font-size: 100%;
font-weight: 600;
color: #730e15;
line-height: 1.5em;
}
.agreement-wrapper div.dialog {
width: 95%;
......
class ApplicationController < ActionController::Base
rescue_from Seahorse::Client::NetworkingError, with: :handle_s3_networking_error
helper Openseadragon::OpenseadragonHelper
# Adds a few additional behaviors into the application controller
include Blacklight::Controller
......@@ -12,6 +13,15 @@ class ApplicationController < ActionController::Base
private
def handle_s3_networking_error(exception)
respond_to do |format|
format.html do
render 'errors/error_message', locals: { heading: "Connectivity Issue", description: t('hyrax.uploads.js_templates.options.messages.s3_server_error') }, status: :internal_server_error
end
format.json { render plain: 's3_server_error', status: 500 }
end
end
def check_agreement_acceptance
if current_user.present? && !current_user.agreement_accepted?
redirect_to main_app.deposite_agreement_path
......
# app/controllers/errors_controller.rb
class ErrorsController < ApplicationController
def not_found
render template: 'errors/error_message'
end
def internal_server_error
render template: 'errors/error_message'
end
def unprocessable_entity
render template: 'errors/error_message'
end
def access_forbidden
render template: 'errors/error_message'
end
end
<%
heading = local_assigns[:heading] || t("rdms.errors.#{params[:action]}.heading")
description = local_assigns[:description] || t("rdms.errors.#{params[:action]}.description")
%>
<div class="rails-default-error-page mt-3">
<div class="dialog">
<div class="dialog-heading">
<h1 class="heading-title"><%= heading %></h1>
<p class="heading-body"><%= description %></p>
</div>
<p class="dialog-body"><%= t("rdms.errors.suggestion")%></p>
</div>
</div>
\ No newline at end of file
<div class="modal fade" id="citations-modal" tabindex="-1" role="dialog" aria-labelledby="citations-modal-title" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title w-100 text-center" id="citations-modal-title"><%= t("hyrax.citations.citation") %></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body wpi-citation-modal">
<div class="cite mt-3">
<h4 class="text-left">MLA</h4>
<span class="mla-citation"><%= export_as_mla_citation(presenter) %></span>
</div>
<div class="cite mt-3">
<h4 class="text-left">APA</h4>
<span class="apa-citation"><%= export_as_apa_citation(presenter) %></span>
</div>
<div class="cite mt-3">
<h4 class="text-left">Chicago</h4>
<span class="chicago-citation"><%= export_as_chicago_citation(presenter) %></span>
</div>
</div>
<div class="modal-footer justify-content-center">
<ul class="list-inline d-flex">
<li><%= link_to t('.endnote'), polymorphic_path([main_app, presenter], format: 'endnote') %></li>
<li><%= link_to t('.zotero'), hyrax.zotero_path, id: 'zoteroLink', name: 'zotero' %></li>
<li><%= link_to t('.mendeley'), hyrax.mendeley_path, id: 'mendeleyLink', name: 'mendeley' %></li>
</ul>
</div>
</div>
</div>
</div>
......@@ -14,14 +14,6 @@
</h2>
<% end %>
<% end %>
<div class="row">
<% if is_published?(presenter) %>
<div class="col-md-3">
<%= render 'citations', presenter: @presenter %>
<%= render 'social_media' %>
</div>
<% end %>
</div>
</div>
</div>
</div>
\ No newline at end of file
......@@ -21,7 +21,11 @@
<div class="col-sm-3 text-center">
<%= render 'download_all', presenter: @presenter %>
<% if is_published?(@presenter) %>
<%= render 'citations', presenter: @presenter %>
<div class="citations">
<% if Hyrax.config.citations? %>
<button class="btn btn-default citation-modal-btn" data-toggle="modal" data-target="#citations-modal"><%= t(".citations") %></button>
<% end %>
</div>
<%= render 'social_media' %>
<% end %>
</div>
......@@ -61,4 +65,8 @@
<% end %>
</div>
</div>
\ No newline at end of file
</div>
<% if is_published?(@presenter) && Hyrax.config.citations? %>
<%= render "citations_modal", presenter: @presenter %>
<% end %>
\ No newline at end of file
......@@ -11,6 +11,7 @@ module Hyrax
config.hosts << ENV.fetch('APP_HOST')
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.1
config.exceptions_app = self.routes
config.active_job.queue_adapter = ENV.fetch('HYRAX_ACTIVE_JOB_QUEUE') { 'async' }.to_sym
......
......@@ -54,6 +54,12 @@ Rails.application.routes.draw do
resources :download_all, only: [:show] do
get 'button_ready/:id', :to => "download_all#button_ready", on: :collection
end
get "/404", to: "errors#not_found", via: :all
get "/500", to: "errors#internal_server_error", via: :all
get "/422", to: "errors#unprocessable_entity", via: :all
get "/403", to: "errors#access_forbidden", via: :all
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment