Skip to content

Commit

Permalink
adds quickfix to redirect old-style NYU slugs
Browse files Browse the repository at this point in the history
  • Loading branch information
sgbalogh committed Jul 6, 2018
1 parent 5565726 commit 84c53a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class CatalogController < ApplicationController
# include BlacklightRangeLimit::ControllerOverride

include Blacklight::Catalog
include NyuSlugConcern

configure_blacklight do |config|
## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
Expand Down
19 changes: 19 additions & 0 deletions app/controllers/concerns/nyu_slug_concern.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module NyuSlugConcern
extend Blacklight::Catalog

# Override of main show method to catch old-style
# NYU slugs ("nyu_2451_12345") and turn them into
# new style ("nyu-2451-12345")
def show
if /^nyu_\d{4}_\d{5}$/.match(params[:id])
params[:id] = params[:id].gsub("_","-")
end
@response, @document = fetch params[:id]
respond_to do |format|
format.html { setup_next_and_previous_documents }
format.json { render json: { response: { document: @document } } }
additional_export_formats(@document, format)
end
end

end

0 comments on commit 84c53a1

Please sign in to comment.