Sha256: 740dfcc79d558b98a4fc64c98c028e5f906124f54a9baede61d9ba73bd97f2ce

Contents?: true

Size: 869 Bytes

Versions: 3

Compression:

Stored size: 869 Bytes

Contents

module CurationConcerns
  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 Sufia gem's config/sufia.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">#{CurationConcerns::LicenseService.new.label(value)}</a>)
          end
        end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
curation_concerns-1.6.3 app/renderers/curation_concerns/renderers/rights_attribute_renderer.rb
curation_concerns-1.6.2 app/renderers/curation_concerns/renderers/rights_attribute_renderer.rb
curation_concerns-1.6.1 app/renderers/curation_concerns/renderers/rights_attribute_renderer.rb