# frozen_string_literal: true module Onebox module Engine class GooglePhotosOnebox include Engine include StandardEmbed matches_regexp(/^https?:\/\/(photos)\.(app\.goo\.gl|google\.com)/) always_https def to_html og = get_opengraph return video_html(og) if !og.video_secure_url.nil? return album_html(og) if !og.type.nil? && og.type == "google_photos:photo_album" return image_html(og) if !og.image.nil? nil end private def video_html(og) escaped_url = ::Onebox::Helpers.normalize_url_for_output(url) <<-HTML HTML end def album_html(og) escaped_url = ::Onebox::Helpers.normalize_url_for_output(url) album_title = og.description.nil? ? og.title : "[#{og.description}] #{og.title}" <<-HTML
#{Onebox::Helpers.truncate(album_title, 80)}
HTML end def image_html(og) escaped_url = ::Onebox::Helpers.normalize_url_for_output(url) <<-HTML Google Photos HTML end end end end