Sha256: 02a0a7238e8763d84e5d0d12ac171c5ebb0538a7d79661eaed72a42c3866a7f1

Contents?: true

Size: 914 Bytes

Versions: 36

Compression:

Stored size: 914 Bytes

Contents

module Hyrax
  module Renderers
    # This is used by PresentsAttributes to show licenses
    #   e.g.: presenter.attribute_to_html(:license, render_as: :license)
    class LicenseAttributeRenderer < AttributeRenderer
      private

        ##
        # Special treatment for license/rights.  A URL from the Hyrax gem's config/hyrax.rb is stored in the descMetadata of the
        # curation_concern.  If that URL is valid in form, then it is used as a link.  If it is not valid, it is used as plain text.
        def attribute_value_to_html(value)
          begin
            parsed_uri = URI.parse(value)
          rescue URI::InvalidURIError
            nil
          end
          if parsed_uri.nil?
            ERB::Util.h(value)
          else
            %(<a href=#{ERB::Util.h(value)} target="_blank">#{Hyrax.config.license_service_class.new.label(value)}</a>)
          end
        end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.9.5 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.9.4 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.9.3 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.9.2 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.9.1 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.9.0 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.8.0 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.7.2 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.7.1 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.7.0 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.6.0 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-3.0.0.pre.rc1 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-3.0.0.pre.beta3 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.5.1 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.5.0 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-3.0.0.pre.beta2 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.4.1 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-3.0.0.pre.beta1 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.4.0 app/renderers/hyrax/renderers/license_attribute_renderer.rb