Sha256: 7f972250b2d3a45aa65dac348f73aece5ba29bae252358c2aa3b2f7a07f03e18

Contents?: true

Size: 587 Bytes

Versions: 5

Compression:

Stored size: 587 Bytes

Contents

module Spotlight::Resources
  module OpenGraph
    extend ActiveSupport::Concern
    include Spotlight::Resources::Web

    def opengraph
      @opengraph ||= begin
        page = Hash.new

        body.css('meta').select { |m| m.attribute('property') }.each do |m|
          page[m.attribute('property').to_s] = m.attribute('content').to_s
        end

        page
      end
    end

    def opengraph_properties
      Hash[opengraph.map do |k,v|
        ["#{k.parameterize("_")}_tesim", v]
      end]
    end

    def to_solr
      super.merge(opengraph_properties)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blacklight-spotlight-0.4.1 app/models/concerns/spotlight/resources/open_graph.rb
blacklight-spotlight-0.3.1 app/models/concerns/spotlight/resources/open_graph.rb
blacklight-spotlight-0.3.0 app/models/concerns/spotlight/resources/open_graph.rb
blacklight-spotlight-0.2.0 app/models/concerns/spotlight/resources/open_graph.rb
blacklight-spotlight-0.1.0 app/models/concerns/spotlight/resources/open_graph.rb