Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Builders #26

Open
travisLilleberg opened this issue Jul 31, 2018 · 2 comments
Open

Custom Builders #26

travisLilleberg opened this issue Jul 31, 2018 · 2 comments

Comments

@travisLilleberg
Copy link

Hello, this is more of a question than a issue, but is there any way to cleanly add a builder to this process?

I need to add thumbnail support to the manifest and I know I can overwrite things and all that, but I was hoping there was a place where I could just insert my own builder and let the code run as intended.

I'm happy to clarify, if I'm not being clear. Thanks.

@cjcolvar
Copy link
Member

@travisLilleberg I'm not sure if there is an easy/clean way to add a builder other than overriding ManifestServiceLocator#manifest_builders and adding in your builder. I'm going to be working on adding thumbnail (and posterCanvas in V3 manifests) soon. Did you figure out a better solution?

@travisLilleberg
Copy link
Author

@cjcolvar

I ended up overriding the Hyrax::WorksControllerBehavior#manifest method in our Image controller - building the json, and then attaching the thumbnail info at the end before rendering it.

module Hyrax
  class ImagesController < CatalogController
    include Hyrax::WorksControllerBehavior
    self.curation_concern_type = ::Image
    self.show_presenter = Hyrax::ImagePresenter

    ###
    # Adds thumbnails to the IIIF Manifest for images.
    def manifest
      headers['Access-Control-Allow-Origin'] = '*'

      manifest_json = manifest_builder.to_h
      manifest_json['thumbnail'] = { '@id' => thumbnail }
      render json: manifest_json
    end

    private

      ###
      # Gets the external thumbnail path of a resource.
      def thumbnail
        thumbnail_path = Hyrax::ThumbnailPathService.call(@presenter).slice(1..-1)
        root_url + thumbnail_path
      end
  end
end

I'm open to better ways of doing this, if you can think of any! I hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants