Skip to content
This repository has been archived by the owner on May 14, 2022. It is now read-only.

Commit

Permalink
Updating Blacklight display logic for dates and languages to use disp…
Browse files Browse the repository at this point in the history
…lay values

instead of codes.
  • Loading branch information
escowles committed Oct 21, 2016
1 parent 916e67d commit 52ffb0a
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 1,468 deletions.
12 changes: 8 additions & 4 deletions app/controllers/catalog_controller.rb
Expand Up @@ -56,10 +56,14 @@ def self.search_config
config.add_index_field solr_name('contributor', :stored_searchable)
config.add_index_field solr_name('publisher', :stored_searchable)
config.add_index_field solr_name('based_near', :stored_searchable)
config.add_index_field solr_name('language', :stored_searchable)
config.add_index_field solr_name('language', :stored_searchable) do |field|
field.accessor = :language_display
end
config.add_index_field solr_name('date_uploaded', :stored_sortable)
config.add_index_field solr_name('date_modified', :stored_sortable)
config.add_index_field solr_name('date_created', :stored_searchable)
config.add_index_field solr_name('date_created', :stored_searchable) do |field|
field.accessor = :date_created_display
end
config.add_index_field solr_name('human_readable_type', :stored_searchable)
config.add_index_field solr_name('format', :stored_searchable)
config.add_index_field solr_name('identifier', :stored_searchable)
Expand Down Expand Up @@ -242,8 +246,8 @@ def self.search_config
# If there are more than this many search results, no spelling ("did you
# mean") suggestion is offered.
config.spell_max = 5
config.index_presenter_class = RTLIndexPresenter
config.show_presenter_class = RTLShowPresenter
config.index.document_presenter_class = RTLIndexPresenter
config.show.document_presenter_class = RTLShowPresenter
end
def admin_state_facet
return unless can? :create, ScannedResource
Expand Down
3 changes: 3 additions & 0 deletions app/indexers/work_indexer.rb
Expand Up @@ -24,6 +24,9 @@ def generate_solr_document
solr_doc[Solrizer.solr_name("#{field}_literals", :symbol)] = output
end
solr_doc[Solrizer.solr_name("identifier", :symbol)] = object.identifier
solr_doc[Solrizer.solr_name("language", :facetable)] = object.language.map do |code|
LanguageService.label(code)
end
end
end
end
8 changes: 8 additions & 0 deletions app/models/solr_document.rb
Expand Up @@ -25,6 +25,10 @@ def date_created
self[Solrizer.solr_name('date_created')]
end

def date_created_display
DateValue.new(date_created).to_a
end

def state
Array(self[Solrizer.solr_name("state")]).first
end
Expand Down Expand Up @@ -78,6 +82,10 @@ def language
self[Solrizer.solr_name('language')]
end

def language_display
(language || []).map { |code| LanguageService.label(code) }
end

def source_metadata_identifier
self[Solrizer.solr_name('source_metadata_identifier')]
end
Expand Down
5 changes: 1 addition & 4 deletions app/services/language_service.rb
@@ -1,8 +1,5 @@
module LanguageService
mattr_accessor :authority
self.authority = Qa::Authorities::Local.subauthority_for('iso639')

def self.label(id)
authority.find(id).fetch('term', id)
ISO_639.find_by_code(id).try(:english_name) || id
end
end

0 comments on commit 52ffb0a

Please sign in to comment.