From 1eb73a72925f93a34034b8c57ce740e1c3cbc349 Mon Sep 17 00:00:00 2001 From: Daniel Pierce Date: Fri, 8 Nov 2024 17:37:19 -0500 Subject: [PATCH] Implement custom metadata for data catalog --- app/controllers/catalog_controller.rb | 66 ++++--- app/models/solr_document.rb | 25 ++- app/presenters/hyrax/data_set_presenter.rb | 5 +- .../renderers/markdown_attribute_renderer.rb | 14 ++ app/views/hyrax/base/_attribute_rows.html.erb | 47 ++--- config/metadata/data_set.yaml | 181 +++++++++++++----- 6 files changed, 221 insertions(+), 117 deletions(-) create mode 100644 app/renderers/hyrax/renderers/markdown_attribute_renderer.rb diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index dc7f902..562879e 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -15,9 +15,9 @@ def self.modified_field end configure_blacklight do |config| - config.view.gallery(document_component: Blacklight::Gallery::DocumentComponent, icon: Blacklight::Gallery::Icons::GalleryComponent) - config.view.masonry(document_component: Blacklight::Gallery::DocumentComponent, icon: Blacklight::Gallery::Icons::MasonryComponent) - config.view.slideshow(document_component: Blacklight::Gallery::SlideshowComponent, icon: Blacklight::Gallery::Icons::SlideshowComponent) + # config.view.gallery(document_component: Blacklight::Gallery::DocumentComponent, icon: Blacklight::Gallery::Icons::GalleryComponent) + # config.view.masonry(document_component: Blacklight::Gallery::DocumentComponent, icon: Blacklight::Gallery::Icons::MasonryComponent) + # config.view.slideshow(document_component: Blacklight::Gallery::SlideshowComponent, icon: Blacklight::Gallery::Icons::SlideshowComponent) config.show.tile_source_field = :content_metadata_image_iiif_info_ssm config.show.partials.insert(1, :openseadragon) config.search_builder_class = Hyrax::CatalogSearchBuilder @@ -30,7 +30,7 @@ def self.modified_field config.default_solr_params = { qt: "search", rows: 10, - qf: "title_tesim description_tesim creator_tesim keyword_tesim" + qf: "title_tesim abstract_tesim description_tesim creator_tesim subject_tesim geographic_location_tesim domain_subject_tesim" } # solr field configuration for document/show views @@ -51,20 +51,24 @@ def self.modified_field # solr fields that will be treated as facets by the blacklight application # The ordering of the field names is the order of the display - config.add_facet_field "human_readable_type_sim", label: "Type", limit: 5 - config.add_facet_field "resource_type_sim", label: "Resource Type", limit: 5 - config.add_facet_field "creator_sim", limit: 5 - config.add_facet_field "contributor_sim", label: "Contributor", limit: 5 - config.add_facet_field "keyword_sim", limit: 5 - config.add_facet_field "subject_sim", limit: 5 - config.add_facet_field "language_sim", limit: 5 - config.add_facet_field "based_near_label_sim", limit: 5 - config.add_facet_field "publisher_sim", limit: 5 - config.add_facet_field "file_format_sim", limit: 5, label: 'File Format' - config.add_facet_field "time_frame_sim", limit: 5, label: 'Timeframe' - config.add_facet_field "data_location_sim", limit: 5, label: 'Data Location' - config.add_facet_field "hosting_unit_sim", limit: 5, label: 'Hosting Unit' - config.add_facet_field "member_of_collection_ids_ssim", limit: 5, label: 'Collections', helper_method: :collection_title_by_id + config.add_facet_field "domain_subject_sim", limit: 10, label: 'Domain Subject' + config.add_facet_field "campus_sim", limit: 10, label: 'Campus' + config.add_facet_field "holding_location_sim", limit: 10, label: 'Hosting Unit' + # config.add_facet_field "rights_statement_sim", limit: 10, label: 'Access Restrictions' + # config.add_facet_field "human_readable_type_sim", label: "Type", limit: 5 + # config.add_facet_field "resource_type_sim", label: "Resource Type", limit: 5 + # config.add_facet_field "creator_sim", limit: 5 + # config.add_facet_field "contributor_sim", label: "Contributor", limit: 5 + # config.add_facet_field "keyword_sim", limit: 5 + # config.add_facet_field "subject_sim", limit: 5 + # config.add_facet_field "language_sim", limit: 5 + # config.add_facet_field "based_near_label_sim", limit: 5 + # config.add_facet_field "publisher_sim", limit: 5 + # config.add_facet_field "file_format_sim", limit: 5, label: 'File Format' + # config.add_facet_field "time_frame_sim", limit: 5, label: 'Timeframe' + # config.add_facet_field "data_location_sim", limit: 5, label: 'Data Location' + # config.add_facet_field "hosting_unit_sim", limit: 5, label: 'Hosting Unit' + # config.add_facet_field "member_of_collection_ids_ssim", limit: 5, label: 'Collections', helper_method: :collection_title_by_id # The generic_type and depositor are not displayed on the facet list # They are used to give a label to the filters that comes from the user profile @@ -79,24 +83,26 @@ def self.modified_field # solr fields to be displayed in the index (search results) view # The ordering of the field names is the order of the display config.add_index_field "title_tesim", label: "Title", itemprop: 'name', if: false - config.add_index_field "summary_tesim", label: "Summary", itemprop: 'summary', helper_method: :render_markdown - config.add_index_field "keyword_tesim", itemprop: 'keywords', link_to_facet: "keyword_sim" + config.add_index_field "abstract_tesim", label: "Summary", itemprop: 'summary', helper_method: :render_markdown + config.add_index_field "domain_subject_tesim", label: 'Domain Subject', itemprop: 'keywords', link_to_facet: "domain_subject_sim" + config.add_index_field "campus_tesim", label: 'Campus', itemprop: 'campus', link_to_facet: "campus_sim" + config.add_index_field "holding_location_tesim", label: 'Hosting Unit', link_to_facet: "holding_location_sim" + config.add_index_field "rights_statement_tesim", label: 'Access Restrictions', link_to_facet: 'rights_statement_sim', helper_method: :rights_statement_links # config.add_index_field "subject_tesim", itemprop: 'about', link_to_facet: "subject_sim" - config.add_index_field "creator_tesim", itemprop: 'creator', link_to_facet: "creator_sim" - config.add_index_field "contributor_tesim", itemprop: 'contributor', link_to_facet: "contributor_sim" - config.add_index_field "proxy_depositor_ssim", label: "Depositor", helper_method: :link_to_profile + # config.add_index_field "creator_tesim", itemprop: 'creator', link_to_facet: "creator_sim" + # config.add_index_field "contributor_tesim", itemprop: 'contributor', link_to_facet: "contributor_sim" + # config.add_index_field "proxy_depositor_ssim", label: "Depositor", helper_method: :link_to_profile # config.add_index_field "depositor_tesim", label: "Owner", helper_method: :link_to_profile - config.add_index_field "publisher_tesim", itemprop: 'publisher', link_to_facet: "publisher_sim" - config.add_index_field "based_near_label_tesim", itemprop: 'contentLocation', link_to_facet: "based_near_label_sim" - config.add_index_field "language_tesim", itemprop: 'inLanguage', link_to_facet: "language_sim" + # config.add_index_field "publisher_tesim", itemprop: 'publisher', link_to_facet: "publisher_sim" + # config.add_index_field "based_near_label_tesim", itemprop: 'contentLocation', link_to_facet: "based_near_label_sim" + # config.add_index_field "language_tesim", itemprop: 'inLanguage', link_to_facet: "language_sim" # config.add_index_field "date_uploaded_dtsi", itemprop: 'datePublished', helper_method: :human_readable_date # config.add_index_field "date_modified_dtsi", itemprop: 'dateModified', helper_method: :human_readable_date # config.add_index_field "date_created_tesim", itemprop: 'dateCreated' - config.add_index_field "rights_statement_tesim", helper_method: :rights_statement_links - config.add_index_field "license_tesim", helper_method: :license_links - config.add_index_field "resource_type_tesim", label: "Resource Type", link_to_facet: "resource_type_sim" + # config.add_index_field "license_tesim", helper_method: :license_links + # config.add_index_field "resource_type_tesim", label: "Resource Type", link_to_facet: "resource_type_sim" # config.add_index_field "file_format_tesim", link_to_facet: "file_format_sim" - config.add_index_field "identifier_tesim", helper_method: :index_field_link, field_name: 'identifier' + # config.add_index_field "identifier_tesim", helper_method: :index_field_link, field_name: 'identifier' # config.add_index_field "data_location_tesim", link_to_facet: "data_location_sim" # config.add_index_field "time_frame_tesim", link_to_facet: "time_frame_sim" # config.add_index_field "hosting_unit_tesim", link_to_facet: "hosting_unit_sim" diff --git a/app/models/solr_document.rb b/app/models/solr_document.rb index 9850fa1..6ffdec5 100644 --- a/app/models/solr_document.rb +++ b/app/models/solr_document.rb @@ -28,14 +28,21 @@ class SolrDocument use_extension( Hydra::ContentNegotiation ) - attribute :summary, Solr::String, "summary_tesim" - attribute :documentation, Solr::String, "documentation_tesim" - attribute :access_summary, Solr::String, "access_summary_tesim" - attribute :access_process, Solr::String, "access_process_tesim" - attribute :data_location, Solr::Array, "data_location_tesim" - attribute :time_frame, Solr::Array, "time_frame_tesim" - attribute :file_format, Solr::Array, "file_format_tesim" - attribute :hosting_unit, Solr::Array, "hosting_unit_tesim" - attribute :public_contact, Solr::Array, "public_contact_tesim" + attribute :abstract, Solr::Array, "abstract_tesim" + attribute :description, Solr::Array, "description_tesim" + attribute :related_url, Solr::Array, "related_url_tesim" + attribute :rights_notes, Solr::Array, "rights_notes_tesim" + attribute :time_period, Solr::Array, "time_period_tesim" + attribute :subject, Solr::Array, "subject_tesim" + attribute :geographic_location, Solr::Array, "geographic_location_tesim" + attribute :domain_subject, Solr::Array, "domain_subject_tesim" + attribute :creator, Solr::Array, "creator_tesim" + attribute :location_physical, Solr::Array, "location_physical_tesim" + attribute :digital_specifications, Solr::Array, "digital_specifications_tesim" + attribute :expert, Solr::Array, "expert_tesim" + attribute :holding_location, Solr::Array, "holding_location_tesim" + attribute :campus, Solr::Array, "campus_tesim" + attribute :rights_statement, Solr::Array, "rights_statement_tesim" + attribute :bibliographic_citation, Solr::Array, "bibliographic_citation_tesim" end diff --git a/app/presenters/hyrax/data_set_presenter.rb b/app/presenters/hyrax/data_set_presenter.rb index 47c9377..5d93997 100644 --- a/app/presenters/hyrax/data_set_presenter.rb +++ b/app/presenters/hyrax/data_set_presenter.rb @@ -1,7 +1,8 @@ module Hyrax class DataSetPresenter < Hyrax::WorkShowPresenter - delegate :summary, :documentation, :access_summary, :access_process, :data_location, :time_frame, - :file_format, :hosting_unit, :public_contact, + delegate :abstract, :description, :related_url, :rights_notes, :time_period, :subject, + :geographic_location, :domain_subject, :creator, :location_physical, :digital_specifications, + :expert, :holding_location, :campus, :rights_statement, :bibliographic_citations, to: :solr_document end end \ No newline at end of file diff --git a/app/renderers/hyrax/renderers/markdown_attribute_renderer.rb b/app/renderers/hyrax/renderers/markdown_attribute_renderer.rb new file mode 100644 index 0000000..bbd2c76 --- /dev/null +++ b/app/renderers/hyrax/renderers/markdown_attribute_renderer.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true +module Hyrax + module Renderers + class MarkdownAttributeRenderer < AttributeRenderer + private + + def attribute_value_to_html(value) + # text = value.join("\n\n") + text = value + DataCatalog::MarkdownService.call(text).html_safe + end + end + end +end diff --git a/app/views/hyrax/base/_attribute_rows.html.erb b/app/views/hyrax/base/_attribute_rows.html.erb index eaada55..a53ce04 100644 --- a/app/views/hyrax/base/_attribute_rows.html.erb +++ b/app/views/hyrax/base/_attribute_rows.html.erb @@ -1,31 +1,16 @@ -<%= presenter.attribute_to_html(:documentation, html_dl: true) %> -<%= presenter.attribute_to_html(:access_summary, html_dl: true) %> -<%= presenter.attribute_to_html(:access_process, html_dl: true) %> -<%= presenter.attribute_to_html(:time_frame, render_as: :faceted, html_dl: true) %> -<%= presenter.attribute_to_html(:subject, render_as: :faceted, html_dl: true) %> -<%= presenter.attribute_to_html(:data_location, render_as: :faceted, html_dl: true) %> -<%= presenter.attribute_to_html(:file_format, render_as: :faceted, html_dl: true) %> -<%= presenter.attribute_to_html(:public_contact, html_dl: true) %> -<%= presenter.attribute_to_html(:hosting_unit, render_as: :faceted, html_dl: true) %> - -<%= presenter.attribute_to_html(:alternative_title, html_dl: true) %> -<%= presenter.attribute_to_html(:abstract, html_dl: true) %> -<%= presenter.attribute_to_html(:date_modified, label: t('hyrax.base.show.last_modified'), html_dl: true) %> -<%= presenter.attribute_to_html(:creator, render_as: :faceted, html_dl: true) %> -<%= presenter.attribute_to_html(:contributor, render_as: :faceted, html_dl: true) %> - -<%= presenter.attribute_to_html(:publisher, render_as: :faceted, html_dl: true) %> -<%= presenter.attribute_to_html(:bibliographic_citation, html_dl: true) %> -<%= presenter.attribute_to_html(:language, render_as: :faceted, html_dl: true) %> -<%= presenter.attribute_to_html(:identifier, render_as: :linked, search_field: 'identifier_tesim', html_dl: true) %> -<%= presenter.attribute_to_html(:keyword, render_as: :faceted, html_dl: true) %> -<%= presenter.attribute_to_html(:date_created, render_as: :linked, search_field: 'date_created_tesim', html_dl: true) %> -<%= presenter.attribute_to_html(:based_near_label, html_dl: true) %> -<%= presenter.attribute_to_html(:related_url, render_as: :external_link, html_dl: true) %> -<%= presenter.attribute_to_html(:resource_type, render_as: :faceted, html_dl: true) %> -<%= presenter.attribute_to_html(:source, html_dl: true) %> -<%= presenter.attribute_to_html(:extent, html_dl: true) %> -<%= presenter.attribute_to_html(:rights_statement, render_as: :rights_statement, html_dl: true) %> -<%= presenter.attribute_to_html(:rights_notes, html_dl: true) %> -<%= presenter.attribute_to_html(:access_right, html_dl: true) %> -<%= presenter.attribute_to_html(:license, render_as: :license, html_dl: true) %> +<%= presenter.attribute_to_html(:abstract, label: 'Summary', render_as: :markdown, html_dl: true) %> +<%#= presenter.attribute_to_html(:description, label: 'Description', render_as: :markdown, html_dl: true) %> +<%= presenter.attribute_to_html(:related_url, label: 'Documentation', render_as: :external_link, html_dl: true) %> +<%= presenter.attribute_to_html(:rights_notes, label: 'Access Instructions', html_dl: true) %> +<%= presenter.attribute_to_html(:time_period, label: 'Timeframe', html_dl: true) %> +<%= presenter.attribute_to_html(:subject, label: 'Keyword Subject', html_dl: true) %> +<%= presenter.attribute_to_html(:geographic_location, label: 'Spatial Subject', html_dl: true) %> +<%= presenter.attribute_to_html(:domain_subject, label: 'Domain Subject', render_as: :faceted, html_dl: true) %> +<%= presenter.attribute_to_html(:creator, label: 'Creator', html_dl: true) %> +<%= presenter.attribute_to_html(:location_physical, label: 'Data Location', html_dl: true) %> +<%= presenter.attribute_to_html(:digital_specifications, label: 'File Format(s)', html_dl: true) %> +<%= presenter.attribute_to_html(:expert, label: 'Public Contact', html_dl: true) %> +<%= presenter.attribute_to_html(:holding_location, label: 'Hosting Unit', render_as: :faceted, html_dl: true) %> +<%= presenter.attribute_to_html(:campus, label: 'Campus', render_as: :faceted, html_dl: true) %> +<%= presenter.attribute_to_html(:rights_statement, label: 'Access Restrictions', render_as: :rights_statement, html_dl: true) %> +<%= presenter.attribute_to_html(:bibliographic_citation, label: 'Bibliographic Citation', html_dl: true) %> diff --git a/config/metadata/data_set.yaml b/config/metadata/data_set.yaml index 928f095..0ab87c0 100644 --- a/config/metadata/data_set.yaml +++ b/config/metadata/data_set.yaml @@ -22,118 +22,209 @@ # `rails generate hyrax:work_resource DataSet` attributes: - summary: + abstract: + display_label: Summary + predicate: http://purl.org/dc/terms/abstract type: string - multiple: false + multiple: true index_keys: - - 'summary_tesim' + - 'abstract_tesim' form: required: true primary: true - multiple: false + multiple: true - description: + related_url: + display_label: Documentation + predicate: http://www.w3.org/2000/01/rdf-schema#seeAlso type: string - multiple: false + multiple: true index_keys: - - 'description_tesim' + - 'related_url_tesim' + - 'related_url_sim' form: required: false - primary: false - multiple: false + primary: true + multiple: true - documentation: + rights_notes: + display_label: Access Instructions + predicate: http://purl.org/dc/elements/1.1/rights type: string multiple: true index_keys: - - 'documentation_tesim' + - 'rights_notes_tesim' + - 'rights_notes_sim' form: required: false - primary: false + primary: true multiple: true - access_summary: + time_period: + display_label: Timeframe + predicate: http://purl.org/dc/terms/temporal type: string - multiple: false + multiple: true index_keys: - - 'access_summary_tesim' + - 'time_period_tesim' + - 'time_period_sim' form: required: false - primary: false - multiple: false + primary: true + multiple: true - access_process: + subject: + display_label: Keyword Subject + predicate: http://purl.org/dc/terms/subject type: string multiple: true index_keys: - - 'access_process_tesim' + - 'subject_tesim' + - 'subject_sim' form: required: false - primary: false + primary: true multiple: true - subject: + geographic_location: + display_label: Spatial Subject + predicate: http://purl.org/dc/terms/coverage type: string multiple: true index_keys: - - 'subject_tesim' - - 'subject_sim' + - 'geographic_location_tesim' + - 'geographic_location_sim' + form: + required: false + primary: true + multiple: true + + domain_subject: + display_label: Domain Subject + predicate: http://purl.org/dc/elements/1.1/subject + type: string + multiple: true + index_keys: + - 'domain_subject_tesim' + - 'domain_subject_sim' + form: + required: false + primary: true + multiple: true + + creator: + display_label: Creator + predicate: http://purl.org/dc/terms/creator + type: string + multiple: true + index_keys: + - 'creator_tesim' + - 'creator_sim' form: required: false - primary: false + primary: true + multiple: true + + description: + display_label: Description + predicate: http://purl.org/dc/terms/description + type: string + multiple: true + index_keys: + - 'description_tesim' + form: + required: false + primary: true + multiple: true + + location_physical: + display_label: Data Location + predicate: https://www.loc.gov/standards/mods/rdf/v1/#locationPhysical + type: string + multiple: true + index_keys: + - 'location_physical_tesim' + - 'location_physical_sim' + form: + required: false + primary: true multiple: true - data_location: + digital_specifications: + display_label: File Format(s) + predicate: http://purl.org/dc/elements/1.1/format type: string multiple: true index_keys: - - 'data_location_tesim' - - 'data_location_sim' + - 'digital_specifications_tesim' + - 'digital_specifications_sim' form: required: false - primary: false + primary: true multiple: true - time_frame: + expert: + display_label: 'Public Contact' + predicate: http://id.loc.gov/vocabulary/relators/exp type: string multiple: true index_keys: - - 'time_frame_tesim' - - 'time_frame_sim' + - 'expert_tesim' + - 'expert_sim' form: required: false - primary: false + primary: true multiple: true - file_format: + holding_location: + display_label: Hosting Unit + predicate: http://id.loc.gov/ontologies/bibframe/heldBy type: string multiple: true index_keys: - - 'file_format_tesim' - - 'file_format_sim' + - 'holding_location_tesim' + - 'holding_location_sim' form: required: false - primary: false + primary: true multiple: true - hosting_unit: + campus: + display_label: Campus + predicate: http://id.loc.gov/vocabulary/relators/uvp type: string multiple: true index_keys: - - 'hosting_unit_tesim' - - 'hosting_unit_sim' + - 'campus_tesim' + - 'campus_sim' form: required: false - primary: false + primary: true multiple: true - public_contact: + rights_statement: + display_label: Access Restrictions + predicate: http://www.europeana.eu/schemas/edm/rights type: string multiple: true index_keys: - - 'public_contact_tesim' - - 'public_contact_sim' + - 'rights_statement_sim' form: required: false - primary: false - multiple: true \ No newline at end of file + primary: true + multiple: true + + bibliographic_citation: + display_label: Bibliographic Citation + predicate: http://purl.org/dc/terms/bibliographicCitation + type: string + multiple: true + index_keys: + - 'bibliographic_citation_tesim' + - 'bibliographic_citation_sim' + form: + required: false + primary: true + multiple: true + + # Bulkrax Fields TODO