Sha256: d174035f3e3529c3878153f60f5023a7c8da0743f7fc1d5538d4ab9e82ed0ae1
Contents?: true
Size: 838 Bytes
Versions: 41
Compression:
Stored size: 838 Bytes
Contents
module Onebox module Engine class ClassicGoogleMapsOnebox include Engine include LayoutSupport matches_regexp /^(https?:)?\/\/(maps\.google\.[\w.]{2,}|goo\.gl)\/maps?.+$/ def url @url = get_long_url if @url.include?("//goo.gl/maps/") @url end def to_html "<iframe src='#{url}&output=embed' width='690px' height='400px' frameborder='0' style='border:0'></iframe>" end private def data {link: url, title: url} end def get_long_url uri = URI(@url) http = Net::HTTP.start(uri.host, uri.port) http.open_timeout = timeout http.read_timeout = timeout response = http.head(uri.path) response["Location"] if response.code == "301" rescue @url end end end end
Version data entries
41 entries across 41 versions & 1 rubygems