Class: Slimmer::Processors::MetadataInserter

Inherits:
Object
  • Object
show all
Defined in:
lib/slimmer/processors/metadata_inserter.rb

Instance Method Summary collapse

Constructor Details

#initialize(response, app_name) ⇒ MetadataInserter

Returns a new instance of MetadataInserter.



3
4
5
6
# File 'lib/slimmer/processors/metadata_inserter.rb', line 3

def initialize(response, app_name)
  @headers = response.headers
  @app_name = app_name
end

Instance Method Details

#filter(_old_doc, new_doc) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/slimmer/processors/metadata_inserter.rb', line 8

def filter(_old_doc, new_doc)
  head = new_doc.at_css("head")

  # temporarily duplicate these tags with the old names to avoid deployment issues
  add_meta_tag("analytics:organisations", @headers[Slimmer::Headers::ORGANISATIONS_HEADER], head, new_doc)
  add_meta_tag("analytics:world-locations", @headers[Slimmer::Headers::WORLD_LOCATIONS_HEADER], head, new_doc)
  add_meta_tag("organisations", @headers[Slimmer::Headers::ORGANISATIONS_HEADER], head, new_doc)
  add_meta_tag("world-locations", @headers[Slimmer::Headers::WORLD_LOCATIONS_HEADER], head, new_doc)
  add_meta_tag("format", @headers[Slimmer::Headers::FORMAT_HEADER], head, new_doc)
  add_meta_tag("search-result-count", @headers[Slimmer::Headers::RESULT_COUNT_HEADER], head, new_doc)
  add_meta_tag("rendering-application", @app_name, head, new_doc)
end