Sha256: 933f3f5dffdca8adff0681cdd8a61e0ce7bcf3f39d17c1b96219a21f2cc9c0b7

Contents?: true

Size: 1.33 KB

Versions: 54

Compression:

Stored size: 1.33 KB

Contents

module Hyrax
  module Renderers
    module ConfiguredMicrodata
      def microdata?(field)
        return false unless Hyrax.config.display_microdata?
        translate_microdata(field: field, field_context: 'property', default: false)
      end

      def microdata_object?(field)
        return false unless Hyrax.config.display_microdata?
        translate_microdata(field: field, field_context: 'type', default: false)
      end

      def microdata_object_attributes(field)
        if microdata_object?(field)
          { itemprop: microdata_property(field), itemscope: '', itemtype: microdata_type(field) }
        else
          {}
        end
      end

      def microdata_property(field)
        translate_microdata(field: field, field_context: 'property')
      end

      def microdata_type(field)
        translate_microdata(field: field, field_context: 'type')
      end

      def microdata_value_attributes(field)
        if microdata?(field)
          field_context = microdata_object?(field) ? :value : :property
          { itemprop: translate_microdata(field: field, field_context: field_context) }
        else
          {}
        end
      end

      private

        def translate_microdata(field:, field_context:, default: true)
          Microdata.fetch("#{field}.#{field_context}", default: default)
        end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

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