Skip to content

Commit

Permalink
Merge pull request #225 from gwu-libraries/t194-bib
Browse files Browse the repository at this point in the history
T194 bib
  • Loading branch information
kerchner authored Jun 2, 2019
2 parents a8728d5 + dcdd122 commit b13efb7
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 25 deletions.
3 changes: 2 additions & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def self.modified_field
config.add_show_field solr_name("resource_type", :stored_searchable), label: "Resource Type"
config.add_show_field solr_name("format", :stored_searchable), label: "File Format"
config.add_show_field solr_name("identifier", :stored_searchable), label: "Identifier"
config.add_show_field solr_name("gw_affiliation", :stored_searchable), label: "GW Affiliation"
config.add_show_field solr_name("gw_affiliation", :stored_searchable), label: "GW Unit"
config.add_show_field solr_name("bibliographic_citation", :stored_searchable), label: "Previous Publication Information"
config.add_show_field solr_name("degree", :stored_searchable), label: "Degree"
config.add_show_field solr_name("advisor", :stored_searchable), label: "Advisor"
config.add_show_field solr_name("committee_member", :stored_searchable), label: "Committee Member"
Expand Down
92 changes: 92 additions & 0 deletions app/models/concerns/hyrax/solr_document/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
module Hyrax
module SolrDocument
module Metadata
extend ActiveSupport::Concern
class_methods do
def attribute(name, type, field)
define_method name do
type.coerce(self[field])
end
end

def solr_name(*args)
Solrizer.solr_name(*args)
end
end

module Solr
class Array
# @return [Array]
def self.coerce(input)
::Array.wrap(input)
end
end

class String
# @return [String]
def self.coerce(input)
::Array.wrap(input).first
end
end

class Date
# @return [Date]
def self.coerce(input)
field = String.coerce(input)
return if field.blank?
begin
::Date.parse(field)
rescue ArgumentError
Rails.logger.info "Unable to parse date: #{field.first.inspect}"
end
end
end
end

included do
attribute :identifier, Solr::Array, solr_name('identifier')
attribute :based_near, Solr::Array, solr_name('based_near')
attribute :based_near_label, Solr::Array, solr_name('based_near_label')
attribute :related_url, Solr::Array, solr_name('related_url')
attribute :resource_type, Solr::Array, solr_name('resource_type')
attribute :edit_groups, Solr::Array, ::Ability.edit_group_field
attribute :edit_people, Solr::Array, ::Ability.edit_user_field
attribute :read_groups, Solr::Array, ::Ability.read_group_field
attribute :collection_ids, Solr::Array, 'collection_ids_tesim'
attribute :admin_set, Solr::Array, solr_name('admin_set')
attribute :member_of_collection_ids, Solr::Array, solr_name('member_of_collection_ids', :symbol)
attribute :description, Solr::Array, solr_name('description')
attribute :title, Solr::Array, solr_name('title')
attribute :contributor, Solr::Array, solr_name('contributor')
attribute :subject, Solr::Array, solr_name('subject')
attribute :publisher, Solr::Array, solr_name('publisher')
attribute :language, Solr::Array, solr_name('language')
attribute :keyword, Solr::Array, solr_name('keyword')
attribute :license, Solr::Array, solr_name('license')
attribute :source, Solr::Array, solr_name('source')
attribute :date_created, Solr::Array, solr_name('date_created')
attribute :rights_statement, Solr::Array, solr_name('rights_statement')
attribute :bibliographic_citation, Solr::Array, solr_name('bibliographic_citation')

