Sha256: f5763de9ab8a3a7fe25d9148448588e786953f6d50e0a423b3703ff01808ac82

Contents?: true

Size: 893 Bytes

Versions: 12

Compression:

Stored size: 893 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
            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

12 entries across 12 versions & 1 rubygems

Version Path
hyrax-2.0.3 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.0.2 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.0.1 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.0.0 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.0.0.rc3 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.0.0.rc2 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.0.0.rc1 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.0.0.beta5 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.0.0.beta4 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.0.0.beta3 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.0.0.beta2 app/renderers/hyrax/renderers/license_attribute_renderer.rb
hyrax-2.0.0.beta1 app/renderers/hyrax/renderers/license_attribute_renderer.rb