Sha256: ee989dd776b605e1f7ff7512dccea258d78a0adb72e1a55d5c4e3b83493d9501

Contents?: true

Size: 1.16 KB

Versions: 8

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

module Onebox
  module Engine
    class RedditImageOnebox
      include Engine
      include StandardEmbed

      matches_regexp(/^https?:\/\/(www\.)?reddit\.com/)

      def to_html
        if raw[:type] == "image"
          <<-HTML
            <aside class="onebox reddit">
              <header class="source">
                <img src="#{raw[:favicon]}" class="site-icon" width="16" height="16">
                <a href="#{raw[:url]}" target="_blank" rel="nofollow ugc noopener">#{raw[:site_name]}</a>
              </header>
              <article class="onebox-body">
                <h3><a href="#{raw[:url]}" target="_blank" rel="nofollow ugc noopener">#{raw[:title]}</a></h3>
                <div class="scale-images">
                  <img src="#{raw[:image]}" class="scale-image"/>
                </div>
                <div class="description"><p>#{raw[:description]}</p></div>
              </article>
            </aside>
          HTML
        else
          html = Onebox::Engine::WhitelistedGenericOnebox.new(@url, @timeout).to_html
          return if Onebox::Helpers.blank?(html)
          html
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
onebox-1.9.27.2 lib/onebox/engine/reddit_image_onebox.rb
onebox-1.9.27.1 lib/onebox/engine/reddit_image_onebox.rb
onebox-1.9.26 lib/onebox/engine/reddit_image_onebox.rb
onebox-1.9.25 lib/onebox/engine/reddit_image_onebox.rb
onebox-1.9.24 lib/onebox/engine/reddit_image_onebox.rb
onebox-1.9.23 lib/onebox/engine/reddit_image_onebox.rb
onebox-1.9.22 lib/onebox/engine/reddit_image_onebox.rb
onebox-1.9.21 lib/onebox/engine/reddit_image_onebox.rb