Last active
July 17, 2019 08:49
-
-
Save mankind/d14673d216757f847adab81bf3dd7762 to your computer and use it in GitHub Desktop.
attempt to display samvera active-fedora json metatdata field using custom indexer approach
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= presenter.attribute_to_html(:formatted_creator, render_as: :faceted) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JournalArticleIndexer < Hyrax::WorkIndexer | |
def generate_solr_document | |
super.tap do |solr_doc| | |
stored_value = object.creator | |
solr_doc['formatted_creator_tesim'] = JSON.parse(stored_value.first).collect { |hash| format_creator(hash) } if object.creator.present? | |
end | |
end | |
private | |
def format_creator(hash) | |
"name - #{hash['creator_given_name']}: orcid - #{hash['creator_orcid']} : type: #{hash['creator_name_type']}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Hyku | |
class JournalArticlePresenter < ManifestEnabledWorkShowPresenter | |
def creator | |
solr_document.formatted_creator | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Hyrax | |
class JournalArticlesController < ApplicationController | |
self.curation_concern_type = JournalArticle | |
# Use this line if you want to use a custom presenter | |
self.show_presenter = Hyku::JournalArticlePresenter | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#First tried adding attribute but it didn't give me what I want, the I tried adding a method still no success | |
#leaving both code here for feedback from the community | |
class SolrDocument | |
#attribute :formatted_creator, Solr::Array, solr_name('formatted_creator_tesim') | |
def formatted_creator | |
self[Solrizer.solr_name('formatted_creator')] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment