diff --git a/lib/onebox/engine/twitter_status_onebox.rb b/lib/onebox/engine/twitter_status_onebox.rb index a0f4cb316db..a9731845d60 100644 --- a/lib/onebox/engine/twitter_status_onebox.rb +++ b/lib/onebox/engine/twitter_status_onebox.rb @@ -23,7 +23,7 @@ module Onebox html.css('meta').each do |m| if m.attribute('property') && m.attribute('property').to_s.match(/^og:/i) m_content = m.attribute('content').to_s.strip - m_property = m.attribute('property').to_s.gsub('og:', '') + m_property = m.attribute('property').to_s.gsub('og:', '').gsub(':', '_') twitter_data[m_property.to_sym] = m_content end end @@ -100,7 +100,7 @@ module Onebox if twitter_api_credentials_present? access(:user, :profile_image_url_https).sub('normal', '400x400') elsif twitter_data[:image] - twitter_data[:image] + twitter_data[:image] unless twitter_data[:image_user_generated] end end diff --git a/spec/fixtures/onebox/twitterstatus_featured_image.response b/spec/fixtures/onebox/twitterstatus_featured_image.response new file mode 100644 index 00000000000..0f865fe6287 --- /dev/null +++ b/spec/fixtures/onebox/twitterstatus_featured_image.response @@ -0,0 +1,4149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Jeff Atwood on Twitter: "My first text message from my child! A moment that shall live on in infamy!… " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Skip to content + + + + + + + + + + +
+
+ + + +
+
+
+ + +
    +
  • + + + Home + Home + Home, current page. + +
  • +
  • + + + + Moments + Moments + Moments, current page. + +
  • +
+
+
+
+ + + + + + + + +
+
+
+
+
+
+
+

Saved searches

+
    + +
  • + Remove + +
  • +
+
+ +
    + +
  • + +
  • +
+
    + +
  • + + +
    + + In this conversation +
    + + + Verified accountProtected Tweets @ + + +
    +
  • +
  • +
+ +
    + +
  • +
+ +
+
+ Suggested users +
+
    + +
  • + + + + + + + Verified accountProtected Tweets @ + + +
  • +
  • +
+ +
    + +
  • + + + + + + + Verified accountProtected Tweets @ + + +
  • +
  • +
+
+ +
+
    +
  • + +
  • +
+
+
+
+ +
+
+ + +
    +
  • + + Language: English + +
    +
    + + +
    +
      +
    • Bahasa Indonesia
    • +
    • Bahasa Melayu
    • +
    • Català
    • +
    • Čeština
    • +
    • Dansk
    • +
    • Deutsch
    • +
    • English UK
    • +
    • Español
    • +
    • Filipino
    • +
    • Français
    • +
    • Hrvatski
    • +
    • Italiano
    • +
    • Magyar
    • +
    • Nederlands
    • +
    • Norsk
    • +
    • Polski
    • +
    • Português
    • +
    • Română
    • +
    • Slovenčina
    • +
    • Suomi
    • +
    • Svenska
    • +
    • Tiếng Việt
    • +
    • Türkçe
    • +
    • Ελληνικά
    • +
    • Български език
    • +
    • Русский
    • +
    • Српски
    • +
    • Українська мова
    • +
    • עִבְרִית
    • +
    • العربية
    • +
    • فارسی
    • +
    • मराठी
    • +
    • हिन्दी
    • +
    • বাংলা
    • +
    • ગુજરાતી
    • +
    • தமிழ்
    • +
    • ಕನ್ನಡ
    • +
    • ภาษาไทย
    • +
    • 한국어
    • +
    • 日本語
    • +
    • 简体中文
    • +
    • 繁體中文
    • +
    +
    +
    +
    + + +
    +
    +
  • +
+ +
    +
  • + + Have an account? Log in + +
    +
    +
    +
    Have an account?
    +
    +
    + +
    + +
    + + +
    + +
    + + · + Forgot password? +
    + + + + + + + + + + +
    +
    +
    +
    New to Twitter?
    + Sign up + +
    +
    +
    +
  • +
