Skip to content

Commit

Permalink
Extract add_organisation_tags
Browse files Browse the repository at this point in the history
  • Loading branch information
tijmenb committed Apr 24, 2018
1 parent 97d9ab6 commit a614146
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lib/govuk_publishing_components/presenters/meta_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ def meta_tags
meta_tags["govuk:content-id"] = content_item[:content_id] if content_item[:content_id]
meta_tags["govuk:withdrawn"] = "withdrawn" if content_item[:withdrawn_notice].present?

organisations = []
organisations += links[:organisations] || []
organisations += links[:worldwide_organisations] || []
organisations_content = organisations.map { |link| "<#{link[:analytics_identifier]}>" }.uniq.join
meta_tags["govuk:analytics:organisations"] = organisations_content if organisations.any?

world_locations = links[:world_locations] || []
world_locations_content = world_locations.map { |link| "<#{link[:analytics_identifier]}>" }.join
meta_tags["govuk:analytics:world-locations"] = world_locations_content if world_locations.any?
meta_tags = add_organisation_tags(meta_tags)

if details.key?(:political) && details.key?(:government)
political_status = "non-political"
Expand Down Expand Up @@ -135,6 +127,20 @@ def add_document_type_tags(meta_tags)

meta_tags
end

def add_organisation_tags(meta_tags)
organisations = []
organisations += links[:organisations] || []
organisations += links[:worldwide_organisations] || []
organisations_content = organisations.map { |link| "<#{link[:analytics_identifier]}>" }.uniq.join
meta_tags["govuk:analytics:organisations"] = organisations_content if organisations.any?

world_locations = links[:world_locations] || []
world_locations_content = world_locations.map { |link| "<#{link[:analytics_identifier]}>" }.join
meta_tags["govuk:analytics:world-locations"] = world_locations_content if world_locations.any?

meta_tags
end
end
end
end

0 comments on commit a614146

Please sign in to comment.