2 require "addressable/uri"
4 def opengraph_tags(title, properties)
6 "og:site_name" => t("layouts.project_name.title"),
7 "og:title" => properties["og:title"] || title || t("layouts.project_name.title"),
8 "og:type" => "website",
9 "og:url" => url_for(:only_path => false),
10 "og:description" => properties["og:description"] || t("layouts.intro_text")
12 opengraph_image_properties(properties)
14 properties.slice("article:published_time")
17 safe_join(tags.map do |property, content|
18 tag.meta(:property => property, :content => content)
24 def opengraph_image_properties(properties)
26 if properties["og:image"]
28 image_properties["og:image"] = Addressable::URI.join(root_url, properties["og:image"]).normalize
29 image_properties["og:image:alt"] = properties["og:image:alt"] if properties["og:image:alt"]
30 return image_properties
32 rescue Addressable::URI::InvalidURIError
33 # return default image
36 "og:image" => image_url("osm_logo_256.png"),
37 "og:image:alt" => t("layouts.logo.alt_text")