+
+ +
+
+
+
+ + +
+
+ + + + codinghorror's profile + +
+
+
+ +
+
+ +
+ +
+ +
+
+ + Jeff Atwood + +
+ +
+ + +
+
+ +
+ + +
+ +
+
+
+
+
+ + Jeff Atwood + +
+
+
+ + Jeff Atwood
Verified account +
+
+ + @codinghorror + +
+
+
+ +
+
+ +
+
+ + +
+
+
+
+
+ +
+
+ + +
+
+

Tweets

+
+ + +
+
+
+
+
+
+
+

+ Jeff AtwoodVerified account +

+ +

+ + @codinghorror + +

+ + + +

Indoor enthusiast. Co-founder of http://stackoverflow.com  and http://discourse.org . Let’s be kind to each other. Disclaimer: I have no idea what I'm talking about.

+ +
+ + + Bay Area, CA + + +
+ +
+ + + blog.codinghorror.com + + + +
+ + +
+ + Joined April 2007 +
+ +
+ + + +
+ + +
+ + + + + + + +
+ +
+
+
+
+
+
+
+
+

Tweets

+
+ + + + + + + + + + + +
+
+
+
+
+
+ +
+ + + + + +
+
+
+
    +
  • © 2021 Twitter
  • +
  • About
  • +
  • Help Center
  • +
  • Terms
  • +
  • Privacy policy
  • +
  • Cookies
  • +
  • Ads info
  • +
+
+
+ +
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + +
+
+
+
+
+
+ + + Dismiss + +
+
+
+ + + + +
+
+ +
+
+
+ + +
+
+ + + + Previous + + + +
+
+ + + + Next + + + +
+
+
+
+ + +
+ +
+ + +
+
+
+ + + +
+

Go to a person's profile

+
+ +
+
+
+ + + + +
+
+
+
+
+
+
+

Saved searches

+
    + +
  • + Remove + +
  • +
+
+ +
    + +
  • + +
  • +
+
    + +
  • + + +
    + + In this conversation +
    + + + Verified accountProtected Tweets @ + + +
    +
  • +
  • +
+ +
    + +
  • +
+ +
+
+ Suggested users +
+
    + +
  • + + + + + + + Verified accountProtected Tweets @ + + +
  • +
  • +
+ +
    + +
  • + + + + + + + Verified accountProtected Tweets @ + + +
  • +
  • +
+
+ +
+
    +
  • + +
  • +
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ + +
+

Promote this Tweet

+
+
+
+
+ +
+
+
+
+
+
+ + +
+
+
+ + + +
+

Block

+
+ +
+
+
+ +
+ +
+ + +
+
+
+
+ + + + + + +
+
+
+ + +
+
    +
  • +

    Tweet with a location

    +

    + You can add location information to your Tweets, such as your city or precise location, from the web and via third-party applications. You always have the option to delete your Tweet location history. + Learn more +

    +
    + + +
    +
  • +
