Sha256: 58afab4ed002b007cc96b8e7add07b2172f3af2d4ff5e48deddecff17421cb58

Contents?: true

Size: 860 Bytes

Versions: 10

Compression:

Stored size: 860 Bytes

Contents

module Hyrax
  module Renderers
    class RightsAttributeRenderer < AttributeRenderer
      private

        def attribute_value_to_html(value)
          rights_attribute_to_html(value)
        end

        ##
        # 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 rights_attribute_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

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 app/renderers/hyrax/renderers/rights_attribute_renderer.rb
hyrax-1.1.0 app/renderers/hyrax/renderers/rights_attribute_renderer.rb
hyrax-1.0.5 app/renderers/hyrax/renderers/rights_attribute_renderer.rb
hyrax-1.0.4 app/renderers/hyrax/renderers/rights_attribute_renderer.rb
hyrax-1.0.3 app/renderers/hyrax/renderers/rights_attribute_renderer.rb
hyrax-1.0.2 app/renderers/hyrax/renderers/rights_attribute_renderer.rb
hyrax-1.0.1 app/renderers/hyrax/renderers/rights_attribute_renderer.rb
hyrax-1.0.0.rc2 app/renderers/hyrax/renderers/rights_attribute_renderer.rb
hyrax-1.0.0.rc1 app/renderers/hyrax/renderers/rights_attribute_renderer.rb
test_hyrax-0.0.1.alpha app/renderers/hyrax/renderers/rights_attribute_renderer.rb