Sha256: ed313867b259660253e10c8cd73fa608f56a548b2324e601bc2902d3ff48befd
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module Onebox module Engine class TypeformOnebox include Engine matches_regexp(/^https?:\/\/[a-z0-9]+\.typeform\.com\/to\/[a-zA-Z0-9]+/) always_https def to_html typeform_src = build_typeform_src <<~HTML <iframe src="#{typeform_src}" width="100%" height="600px" scrolling="no" frameborder="0"> </iframe> HTML end def placeholder_html "<div class='onebox-placeholder-container'><span class='placeholder-icon generic'></span></div>" end private def build_typeform_src escaped_src = ::Onebox::Helpers.normalize_url_for_output(@url) query_params = CGI::parse(URI::parse(escaped_src).query || '') return escaped_src if query_params.has_key?('typeform-embed') if query_params.empty? escaped_src += '?' unless escaped_src.end_with?('?') else escaped_src += '&' end escaped_src += 'typeform-embed=embed-widget' end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
onebox-1.9.1 | lib/onebox/engine/typeform_onebox.rb |
onebox-1.9.0 | lib/onebox/engine/typeform_onebox.rb |