+
+ +
+ +
+
+
+ + +
+
+
+ + +
+
+
    +
    +
    + +
    + + + +
    +
    +
    + + +
    +

    Your lists

    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    + + +
    +

    Create a new list

    +
    +
    +
    +
    + + +
    +
    + +
    + + + Under 100 characters, optional +
    +
    + +
    + Privacy +
    + + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    +
    + + + +
    +

    +
    + +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    + + +
    +

    Copy link to Tweet

    +
    +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + +
    +

    Embed this Tweet

    +

    Embed this Video

    +
    +
    +
    +

    Add this Tweet to your website by copying the code below. Learn more

    +

    Add this video to your website by copying the code below. Learn more

    +
    + +
    +
    +
    +

    Hmm, there was a problem reaching the server.

    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +

    By embedding Twitter content in your website or app, you are agreeing to the Twitter Developer Agreement and Developer Policy.

    +

    Preview

    +
    +
    +
    + +
    +
    +
    +
    + + +
    +
    +
    + + +
    +

    Why you're seeing this ad

    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + + +
    +
    +
    + + +
    +

    Log in to Twitter

    +
    +
    +
    + +
    +
    +
    +
    + +
    + +
    + + +
    + +
    + + · + Forgot password? +
    + + + + + + + + + + +
    +
    +
    +
    + Don't have an account? Sign up » +
    +
    +
    +
    + +
    +
    +
    + + +
    +

    Sign up for Twitter

    +
    +
    +
    + +
    +

    Not on Twitter? Sign up, tune into the things you care about, and get updates as they happen.

    +
    +
    + Sign up +
    +
    +
    +
    + Have an account? Log in » +
    +
    +
    +
    + +
    +
    +
    + + +
    +

    Two-way (sending and receiving) short codes:

    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    CountryCodeFor customers of
    United States40404(any)
    Canada21212(any)
    United Kingdom86444Vodafone, Orange, 3, O2
    Brazil40404Nextel, TIM
    Haiti40404Digicel, Voila
    Ireland51210Vodafone, O2
    India53000Bharti Airtel, Videocon, Reliance
    Indonesia89887AXIS, 3, Telkomsel, Indosat, XL Axiata
    Italy4880804Wind
    3424486444Vodafone
    + » See SMS short codes for other countries +
    +
    +
    +
    +
    + +
    +
    +
    + + +
    +

    Confirmation

    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    + + +
    +
    +
    + + +
    +

     

    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + + + +
    +
    + + +
    +
    +
    + + +
    +
    +
    +
    +
    +
    +
    + + +
    + + + + +
    +

    + + Welcome home! +

    +

    This timeline is where you’ll spend most of your time, getting instant updates about what matters to you.

    +
    + + + +
    +

    + + Tweets not working for you? +

    +

    + Hover over the profile pic and click the Following button to unfollow any account. +

    +
    + +
    + +

    + + Say a lot with a little +

    +

    + When you see a Tweet you love, tap the heart — it lets the person who wrote it know you shared the love. +

    +
    + +
    +

    + + Spread the word +

    +

    + The fastest way to share someone else’s Tweet with your followers is with a Retweet. Tap the icon to send it instantly. +

    +
    + +
    +

    + + Join the conversation +

    +

    + Add your thoughts about any Tweet with a Reply. Find a topic you’re passionate about, and jump right in. +

    +
    + + + +
    +

    + + Learn the latest +

    +

    + Get instant insight into what people are talking about now. +

    +
    + +
    +

    + + Get more of what you love +

    +

    + Follow more accounts to get instant updates about topics you care about. +

    +
    + +
    +

    + + Find what's happening +

    +

    + See the latest conversations about any topic instantly. +

    +
    + +
    +

    + + Never miss a Moment +

    +

    + Catch up instantly on the best stories happening as they unfold. +

    +
    +
    + +
    + + +
    +
    +
    +
    + + + + +
    +
    +
    +
    + + +
    +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
      + +
      +
    1. + + + +
      + +
      + + +
      + +
      + + + + + +
      + + + + Jeff Atwood‏Verified account @codinghorror + + + + Jun 27 + + +
      +
      + +
      +
      +
      +
      +
      +
        + +
      • + +
      • +
      • + +
      • +
      +
      + +
      + +
      + +
      + + + + + + + +
      +

      Anyone else doing cellular Apple Watches rather than full blown cell phones for their almost-teens? The more I research this the more I like it.

      +
      + + + + + + + + + + + + +
      + +
      + + + + + 24 replies + + + + + 5 retweets + + + + + 96 likes + + +
      + +
      +
      + +
      + +
      + +
      + + +
      + +
      + + + + + + +
      + +
      + + + + + + + + +
      + Show this thread +
      + + + + +
      + +
      + + + +
    2. +
      + + + + + + + + + + + + + + + + + + +
    +
      +
      +
      +
      +
      +
      +
      + + +
      + +
      + + + +
      +
      + + + + Jeff Atwood‏Verified account @codinghorror + + + + Jun 27 + + + + + +
      +
      + + + + + + + + + + +
      + +
      + +
      +
      + +
      +
      +
      +
      +
      +
        + +
      • + +
      • +
      • + +
      • +
      +
      + +
      + +
      + +
      + +
      + + + +
      +

      My first text message from my child! A moment that shall live on in infamy!pic.twitter.com/TQMRJsFwnO

      +
      + + + + + +
      +
      +
      +
      +
      + +
      + + +
      +
      +
      +
      + + + +
      +
      + + 8:20 PM - 27 Jun 2021 + + + +
      + + +
      +
      + +
        + +
      • + + + 90 Likes + +
      • + +
      • + + Blair "The Architect" + + + Ferdi (Ferdinand Fanötöna Zebua) + + + Greg Stoll 💉💉🎉 + + + Miles McNerney + + + Jon C + + + Javad:~$ + + + Philip is staying at home + + + Welcome to the NFT 📉 | BLM 🏳️‍🌈 + + + liagason + +
      • +
      + + +
      +
      + + + +
      + + + + +
      + + + + + 4 replies + + + + + 0 retweets + + + + + 90 likes + + +
      + +
      +
      + +
      + +
      + +
      + + +
      + +
      + + + + + + +
      + +
      + +
      + +
      +
      + +
      + + + +
      +
      +
      +
      +
      +
        + + + + + + + + + + + + +
      1. +
          +
        1. + + + +
          + +
          + + +
          + +
          + + + + + +
          + + + + Ferdi (Ferdinand Fanötöna Zebua)‏ @f_fz + + + + Jun 27 + + +
          +
          + +
          +
          +
          +
          +
          +
            + +
          • + +
          • +
          • + +
          • +
          +
          + +
          + +
          + +
          + + + + + +
          + Replying to @codinghorror + + + +
          + + + +
          +

          Mind-blown!

          +
          + + + + + + + + + + + + +
          + +
          + + + + + 0 replies + + + + + 0 retweets + + + + + 1 like + + +
          + +
          +
          + +
          + +
          + +
          + + +
          + +
          + + + + + + +
          + +
          + + + + + + + + + + + +
          + +
          + + + + +
          +
          +
          +
          +
          Thanks. Twitter will use this to make your timeline better. + Undo +
          +
          +
          +
          +
          + + Undo +
          +
          +
          +
          + +
        2. +
        +
      2. + + +
      3. +
          +
        1. + + + +
          + +
          + + +
          + +
          + + + + + +
          + + + + Chet Faliszek‏Verified account @chetfaliszek + + + + Jun 27 + + +
          +
          + +
          +
          +
          +
          +
          +
            + +
          • + +
          • +
          • + +
          • +
          +
          + +
          + +
          + +
          + + + + + +
          + Replying to @codinghorror + + + +
          + + + +
          +

          Make it their first NFT!

          +
          + + + + + + + + + + + + +
          + +
          + + + + + 0 replies + + + + + 0 retweets + + + + + 2 likes + + +
          + +
          +
          + +
          + +
          + +
          + + +
          + +
          + + + + + + +
          + +
          + + + + + + + + + + + +
          + +
          + + + + +
          +
          +
          +
          +
          Thanks. Twitter will use this to make your timeline better. + Undo +
          +
          +
          +
          +
          + + Undo +
          +
          +
          +
          + +
        2. +
        +
      4. + + +
      5. +
          +
        1. + + + +
          + +
          + + +
          + +
          + + + + + +
          + + + + Shawn Holmes‏ @Hanzo55 + + + + Jun 27 + + +
          +
          + +
          +
          +
          +
          +
          +
            + +
          • + +
          • +
          • + +
          • +
          +
          + +
          + +
          + +
          + + + + + +
          + Replying to @codinghorror + + + +
          + + + +
          +

          This will be the next milestonepic.twitter.com/ARtq5AkZqG

          +
          + + + + + +
          +
          +
          +
          +
          + +
          + + +
          +
          +
          +
          + + + + + + + + +
          + +
          + + + + + 0 replies + + + + + 0 retweets + + + + + 2 likes + + +
          + +
          +
          + +
          + +
          + +
          + + +
          + +
          + + + + + + +
          + +
          + + + + + + + + + + + +
          + +
          + + + + +
          +
          +
          +
          +
          Thanks. Twitter will use this to make your timeline better. + Undo +
          +
          +
          +
          +
          + + Undo +
          +
          +
          +
          + +
        2. +
        +
      6. + + +
      7. +
          +
        1. + + + +
          + +
          + + +
          + +
          + + + + + +
          + + + + Andrei Taranchenko‏ @andrenaleen + + + + Jun 27 + + +
          +
          + +
          +
          +
          +
          +
          +
            + +
          • + +
          • +
          • + +
          • +
          +
          + +
          + +
          + +
          + + + + + +
          + Replying to @codinghorror + + + +
          + + + +
          +

          I mean, a text from your kid is less dramatic than Pearl Harbor, but I don't have all the info.

          +
          + + + + + + + + + + + + +
          + +
          + + + + + 0 replies + + + + + 0 retweets + + + + + 1 like + + +
          + +
          +
          + +
          + +
          + +
          + + +
          + +
          + + + + + + +
          + +
          + + + + + + + + + + + +
          + +
          + + + + +
          +
          +
          +
          +
          Thanks. Twitter will use this to make your timeline better. + Undo +
          +
          +
          +
          +
          + + Undo +
          +
          +
          +
          + +
        2. +
        +
      8. + + + + + + + +
      +
      +
      +
      +
      + + +

      + + +

      + +

      +
      +
      + + +
      +
      + +
      +
      + +
      +
      +
      +
      +
      +

      Loading seems to be taking a while.

      +

      + Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information. +

      +
      +
      +
      + +
        +
        +
        +
        +
        +
        + + + +
        + + +
        +
        +

        Promoted Tweet

        +
          + +
        +
        +
        + +
        +
        +
        +
        + +

        false

        +
        +
        +
          +
        +
        +
        + +
        +
        + + +
        +
        +
        +
        +
          +
        • © 2021 Twitter
        • +
        • About
        • +
        • Help Center
        • +
        • Terms
        • +
        • Privacy policy
        • +
        • Cookies
        • +
        • Ads info
        • +
        +
        +
        + +
        + +
        +
        + + +
        +
        +
        +
        + +
        + + + +
        + + + + + + + + + + + + + + + diff --git a/spec/lib/onebox/engine/twitter_status_onebox_spec.rb b/spec/lib/onebox/engine/twitter_status_onebox_spec.rb index daa6f36cf9d..e74c6ee27fb 100644 --- a/spec/lib/onebox/engine/twitter_status_onebox_spec.rb +++ b/spec/lib/onebox/engine/twitter_status_onebox_spec.rb @@ -74,6 +74,23 @@ describe Onebox::Engine::TwitterStatusOnebox do let(:retweets_count) { "201" } end + shared_context "featured image info" do + before do + @link = "https://twitter.com/codinghorror/status/1409351083177046020" + @onebox_fixture = "twitterstatus_featured_image" + + stub_request(:get, @link.downcase).to_return(status: 200, body: onebox_response(@onebox_fixture)) + end + + let(:full_name) { "Jeff Atwood" } + let(:screen_name) { "codinghorror" } + let(:avatar) { "" } + let(:timestamp) { "3:02 PM - 27 Jun 2021" } + let(:link) { @link } + let(:favorite_count) { "90" } + let(:retweets_count) { "0" } + end + shared_examples "includes quoted tweet data" do it 'includes quoted tweet' do expect(html).to include("If you bought a ticket for tonight’s @Metallica show at Stade de France, you have helped") @@ -115,6 +132,18 @@ describe Onebox::Engine::TwitterStatusOnebox do it_behaves_like '#to_html' it_behaves_like "includes quoted tweet data" end + + context "with a featured image tweet" do + let(:tweet_content) do + "My first text message from my child! A moment that shall live on in infamy!" + end + + include_context "featured image info" + include_context "engines" + + it_behaves_like "an engine" + it_behaves_like '#to_html' + end end context "with twitter client" do