attribute :mime_type, Solr::String, solr_name('mime_type', :stored_sortable)
attribute :workflow_state, Solr::String, solr_name('workflow_state_name', :symbol)
attribute :human_readable_type, Solr::String, solr_name('human_readable_type', :stored_searchable)
attribute :representative_id, Solr::String, solr_name('hasRelatedMediaFragment', :symbol)
# extract the term name from the rendering_predicate (it might be after the final / or #)
attribute :rendering_ids, Solr::Array, solr_name(Hyrax.config.rendering_predicate.value.split(/#|\/|,/).last, :symbol)
attribute :thumbnail_id, Solr::String, solr_name('hasRelatedImage', :symbol)
attribute :thumbnail_path, Solr::String, CatalogController.blacklight_config.index.thumbnail_field
attribute :label, Solr::String, solr_name('label')
attribute :file_format, Solr::String, solr_name('file_format')
attribute :suppressed?, Solr::String, solr_name('suppressed', Solrizer::Descriptor.new(:boolean, :stored, :indexed))

attribute :date_modified, Solr::Date, solr_name('date_modified', :stored_sortable, type: :date)
attribute :date_uploaded, Solr::Date, solr_name('date_uploaded', :stored_sortable, type: :date)
attribute :create_date, Solr::Date, solr_name('system_create', :stored_sortable, type: :date)
attribute :modified_date, Solr::Date, solr_name('system_modified', :stored_sortable, type: :date)
attribute :embargo_release_date, Solr::Date, Hydra.config.permissions.embargo.release_date
attribute :lease_expiration_date, Solr::Date, Hydra.config.permissions.lease.expiration_date
end
end
end
end
2 changes: 1 addition & 1 deletion app/presenters/hyrax/gw_etd_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Hyrax
class GwEtdPresenter < GwWorkPresenter
delegate :gw_affiliation, to: :solr_document
delegate :gw_affiliation, :bibliographic_citation, to: :solr_document
delegate :degree, :advisor, :committee_member, to: :solr_document

def permanent_url
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/hyrax/gw_work_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Hyrax
class GwWorkPresenter < Hyrax::WorkShowPresenter
delegate :gw_affiliation, to: :solr_document
delegate :gw_affiliation, :bibliographic_citation, to: :solr_document

def permanent_url
Scholarspace::Application.config.permanent_url_base + "work/#{id}"
Expand Down
1 change: 1 addition & 0 deletions app/views/hyrax/gw_etds/_attribute_rows.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
<%= presenter.attribute_to_html(:advisor, render_as: :faceted) %>
<%= presenter.attribute_to_html(:committee_member, render_as: :faceted) %>
<%= presenter.attribute_to_html(:permanent_url, render_as: :external_link) %>
<%= presenter.attribute_to_html(:bibliographic_citation, render_as: :faceted) %>
1 change: 1 addition & 0 deletions app/views/hyrax/gw_works/_attribute_rows.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
<%= presenter.attribute_to_html(:advisor, render_as: :faceted) %>
<%= presenter.attribute_to_html(:committee_member, render_as: :faceted) %>
<%= presenter.attribute_to_html(:permanent_url, render_as: :external_link) %>
<%= presenter.attribute_to_html(:bibliographic_citation, render_as: :faceted) %>
32 changes: 10 additions & 22 deletions config/locales/hyrax.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,17 @@ project from which the work was derived."
search:
fields:
show:
resource_type_tesim: Type of Work
based_near_tesim: Location
contributor_tesim: Contributor
creator_tesim: Author
resource_type: Type of Work
based_near_label: Location
contributor: Contributor
creator: Author
description_tesim: Description
gw_affiliation_tesim: GW Unit
degree_tesim: Degree
advisor_tesim: Advisor
committee_member_tesim: Committee Member(s)
bibliographic_citation_tesim: Previous Publication Information
permanent_url_tesim: Persistent URL
index:
resource_type_tesim: Type of Work
based_near_tesim: Location
contributor_tesim: Contributor
creator_tesim: Author
description_tesim: Description
gw_affiliation_tesim: GW Unit
degree_tesim: Degree
advisor_tesim: Advisor
committee_member_tesim: Committee Member(s)
bibliographic_citation_tesim: Previous Publication Information
permanent_url_tesim: Persistent URL
gw_affiliation: GW Unit
degree: Degree
advisor: Advisor
committee_member: Committee Member(s)
bibliographic_citation: Previous Publication Information
permanent_url: Persistent URL
facet:
gw_affiliation_sim: GW Unit
degree_sim: Degree
Expand Down

0 comments on commit b13efb7

Please sign in to comment.