A platform for community discussion. Free, open, simple.
FIX: Switch Reddit onebox from OG scraping to JSON API (#38035)
Rafael dos Santos Silvabab10337580a
diff --git a/app/assets/stylesheets/common/base/onebox.scss b/app/assets/stylesheets/common/base/onebox.scssindex 735a5377500..0bd69c6e579 100644--- a/app/assets/stylesheets/common/base/onebox.scss+++ b/app/assets/stylesheets/common/base/onebox.scss@@ -950,13 +950,48 @@ aside.onebox.xkcd .onebox-body img {}.onebox.reddit {- div.aspect-image-full-size {- position: relative;- }-div.description {color: var(--primary-med-or-secondary-med);}++ .onebox-body.reddit-preview-onebox {+ display: flex;+ gap: 0.75em;++ .reddit-preview-thumbnail {+ flex-shrink: 0;+ max-width: 150px;++ // neutralize the legacy float/absolute-position system+ .aspect-image {+ position: relative;+ width: auto;+ height: auto;+ max-width: 100%;+ max-height: none;+ float: none;+ margin: 0;+ }++ .aspect-image img,+ > img {+ position: static;+ width: auto;+ height: auto;+ max-width: 100%;+ max-height: 170px;+ float: none;+ }+ }++ .reddit-preview-details {+ flex: 1;+ min-width: 0;+ display: flex;+ flex-direction: column;+ justify-content: space-between;+ }+ }}.onebox.githubfolder {diff --git a/lib/onebox/engine/reddit_media_onebox.rb b/lib/onebox/engine/reddit_media_onebox.rbindex ffc51b6669f..81ab71317a2 100644--- a/lib/onebox/engine/reddit_media_onebox.rb+++ b/lib/onebox/engine/reddit_media_onebox.rb@@ -4,51 +4,137 @@ module Oneboxmodule Engineclass RedditMediaOneboxinclude Engine- include StandardEmbedalways_https- matches_domain("reddit.com", "www.reddit.com")+ matches_domain(+ "reddit.com",+ "www.reddit.com",+ "old.reddit.com",+ "np.reddit.com",+ "new.reddit.com",+ )++ def self.matches_path(path)+ path.match?(%r{^/r/[^/]+/comments/[^/]+})+ enddef to_html- if raw[:type] == "image"- <<-HTML+ post = reddit_post+ return nil unless post++ url = Onebox::Helpers.normalize_url_for_output("https://www.reddit.com#{post["permalink"]}")+ subreddit_url =+ Onebox::Helpers.normalize_url_for_output(+ "https://www.reddit.com/#{post["subreddit_name_prefixed"]}",+ )+ title = CGI.escapeHTML(Onebox::Helpers.truncate(post["title"].to_s, 80))+ subreddit = CGI.escapeHTML(post["subreddit_name_prefixed"].to_s)+ author = CGI.escapeHTML(post["author"].to_s)+ score = post["score"].to_i+ num_comments = post["num_comments"].to_i+ nsfw_label = post["over_18"] ? " <span class='nsfw'>NSFW</span>" : ""+ meta = "#{score} points | #{num_comments} comments — u/#{author}"++ if image_post?(post)+ image_url = extract_image_url(post)+ return nil unless image_url++ image_url = Onebox::Helpers.normalize_url_for_output(image_url)++ <<~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>+ <img src="https://www.reddit.com/favicon.ico" class="site-icon" width="16" height="16">+ <a href="#{subreddit_url}" target="_blank" rel="nofollow ugc noopener">#{subreddit}</a></header><article class="onebox-body">- <h3><a href="#{raw[:url]}" target="_blank" rel="nofollow ugc noopener">#{raw[:title]}</a></h3>+ <h3><a href="#{url}" target="_blank" rel="nofollow ugc noopener">#{title}#{nsfw_label}</a></h3><div class="scale-images">- <img src="#{raw[:image]}" class="scale-image"/>+ <img src="#{image_url}" class="scale-image"/></div>- <div class="description"><p>#{raw[:description]}</p></div>+ <div class="description"><p>#{meta}</p></div></article></aside>HTML- elsif raw[:type] =~ %r{^video[/\.]}- <<-HTML+ elsif video_post?(post)+ preview_url = extract_image_url(post)+ preview_html =+ if preview_url+ preview_url = Onebox::Helpers.normalize_url_for_output(preview_url)+ "<div class=\"reddit-preview-thumbnail\"><img src=\"#{preview_url}\" class=\"thumbnail\"/></div>"+ else+ ""+ end++ <<~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>+ <img src="https://www.reddit.com/favicon.ico" class="site-icon" width="16" height="16">+ <a href="#{subreddit_url}" target="_blank" rel="nofollow ugc noopener">#{subreddit}</a></header>- <article class="onebox-body">- <h3><a href="#{raw[:url]}" target="_blank" rel="nofollow ugc noopener">#{raw[:title]}</a></h3>- <div class="aspect-image-full-size">- <a href="#{raw[:url]}" target="_blank" rel="nofollow ugc noopener" class="image-wrapper">- <img src="#{raw[:image]}" class="scale-image"/>- <span class="video-icon"></span>- </a>+ <article class="onebox-body reddit-preview-onebox">+ #{preview_html}+ <div class="reddit-preview-details">+ <h3><a href="#{url}" target="_blank" rel="nofollow ugc noopener">#{title}#{nsfw_label}</a></h3>+ <div class="description"><p>#{meta}</p></div></div>- <div class="description"><p>#{raw[:description]}</p></div></article></aside>HTMLelse- html = Onebox::Engine::AllowlistedGenericOnebox.new(@url, @timeout).to_html- html.presence+ description_html =+ if post["is_self"] && post["selftext"].present?+ desc = CGI.escapeHTML(Onebox::Helpers.truncate(post["selftext"], 250))+ "<div class=\"description\"><p>#{desc}</p></div>"+ else+ ""+ end++ <<~HTML+ <aside class="onebox reddit">+ <header class="source">+ <img src="https://www.reddit.com/favicon.ico" class="site-icon" width="16" height="16">+ <a href="#{subreddit_url}" target="_blank" rel="nofollow ugc noopener">#{subreddit}</a>+ </header>+ <article class="onebox-body">+ <h3><a href="#{url}" target="_blank" rel="nofollow ugc noopener">#{title}#{nsfw_label}</a></h3>+ #{description_html}+ <div class="description"><p>#{meta}</p></div>+ </article>+ </aside>+ HTML+ end+ end++ private++ def reddit_post+ return @reddit_post if defined?(@reddit_post)++ json_url = @url.sub(%r{/?(\?.*)?$}, ".json")+ response = Onebox::Helpers.fetch_response(json_url)+ parsed = ::MultiJson.load(response)+ @reddit_post = parsed[0]["data"]["children"][0]["data"]+ rescue StandardError+ @reddit_post = nil+ end++ def image_post?(post)+ post["post_hint"] == "image" ||+ post["url"].to_s.match?(/\.(jpg|jpeg|png|gif|webp)(\?.*)?$/i)+ end++ def video_post?(post)+ post["is_video"] || post["post_hint"].to_s.include?("video")+ end++ def extract_image_url(post)+ if post["url"].to_s.match?(/\.(jpg|jpeg|png|gif|webp)(\?.*)?$/i)+ return CGI.unescapeHTML(post["url"])end++ preview_url = post.dig("preview", "images", 0, "source", "url")+ CGI.unescapeHTML(preview_url) if preview_urlendendenddiff --git a/spec/fixtures/onebox/reddit_image.response b/spec/fixtures/onebox/reddit_image.responseindex b8158ea4768..5b02b92235d 100644--- a/spec/fixtures/onebox/reddit_image.response+++ b/spec/fixtures/onebox/reddit_image.response@@ -1,416 +1,43 @@-<html lang="en" data-ember-extension="1">-<head>- <link href="//c.aaxads.com/aax.js?pub=AAX763KC6&hst=www.reddit.com&ver=1.2" rel="preload" as="script">- <link href="//c.amazon-adsystem.com/aax2/apstag.js" rel="preload" as="script">- <link href="//www.googletagservices.com/tag/js/gpt.js" rel="preload" as="script">- <title>Literally nothing black edition : colors</title>- <meta charset="utf8">- <meta name="viewport" content="width=device-width, initial-scale=1">- <meta name="description" content="r/colors: “Mere color, unspoiled by meaning, and unallied with definite form, can speak to the soul in a thousand different ways. ”-― Oscar Wilde">- <link rel="canonical" href="https://www.reddit.com/r/colors/comments/b4d5xm/literally_nothing_black_edition/">- <meta property="og:ttl" content="600">- <meta property="og:site_name" content="reddit">- <meta property="twitter:site" content="@reddit">- <meta property="twitter:card" content="summary">- <meta property="og:title" content="r/colors - Literally nothing black edition">- <meta property="twitter:title" content="r/colors - Literally nothing black edition">- <meta property="og:type" content="image">- <meta property="og:url" content="https://www.reddit.com/r/colors/comments/b4d5xm/literally_nothing_black_edition/">- <meta property="og:description" content="4 votes and 1 comment so far on Reddit">- <meta property="og:image" content="https://preview.redd.it/vsg59iw0srn21.jpg?auto=webp&s=e19452b85c0aa8e3563cb1006a36eb914abfdec7">- <meta property="og:image:width" content="3024">- <meta property="og:image:height" content="4032">- <meta property="twitter:image" content="https://preview.redd.it/vsg59iw0srn21.jpg?auto=webp&s=e19452b85c0aa8e3563cb1006a36eb914abfdec7">- <link rel="apple-touch-icon" sizes="57x57" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-57x57.png">- <link rel="apple-touch-icon" sizes="60x60" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-60x60.png">- <link rel="apple-touch-icon" sizes="72x72" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-72x72.png">- <link rel="apple-touch-icon" sizes="76x76" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-76x76.png">- <link rel="apple-touch-icon" sizes="114x114" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-114x114.png">- <link rel="apple-touch-icon" sizes="120x120" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-120x120.png">- <link rel="apple-touch-icon" sizes="144x144" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-144x144.png">- <link rel="apple-touch-icon" sizes="152x152" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-152x152.png">- <link rel="apple-touch-icon" sizes="180x180" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-180x180.png">- <link rel="icon" type="image/png" sizes="192x192" href="https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png">- <link rel="icon" type="image/png" sizes="32x32" href="https://www.redditstatic.com/desktop2x/img/favicon/favicon-32x32.png">- <link rel="icon" type="image/png" sizes="96x96" href="https://www.redditstatic.com/desktop2x/img/favicon/favicon-96x96.png">- <link rel="icon" type="image/png" sizes="16x16" href="https://www.redditstatic.com/desktop2x/img/favicon/favicon-16x16.png">- <link rel="manifest" href="https://www.redditstatic.com/desktop2x/img/favicon/manifest.json">- <meta name="msapplication-TileColor" content="#ffffff">- <meta name="msapplication-TileImage" content="https://www.redditstatic.com/desktop2x/img/favicon/ms-icon-144x144.png">- <meta name="theme-color" content="#ffffff">- <meta name="jsapi">-<body>- <iframe marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="0" width="0" id="aax_prefetch_frame" sandbox="allow-same-origin allow-forms allow-popups allow-scripts allow-pointer-lock allow-popups-to-escape-sandbox" src="https://redditad.com/display.html?&_otarOg=https%3A%2F%2Fwww.reddit.com&_cpub=AAX763KC6&_csvr=2019032812_578&_cgdpr=1&_cgdprconsent=0" name="{"fid":1,"type":"prefetch_frame"}" style="display: none !important;"></iframe>- <iframe marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="0" width="0" id="cok_aax" src="https://c.aaxads.com/aacxs.php?&yvVbqf=1&fv=1&ke=1&fy=37&qghf=1&flg=AAX763KC6&suylg=33%2C38%2C41%2C51%2C55%2C80%2C82%2C89%2C90%2C97%2C109%2C113%2C114%2C117%2C122%2C141%2C145%2C155%2C157%2C161%2C167%2C172%2C3004&uwlph=75&kwwsv=1&gdpr=1&gdprconsent=0" style="display: none !important;"></iframe>- <iframe marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="0" width="0" id="aax_if_detect" src="https://aaxdetect.com/detect.html?&pub=AAX763KC6&svr=2019032812_578&gdpr=1&gdprconsent=0&dn=https%3A%2F%2Fwww.reddit.com" style="display: none !important;"></iframe>- <script>- __perfMark('app_html_start');- </script>- <div id="2x-container">- <div class="xvmxia-0 PrKco">- <div tabindex="-1">- <div class="_1gsAk1ihQliBnDybgyjghy" id="SHORTCUT_FOCUSABLE_DIV" tabindex="-1">- <div class="SubredditVars-r-colors">- <header class="_2GyPfdsi-MbQFyHRECo9GO cx1ohrUAq6ARaXTX2u8YN s4rdgu3-0 eAICLF s1ipn2bl-0 dPRCBc" data-redditstyle="true">- <div class="_2vkeRJojnV7cb9pMlPHy7d">- <div class="_3dnbqz69WJTFCss8wl7Wlk"><span class="s1dqr9jy-0 imyGpC">Press J to jump to the feed. Press question mark to learn the rest of the keyboard shortcuts</span>- <a aria-label="Home" class="_30BbATRhFv3V83DHNDjJAO" href="/">- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" class="_1O4jTk-dZ-VIxsCuYB6OR8">- <g>- <circle fill="#FF4500" cx="10" cy="10" r="10"></circle>- <path fill="#FFF" d="M16.67,10A1.46,1.46,0,0,0,14.2,9a7.12,7.12,0,0,0-3.85-1.23L11,4.65,13.14,5.1a1,1,0,1,0,.13-0.61L10.82,4a0.31,0.31,0,0,0-.37.24L9.71,7.71a7.14,7.14,0,0,0-3.9,1.23A1.46,1.46,0,1,0,4.2,11.33a2.87,2.87,0,0,0,0,.44c0,2.24,2.61,4.06,5.83,4.06s5.83-1.82,5.83-4.06a2.87,2.87,0,0,0,0-.44A1.46,1.46,0,0,0,16.67,10Zm-10,1a1,1,0,1,1,1,1A1,1,0,0,1,6.67,11Zm5.81,2.75a3.84,3.84,0,0,1-2.47.77,3.84,3.84,0,0,1-2.47-.77,0.27,0.27,0,0,1,.38-0.38A3.27,3.27,0,0,0,10,14a3.28,3.28,0,0,0,2.09-.61A0.27,0.27,0,1,1,12.48,13.79Zm-0.18-1.71a1,1,0,1,1,1-1A1,1,0,0,1,12.29,12.08Z"></path>- </g>- </svg>- <svg class="_1bWuGs_1sq4Pqy099x_yy-" viewBox="0 0 55 17.44">- <g fill="#1c1c1c">- <circle fill="#FF4500" cx="45.77" cy="3.33" r="2.05"></circle>- <path fill="inherit" d="M16.73,12.05a1.44,1.44,0,0,0,1.54-1.48,4.91,4.91,0,0,0-.1-0.83,5.66,5.66,0,0,0-5.34-4.61c-3,0-5.51,2.76-5.51,6.15s2.47,6.15,5.51,6.15a5.47,5.47,0,0,0,4.26-1.78,1.19,1.19,0,0,0-.19-1.77,1.25,1.25,0,0,0-1.53.16,3.78,3.78,0,0,1-2.54,1.09,3.42,3.42,0,0,1-3.14-3.08h7ZM12.82,7.44a3.3,3.3,0,0,1,3,2.56h-6A3.3,3.3,0,0,1,12.82,7.44Z"></path>- <path fill="inherit" d="M7.44,6.32a1.15,1.15,0,0,0-1-1.14A4.46,4.46,0,0,0,2.31,6.69V6.54A1.15,1.15,0,1,0,0,6.54V16a1.18,1.18,0,0,0,1.08,1.2A1.15,1.15,0,0,0,2.31,16V11.15A3.51,3.51,0,0,1,6.15,7.47H6.38A1.15,1.15,0,0,0,7.44,6.32Z"></path>- <path fill="inherit" d="M46.92,7.56a1.15,1.15,0,0,0-2.31,0V16a1.15,1.15,0,1,0,2.31,0V7.56Z"></path>- <path fill="inherit" d="M29.87,1.15A1.15,1.15,0,0,0,28.72,0h0a1.15,1.15,0,0,0-1.15,1.15V6.31a4,4,0,0,0-2.95-1.18c-3,0-5.51,2.76-5.51,6.15s2.47,6.15,5.51,6.15a4.08,4.08,0,0,0,3-1.19A1.15,1.15,0,0,0,29.87,16V1.15Zm-5.26,14c-1.77,0-3.21-1.72-3.21-3.85s1.43-3.85,3.21-3.85,3.21,1.72,3.21,3.85S26.39,15.13,24.62,15.13Z"></path>- <path fill="inherit" d="M41.92,1.15A1.15,1.15,0,0,0,40.77,0h0a1.15,1.15,0,0,0-1.15,1.15V6.31a4,4,0,0,0-2.95-1.18c-3,0-5.51,2.76-5.51,6.15s2.47,6.15,5.51,6.15a4.08,4.08,0,0,0,3-1.19A1.15,1.15,0,0,0,41.92,16V1.15Zm-5.26,14c-1.77,0-3.21-1.72-3.21-3.85s1.43-3.85,3.21-3.85,3.21,1.72,3.21,3.85S38.44,15.13,36.67,15.13Z"></path>- <path fill="inherit" d="M52.91,16V7.44h1a1,1,0,0,0,1.06-1,1,1,0,0,0-1-1.09H52.91V3.76a1.18,1.18,0,0,0-1.08-1.19,1.15,1.15,0,0,0-1.23,1.15V5.38h-1a1,1,0,0,0-1.06,1,1,1,0,0,0,1,1.09h1V16a1.15,1.15,0,0,0,1.15,1.15h0A1.15,1.15,0,0,0,52.91,16Z"></path>- </g>- </svg>- </a>- <div class="_3jiriKeNer8y0-1r6oWIFM m-not-pinned">- <button aria-label="Start typing to filter your subscriptions or use up and down to select." class="h-jI8r2f9ozTNqu_2TBeY" role="navigation"><span class="_1GieMuLljOrqnVpRAwz7VP">r/colors</span>- <svg class="_3fvJBCH6c6P0NvMwoqK9MJ s1745pas-1 NuwdV" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" role="presentation">- <path d="M15.8286,15.8998 C15.3466,16.3788 12.6326,15.5598 8.5516,11.4798 C4.4706,7.3968 3.6486,4.6858 4.1316,4.2038 C4.3566,3.9788 4.9286,3.9208 5.9126,4.3518 C5.6166,4.5678 5.3306,4.8008 5.0666,5.0658 C5.0536,5.0798 5.0416,5.0948 5.0266,5.1098 C5.5756,6.4268 6.8946,8.4088 9.2596,10.7728 C11.6206,13.1338 13.6046,14.4538 14.9246,15.0028 C14.9376,14.9898 14.9526,14.9778 14.9666,14.9638 C15.2316,14.6988 15.4646,14.4128 15.6786,14.1178 C16.1096,15.1028 16.0526,15.6748 15.8286,15.8998 M16.7526,11.8998 C17.4066,9.5458 16.8136,6.9138 14.9666,5.0658 C13.6436,3.7438 11.8866,3.0148 10.0166,3.0148 C9.3686,3.0148 8.7356,3.1078 8.1286,3.2768 C5.7306,1.7598 3.9176,1.5898 2.7176,2.7898 C1.4036,4.1028 2.0736,6.1918 3.2866,8.1688 C2.6446,10.5128 3.2276,13.1258 5.0666,14.9638 C6.3886,16.2868 8.1456,17.0148 10.0166,17.0148 C10.6536,17.0148 11.2746,16.9178 11.8736,16.7518 C13.0856,17.4938 14.3406,18.0318 15.4316,18.0318 C16.1156,18.0318 16.7366,17.8198 17.2426,17.3138 C18.4416,16.1138 18.2706,14.2988 16.7526,11.8998"></path>- </svg>- <svg class="_3CG2U_hX3HI-ibl5v2RCq1 r2jmej-0 gEeUEF" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">- <g>- <path fill="inherit" d="M14.1711599,9.3535 L9.99925636,13.529 L5.82735283,9.3535 C5.51262415,9.0385 5.73543207,8.5 6.18054835,8.5 L13.8179644,8.5 C14.2630807,8.5 14.4858886,9.0385 14.1711599,9.3535"></path>- </g>- </svg>- </button>- </div>- <div class="_3jiriKeNer8y0-1r6oWIFM _2dlTXDaX9JuL0bekTwhV18 s1vm61o8-3 lcwViv" id="SearchDropdown">- <label class="s1vm61o8-1 hLCjnv" for="header-search-bar">- <svg class="s1vm61o8-2 clhxOb" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg">- <g>- <path d="M12.4743167,11.1299698 L14.6957506,13.2817166 C15.0924476,13.665969 15.1025359,14.2990536 14.7182834,14.6957506 C14.334031,15.0924476 13.7009464,15.1025359 13.3042494,14.7182834 L11.0486163,12.5334103 C10.0079655,13.2768564 8.73367013,13.7142857 7.35714286,13.7142857 C3.84600096,13.7142857 1,10.8682847 1,7.35714286 C1,3.84600096 3.84600096,1 7.35714286,1 C10.8682847,1 13.7142857,3.84600096 13.7142857,7.35714286 C13.7142857,8.76975383 13.2536226,10.0747029 12.4743167,11.1299698 Z M11.7142857,7.35714286 C11.7142857,4.95057046 9.76371525,3 7.35714286,3 C4.95057046,3 3,4.95057046 3,7.35714286 C3,9.76371525 4.95057046,11.7142857 7.35714286,11.7142857 C9.76371525,11.7142857 11.7142857,9.76371525 11.7142857,7.35714286 Z"></path>- </g>- </svg>- </label>- <form action="/search" autocomplete="off" method="get">- <input type="search" class="s1vm61o8-0 iWGgAu" id="header-search-bar" name="q" placeholder="Search r/colors" role="search" value="">- </form>- </div>- </div>- <div class="_2u8LqkbMtzd0lpblMFbJq5">- <div class="x0hiXHicn7r3BG9m1FJH4 _23q1waDr4n_2fR5A7zcZzb">- <div class="_1vXXD2qKLnHetdKvisFzBD">- <a class="_3dZnYgFFpifT-M_Vs2FAq6" id="header-quicklinks-popular" href="/">- <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">- <g>- <polygon fill="none" points="0 20 20 20 20 0 0 0"></polygon>- <polygon fill="inherit" points="12.5 3.5 20 3.5 20 11 17.5 8.5 11.25 14.75 7.5 11 2.5 16 0 13.5 7.5 6 11.25 9.75 15 6"></polygon>- </g>- </svg>- </a>- <a class="_3dZnYgFFpifT-M_Vs2FAq6" id="header-quicklinks-all" href="/r/all">- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">- <g fill-rule="evenodd">- <polygon fill="none" points="0 20 20 20 20 .001 0 .001"></polygon>- <path fill="inherit" d="M1.25,17.5 L1.25,7.5 L6.25,7.5 L6.25,17.5 L1.25,17.5 Z M12.49995,17.5001 L7.49995,17.5001 L7.49995,5.0001 L4.99995,5.0001 L9.99995,0.0006 L14.99995,5.0001 L12.49995,5.0001 L12.49995,17.5001 Z M13.75,17.5 L13.75,12.5 L18.75,12.5 L18.75,17.5 L13.75,17.5 Z"></path>- </g>- </svg>- </a>- <a class="_3dZnYgFFpifT-M_Vs2FAq6" id="header-quicklinks-oc" href="/original">- <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">- <path fill="inherit" d="M16.9998,2.9995 C18.1028,2.9995 18.9998,3.8975 18.9998,4.9995 L18.9998,14.9995 C18.9998,16.1025 18.1028,16.9995 16.9998,16.9995 L2.9998,16.9995 C1.8978,16.9995 0.9998,16.1025 0.9998,14.9995 L0.9998,4.9995 C0.9998,3.8975 1.8978,2.9995 2.9998,2.9995 L16.9998,2.9995 Z M13.9648,13.3525 C15.2718,13.3525 16.3188,12.6745 16.8278,11.5665 L15.1818,10.9775 C14.9318,11.4765 14.4528,11.8165 13.8338,11.8165 C13.0158,11.8165 12.3478,11.0575 12.3478,9.9995 C12.3478,8.9525 13.0058,8.1735 13.8438,8.1735 C14.4528,8.1735 14.9218,8.5025 15.1308,8.9615 L16.6968,8.2435 C16.1988,7.2755 15.2108,6.6365 13.9648,6.6365 C12.0588,6.6365 10.5118,8.1335 10.5118,9.9995 C10.5118,11.8755 12.0588,13.3525 13.9648,13.3525 Z M6.6248,13.3635 C8.5408,13.3635 10.0878,11.8755 10.0878,9.9995 C10.0878,8.1335 8.5408,6.6365 6.6248,6.6365 C4.7188,6.6365 3.1718,8.1335 3.1718,9.9995 C3.1718,11.8755 4.7188,13.3635 6.6248,13.3635 Z M6.625,8.1641 C7.562,8.1641 8.262,8.9421 8.262,10.0001 C8.262,11.0481 7.562,11.8361 6.625,11.8361 C5.697,11.8361 4.998,11.0481 4.998,10.0001 C4.998,8.9421 5.697,8.1641 6.625,8.1641 Z"></path>- </svg>- </a>- </div>- </div>- <div class="_19oWd7e3z7-ztUGzdIoCR7">- <div class="_1JBkpB_FOZMZ7IPr3FyNfH"><a class="_3Wg53T10KuuPmyWOMWsY2F s1di1u0z-5 eiJrJP" href="https://www.reddit.com/login?dest=https%3A%2F%2Fwww.reddit.com%2Fr%2Fcolors%2Fcomments%2Fb4d5xm%2Fliterally_nothing_black_edition%2F">log in</a><a class="Z_HUY3BUsGOBOtdmH94ZS _3Wg53T10KuuPmyWOMWsY2F s1di1u0z-1 iynWOK" href="https://www.reddit.com/register?dest=https%3A%2F%2Fwww.reddit.com%2Fr%2Fcolors%2Fcomments%2Fb4d5xm%2Fliterally_nothing_black_edition%2F">sign up</a></div>- <div class="U3FRqDA_Qhr4icbaNXSuf s1cu8rnh-0 kCxZdn" id="email-verification-tooltip-id">- <div class="s1dxm5k4-5 exNEfa"></div>- <div class="header-user-dropdown">- <button class="s1dxm5k4-6 cXRnFU o914k-12 hEWURs" aria-expanded="false" aria-haspopup="true" id="USER_DROPDOWN_ID">- <div class="o914k-1 hcePqI">- <div class="o914k-5 fHiJFY">- <svg class="o914k-13 cuvTDF" viewBox="0 0 250 250" xmlns="http://www.w3.org/2000/svg">- <g fill="inherit">- <path d="M146.8 142.6h-37.6c-31.1 0-56.5 25.3-56.5 56.5 0 5.2 4.2 9.4 9.4 9.4h131.8c5.2 0 9.4-4.2 9.4-9.4 0-31.2-25.3-56.5-56.5-56.5zM128 130.7c20.1 0 36.4-16.3 36.4-36.4v-9.4c0-20.1-16.3-36.4-36.4-36.4S91.6 64.8 91.6 84.9v9.4c0 20.1 16.3 36.4 36.4 36.4z"></path>- </g>- </svg>- </div>- <svg class="o914k-10 dPjfRs" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">- <g>- <path fill="inherit" d="M14.1711599,9.3535 L9.99925636,13.529 L5.82735283,9.3535 C5.51262415,9.0385 5.73543207,8.5 6.18054835,8.5 L13.8179644,8.5 C14.2630807,8.5 14.4858886,9.0385 14.1711599,9.3535"></path>- </g>- </svg>- </div><span class="s1dqr9jy-0 imyGpC">User account menu</span></button>- </div>- </div>- </div>- </div>- </div>- </header>- </div>- <div class="SubredditVars-r-colors">- <div class="_1nxEQl5D2Bx2jxDILRHemb s4rdgu3-1 lbeKQg" aria-hidden="false">- <div>- <div class="th5f56-0 dHUYIZ">- <div class="th5f56-4 YygLa th5f56-3 jFtZBV"></div>- <div class="th5f56-1 fJQRaL">- <div class="th5f56-2 bGwsrC">- <a class="ssdjlj-8 clTCiy ssdjlj-7 jDJmGa" href="/r/colors/">- <div class="ssdjlj-4 elhfNK" style="max-width:1600px">- <div class="ssdjlj-3 hLkSVI">- <svg class="ssdjlj-0 zSeAY" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">- <path d="M15.8286,15.8998 C15.3466,16.3788 12.6326,15.5598 8.5516,11.4798 C4.4706,7.3968 3.6486,4.6858 4.1316,4.2038 C4.3566,3.9788 4.9286,3.9208 5.9126,4.3518 C5.6166,4.5678 5.3306,4.8008 5.0666,5.0658 C5.0536,5.0798 5.0416,5.0948 5.0266,5.1098 C5.5756,6.4268 6.8946,8.4088 9.2596,10.7728 C11.6206,13.1338 13.6046,14.4538 14.9246,15.0028 C14.9376,14.9898 14.9526,14.9778 14.9666,14.9638 C15.2316,14.6988 15.4646,14.4128 15.6786,14.1178 C16.1096,15.1028 16.0526,15.6748 15.8286,15.8998 M16.7526,11.8998 C17.4066,9.5458 16.8136,6.9138 14.9666,5.0658 C13.6436,3.7438 11.8866,3.0148 10.0166,3.0148 C9.3686,3.0148 8.7356,3.1078 8.1286,3.2768 C5.7306,1.7598 3.9176,1.5898 2.7176,2.7898 C1.4036,4.1028 2.0736,6.1918 3.2866,8.1688 C2.6446,10.5128 3.2276,13.1258 5.0666,14.9638 C6.3886,16.2868 8.1456,17.0148 10.0166,17.0148 C10.6536,17.0148 11.2746,16.9178 11.8736,16.7518 C13.0856,17.4938 14.3406,18.0318 15.4316,18.0318 C16.1156,18.0318 16.7366,17.8198 17.2426,17.3138 C18.4416,16.1138 18.2706,14.2988 16.7526,11.8998"></path>- </svg><span class="ssdjlj-6 lbhgpA">r/<h1 class="ssdjlj-5 evVwId">colors</h1></span></div>- <div class="ssdjlj-2 haiyiH"></div>- </div>- </a>- <div class="s1s4hmd1-0 enEuTf">- <div class="s1s4hmd1-1 ixOlPy" style="max-width:1600px">- <div><a class="s8ofjbx-2 ekBJsF" href="/r/colors/">Posts</a></div>- </div>- </div>- </div>- <div style="max-width:1600px"></div>- <div class="th5f56-5 ftjuQd" style="max-width:1600px">- <div class="sdccme-0 kIpPAE">- <div class="uI_hDmU5GSiudtABRz_37 ugs5wq-3 inaZFZ">- <div class="ct93lh-9 gdWvqQ _2rszc84L136gWQrkwH6IaM Post t3_b4d5xm s1ukwo15-0 RqhAo" id="t3_b4d5xm" tabindex="-1">- <div data-test-id="post-content">- <div class="_23h0-EcaBUorIHC-JZyh6J" style="width:40px;border-left:4px solid transparent">- <div class="s1b4xnj8-0 dNbgrk">- <button class="cYUyoUM3wmgRXEHv1LlZv " aria-label="upvote" aria-pressed="false" data-click-id="upvote" id="upvote-button-t3_b4d5xm">- <div class="_2q7IQ0BUOWeEZoeAxN555e dplx91-0 hmUUsU"><i class="icon icon-upvote _2Jxk822qXs4DaXwsN7yyHA"></i></div>- </button>- <div class="_1rZYMD_4xY3gRcSS3p8ODO" style="color:#1A1A1B">4</div>- <button class="cYUyoUM3wmgRXEHv1LlZv " aria-label="downvote" aria-pressed="false" data-click-id="downvote">- <div class="_1iKd82bq_nqObFvSH1iC_Q s1y8gf4b-0 keMdrU"><i class="icon icon-downvote ZyxIIl4FP5gHGrJDzNpUC"></i></div>- </button>- </div>- </div>- <div class="s8w20h0-0 zHadr">- <div class="cZPZhMe-UCZ8htPodMyJ5">- <div class="_3AStxql1mQsrZuUIFP9xSg nU4Je7n-eSXStTBAPMYt8"><span class="_2fCzxBE1dlMh4OFc7B3Dun">Posted by</span>- <div class="xvda30-0 camSYk"><a class="_2tbHP6ZydRpjI44J3syuqC k9omvt-1 eTLhLs" href="/user/thatrandomretard">u/thatrandomretard</a>- <div id="UserInfoTooltip--t3_b4d5xm"></div>- </div><a class="_3jOxDPIQ0KaOWpzvSQo-1s" data-click-id="timestamp" href="https://www.reddit.com/r/colors/comments/b4d5xm/literally_nothing_black_edition/" id="PostTopMeta--Created--false--t3_b4d5xm" target="_blank" rel="nofollow noopener">11 days ago</a></div>- <div class="_2wFk1qX4e1cxk8Pkw1rAHk"></div>- <div class="s1himhqu-0 mVLQc _2LeW9tc_6Fs1n7Ou8uD-70 "></div>- </div>- </div>- <div class="ct93lh-0 cjqnLg"><span class="y8HYJ-y_lTUHkQIc1mdCq"><h2 class="s1okktje-0 eYgaub" data-redditstyle="true">Literally nothing black edition</h2></span>- <div class="_1hLrLjnE1G_RBCNcN9MVQf">- <img src="https://www.redditstatic.com/desktop2x/img/renderTimingPixel.png" style="width: 1px; height: 1px;" onload="(__markFirstPostVisible || function(){})();">- </div>- </div>- <div class="_3Oa0THmZ3f5iZXAQ0hBJ0k " style="margin:0 auto">- <a href="https://i.redd.it/vsg59iw0srn21.jpg" target="_blank"><img class="_2_tDEnGMLxpM6uOa2kaDB3 media-element" style="background-color:#FFFFFF;max-height:700px;margin:0 auto" src="https://preview.redd.it/vsg59iw0srn21.jpg?width=640&crop=smart&auto=webp&s=20aac863eaf45bc3022e50942e979c4026410e49"></a>- </div>- <div class="_1hwEKkB_38tIoal6fcdrt9">- <div class="_3-miAEojrCvx_4FQ8x3P-s erkui2-3 jVMRBO">- <div class="_1UoeAeSRhOKSNdY_h3iS1O _3m17ICJgx45k_z-t82iVuO _2qww3J5KKzsD7e5DO0BvvU erkui2-0 jlzGbU"><i class="icon icon-comment _3ch9jJ0painNf41PmU4F9i _3DVrpDrMM9NLT6TlsTUMxC" role="presentation"></i><span class="FHCV02u6Cp2zYL0fhQPsO">1 comment</span></div>- <div class="erkui2-2 lcDJEC" id="t3_b4d5xm-share-menu">- <button class="erkui2-1 kjRcny" data-click-id="share"><i class="icon icon-share xwmljjCrovDE5C9MasZja _1GQDWqbF-wkYWbrpmOvjqJ"></i><span class="_6_44iTtZoeY6_XChKt5b0">share</span></button>- </div>- <button class="s1afabjy-1 hyEpNP b1zwxr-0 hxpTao" role="menuitem">- <div class="s1nordvo-0 iRFTnd"><i class="icon icon-save vlzsw3-2 IyvWL"></i></div><span class="s1nordvo-1 bVDUJS">save</span></button>- <button class="s1afabjy-1 kVpXsu b1zwxr-0 hxpTao" role="menuitem">- <div class="s1nordvo-0 iRFTnd"><i class="icon icon-hide vlzsw3-0 giMEpI"></i></div><span class="s1nordvo-1 bVDUJS">hide</span></button>- <button class="s1afabjy-1 kVpXsu b1zwxr-0 hxpTao" role="menuitem">- <div class="s1nordvo-0 iRFTnd"><i class="icon icon-report _1MDjRAzxk1RSTB12748O1v vlzsw3-1 junIdA"><span class="i729lw-0 ebGXPK"></span></i></div><span class="s1nordvo-1 bVDUJS">report</span></button>- <div class="s1o43ulv-1 fGjVuX"></div>- <div>- <button class="vlzsw3-17 cYeNXF s18u2fuq-1 gwVOpf" aria-expanded="false" aria-haspopup="true" aria-label="more options" id="t3_b4d5xm-overflow-menu"><i class="icon icon-menu s18u2fuq-2 demKfm"></i></button>- </div>- <div class="_21pmAV9gWG6F_UKVe7YIE0"></div>- </div>- <div class="t4Hq30BDzTeJ85vREX7_M"><span>84% Upvoted</span></div>- </div>- </div>- </div>- <div class="s6wlmco-0 jecSt"><span class="s6wlmco-1 fGrGUl">What are your thoughts? Log in or Sign up</span><a class="s6wlmco-3 bsaIpo" href="https://www.reddit.com/login?dest=https%3A%2F%2Fwww.reddit.com%2Fr%2Fcolors%2Fcomments%2Fb4d5xm%2Fliterally_nothing_black_edition%2F">log in</a><a class="s6wlmco-2 eykXoL" href="https://www.reddit.com/register?dest=https%3A%2F%2Fwww.reddit.com%2Fr%2Fcolors%2Fcomments%2Fb4d5xm%2Fliterally_nothing_black_edition%2F">sign up</a></div>- <div class="s121jps0-1 cyghBJ">- <div class="qcxaFzxDBtnkGs5hS18OZ">Sort by</div>- <button class="_9hEKbWSdCV7reKexfA9A9 s1nordvo-2 bhJqeZ b1zwxr-0 hxpTao" id="CommentSort--SortPicker" role="menuitem"><span class="s1nordvo-1 bVDUJS">best</span></button>- <svg class="_2SygZtDzf_C4qIcNZSp9Da r2jmej-0 gEeUEF" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">- <g>- <path fill="inherit" d="M14.1711599,9.3535 L9.99925636,13.529 L5.82735283,9.3535 C5.51262415,9.0385 5.73543207,8.5 6.18054835,8.5 L13.8179644,8.5 C14.2630807,8.5 14.4858886,9.0385 14.1711599,9.3535"></path>- </g>- </svg>- <div class="s1ksf9tn-0 hbcgEe">- <a tabindex="-1" href="/r/colors/comments/b4d5xm/literally_nothing_black_edition/?sort=confidence">- <button class="s1nordvo-2 jKLnd b1zwxr-0 hxpTao" role="menuitem"><span class="s1nordvo-1 bVDUJS">best</span></button>- </a>- <a tabindex="-1" href="/r/colors/comments/b4d5xm/literally_nothing_black_edition/?sort=top">- <button class="s1nordvo-2 dVvmOF b1zwxr-0 hxpTao" role="menuitem"><span class="s1nordvo-1 bVDUJS">top</span></button>- </a>- <a tabindex="-1" href="/r/colors/comments/b4d5xm/literally_nothing_black_edition/?sort=new">- <button class="s1nordvo-2 dVvmOF b1zwxr-0 hxpTao" role="menuitem"><span class="s1nordvo-1 bVDUJS">new</span></button>- </a>- <a tabindex="-1" href="/r/colors/comments/b4d5xm/literally_nothing_black_edition/?sort=controversial">- <button class="s1nordvo-2 dVvmOF b1zwxr-0 hxpTao" role="menuitem"><span class="s1nordvo-1 bVDUJS">controversial</span></button>- </a>- <a tabindex="-1" href="/r/colors/comments/b4d5xm/literally_nothing_black_edition/?sort=old">- <button class="s1nordvo-2 dVvmOF b1zwxr-0 hxpTao" role="menuitem"><span class="s1nordvo-1 bVDUJS">old</span></button>- </a>- <a tabindex="-1" href="/r/colors/comments/b4d5xm/literally_nothing_black_edition/?sort=qa">- <button class="s1nordvo-2 dVvmOF b1zwxr-0 hxpTao" role="menuitem"><span class="s1nordvo-1 bVDUJS">q&a</span></button>- </a>- </div>- </div>- <div class="p0SYO8TbZVqJIWEeFcNZx ugs5wq-2 iwyQYP">- <div class="_2tRg7ajbEnfStKCizLgiOL">- <div class="ugs5wq-1 iPeDWx">- <div class="s1s03i76-0 gZtOW">- <div>- <div>- <div class="s136il31-0 cMWqxb" id="t1_ej75j43" tabindex="-1">- <div class="fxv3b9-1 jDSCcP">- <div class="fxv3b9-2 czhQfm">- <div class="t1_ej75j43 fxv3b9-0 efNcNS"><i class="threadline"></i></div>- </div>- </div>- <div class="Comment t1_ej75j43 top-level s1m8d0lr-3 jzfRiQ">- <div class="s1m8d0lr-0 iJHidl">- <button class="cYUyoUM3wmgRXEHv1LlZv " aria-label="upvote" aria-pressed="false" data-click-id="upvote">- <div class="_3wVayy5JvIMI67DheMYra2 dplx91-0 hmUUsU"><i class="icon icon-upvote _2Jxk822qXs4DaXwsN7yyHA _39UOLMgvssWenwbRxz_iEn"></i></div>- </button>- <button class="cYUyoUM3wmgRXEHv1LlZv " aria-label="downvote" aria-pressed="false" data-click-id="downvote">- <div class="jR747Vd1NbfaLusf5bHre s1y8gf4b-0 keMdrU"><i class="icon icon-downvote ZyxIIl4FP5gHGrJDzNpUC _2GCoZTwJW7199HSwNZwlHk"></i></div>- </button>- </div>- <div class="s1m8d0lr-2 iDQVFl"><span class="s1dqr9jy-0 imyGpC">level 1</span>- <div class="s1m8d0lr-1 hTYgIw s1scqi3h-15 iFVGWf">- <div class="xvda30-0 camSYk"><a class="k9omvt-1 elIMnE" href="/user/MTF_BETA_4">MTF_BETA_4</a>- <div class="_16AAktgl_rVbXAeiWU9CQd" id="UserInfoTooltip--t1_ej75j43"></div>- </div><span class="h5svje-0 cFQOcm">2 points</span><span class="h5svje-0 cFQOcm"> · </span><a class="s1scqi3h-11 iCjbNx" href="/r/colors/comments/b4d5xm/literally_nothing_black_edition/ej75j43/" id="CommentTopMeta--Created--t1_ej75j43" rel="nofollow" target="_blank"><span>11 days ago</span></a>- <div class="s1himhqu-0 mVLQc _2LeW9tc_6Fs1n7Ou8uD-70 "></div>- </div>- <div data-test-id="comment" class="_3cjCphgls6DH-irkVaA0GM">- <div class="fo16tt-0 bJBAtI">- <p class="s14dydj4-10 kiAEUp">Hell yeah</p>- </div>- </div>- <div class="qpz9zt-7 bFqcHi">- <button class="qpz9zt-8 hNcpjb"><i class="icon icon-comment _3ch9jJ0painNf41PmU4F9i qpz9zt-0 dCntJB"></i>Reply</button>- <div id="t1_ej75j43-comment-share-menu">- <button class="qpz9zt-8 hNcpjb">share</button>- </div>- <button class="qpz9zt-8 hNcpjb">report</button>- <button class="qpz9zt-8 hNcpjb">Save</button>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- <div class="th5f56-6 iQdHyy" style="margin-left:24px">- <div class="RffBqG1xCvuy1r49wYhLr ex0irb-2 clOGyg">- <div class="s17ivpdx-0 bpjjeT" data-redditstyle="false">- <div class="_ZhON3a3vplThB8NFwuJn">- <div class="_2sggAEfRQLyoAl4J__5twU">Community Details</div>- </div>- <div class="TmgZY6tDcdErbE5d7E0HJ">- <div class="fa9nbo-1 dGiaKs">- <svg class="_2Vkdik1Q8k0lBEhhA_lRKE s1745pas-1 NuwdV" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" role="presentation">- <path d="M15.8286,15.8998 C15.3466,16.3788 12.6326,15.5598 8.5516,11.4798 C4.4706,7.3968 3.6486,4.6858 4.1316,4.2038 C4.3566,3.9788 4.9286,3.9208 5.9126,4.3518 C5.6166,4.5678 5.3306,4.8008 5.0666,5.0658 C5.0536,5.0798 5.0416,5.0948 5.0266,5.1098 C5.5756,6.4268 6.8946,8.4088 9.2596,10.7728 C11.6206,13.1338 13.6046,14.4538 14.9246,15.0028 C14.9376,14.9898 14.9526,14.9778 14.9666,14.9638 C15.2316,14.6988 15.4646,14.4128 15.6786,14.1178 C16.1096,15.1028 16.0526,15.6748 15.8286,15.8998 M16.7526,11.8998 C17.4066,9.5458 16.8136,6.9138 14.9666,5.0658 C13.6436,3.7438 11.8866,3.0148 10.0166,3.0148 C9.3686,3.0148 8.7356,3.1078 8.1286,3.2768 C5.7306,1.7598 3.9176,1.5898 2.7176,2.7898 C1.4036,4.1028 2.0736,6.1918 3.2866,8.1688 C2.6446,10.5128 3.2276,13.1258 5.0666,14.9638 C6.3886,16.2868 8.1456,17.0148 10.0166,17.0148 C10.6536,17.0148 11.2746,16.9178 11.8736,16.7518 C13.0856,17.4938 14.3406,18.0318 15.4316,18.0318 C16.1156,18.0318 16.7366,17.8198 17.2426,17.3138 C18.4416,16.1138 18.2706,14.2988 16.7526,11.8998"></path>- </svg><a class="fa9nbo-4 eDxOau" href="/r/colors/"><span class="fa9nbo-5 ljlNSY" title="r/colors">r/colors</span></a></div>- <div class="fa9nbo-8 bsqcZX">- <div>- <p class="fa9nbo-10 iHHoqD">485</p>- <p class="fa9nbo-11 kBVNef" id="IdCard--Subscribers--undefined--t5_2qlwz">Subscribers</p>- </div>- <div class="fa9nbo-9 filgwm">- <p class="fa9nbo-10 iHHoqD">0</p>- <p class="fa9nbo-11 kBVNef" id="IdCard--CurrentlyViewing--undefined--t5_2qlwz">Online</p>- </div>- </div>- <p class="fa9nbo-13 iYBMzr">“Mere color, unspoiled by meaning, and unallied with definite form, can speak to the soul in a thousand different ways. ” ― Oscar Wilde</p>- <div class="fa9nbo-14 iooGMG">- <button class="fa9nbo-16 gmOtef s2ckgxg-4 cSzoLk s1di1u0z-3 dOwrvp" id="subscribe-button-t5_2qlwz">Subscribe</button><a class="fa9nbo-18 RdprA s1di1u0z-2 boHcOD" href="/r/colors/submit">Create post</a></div>- </div>- </div>- <div class="ii4q9d-0 fePAzF">- <div class="s17ivpdx-0 bpjjeT" data-redditstyle="false">- <div class="_ZhON3a3vplThB8NFwuJn">- <div class="_2sggAEfRQLyoAl4J__5twU">Moderators</div><a class="s1mvqe4r-2 ykJHm" href="https://reddit.com/message/compose?to=/r/colors" target="_blank"><i class="icon icon-envelope i2kq3x-0 ideQEv"></i></a></div>- <div class="TmgZY6tDcdErbE5d7E0HJ">- <div class="s1mvqe4r-0 caXkXK">- <a href="/user/HattoriHanzo">- <div class="s1mvqe4r-1 selJt">u/HattoriHanzo</div>- </a>- </div>- <div class="s1mvqe4r-0 caXkXK">- <a href="/user/chromakode">- <div class="s1mvqe4r-1 selJt">u/chromakode</div>- </a>- </div>- <div class="s1mvqe4r-0 caXkXK">- <a href="/user/konayashi">- <div class="s1mvqe4r-1 selJt">u/konayashi</div>- </a>- </div>- <div class="s1mvqe4r-5 kSUcya"><a class="s1mvqe4r-4 fjkzOx" href="/r/colors/about/moderators/">View All Moderators</a></div>- </div>- </div>- </div>- <div class="nowfa1-0 eLfEZO">- <div class="nowfa1-5 WraxO">- <div class="s1168hkq-4 hjxxdC s17ivpdx-0 bpjjeT" data-redditstyle="false">- <div class="_3RPJ8hHnfFohktLZca18J6">- <div class="s1168hkq-0 jpZMnH">- <div class="s21l9wz-0 bmnsEB">- <div><a class="s1168hkq-1 hSAKYw" href="https://about.reddit.com">about</a><a class="s1168hkq-1 hSAKYw" href="https://about.reddit.com/careers/">careers</a><a class="s1168hkq-1 hSAKYw" href="https://about.reddit.com/press/">press</a></div>- </div>- <div class="s21l9wz-0 bmnsEB">- <div><a class="s1168hkq-1 hSAKYw" href="https://about.reddit.com/advertise/">advertise</a><a class="s1168hkq-1 hSAKYw" href="http://www.redditblog.com/">blog</a><a class="s1168hkq-1 hSAKYw" href="https://www.reddithelp.com">help</a></div>- </div>- <div class="s21l9wz-0 bmnsEB">- <div><a class="s1168hkq-1 hSAKYw" href="https://www.reddit.com/mobile/download">the reddit app</a><a class="s1168hkq-1 hSAKYw" href="https://www.reddit.com/coins">reddit coins</a><a class="s1168hkq-1 hSAKYw" href="https://www.reddit.com/premium">reddit premium</a><a class="s1168hkq-1 hSAKYw" href="http://redditgifts.com/">reddit gifts</a></div>- </div>- </div>- <div class="s1168hkq-2 kddyLv">- <div>- <a class="s1168hkq-3 dikVDQ" href="https://www.reddit.com/help/contentpolicy">- <!-- -->content policy</a><span>|</span>- <a class="s1168hkq-3 dikVDQ" href="https://www.reddit.com/help/privacypolicy">- <!-- -->privacy policy</a>- </div>- <div>- <a class="s1168hkq-3 dikVDQ" href="https://www.reddit.com/help/useragreement">- <!-- -->user agreement</a><span>|</span>- <a class="s1168hkq-3 dikVDQ" href="https://www.reddit.com/help/healthycommunities/">- <!-- -->mod policy</a>- </div>- <div>© 2019 Reddit, Inc. All rights reserved</div>- </div>- </div>- </div>- </div>- <div class="nowfa1-1 bcFbiE s1ayxy26-0 hYctxm">- <button class="s1ayxy26-1 cPZUMx">back to top</button>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>-</body>-</html>+[+ {+ "kind": "Listing",+ "data": {+ "children": [+ {+ "kind": "t3",+ "data": {+ "title": "Literally nothing black edition",+ "author": "colorlover99",+ "subreddit_name_prefixed": "r/colors",+ "score": 4,+ "num_comments": 1,+ "selftext": "",+ "is_self": false,+ "post_hint": "image",+ "is_video": false,+ "over_18": false,+ "url": "https://i.redd.it/vsg59iw0srn21.jpg",+ "permalink": "/r/colors/comments/b4d5xm/literally_nothing_black_edition/",+ "preview": {+ "images": [+ {+ "source": {+ "url": "https://preview.redd.it/vsg59iw0srn21.jpg?auto=webp&s=e19452b85c0aa8e3563cb1006a36eb914abfdec7",+ "width": 3024,+ "height": 4032+ }+ }+ ]+ }+ }+ }+ ]+ }+ },+ {+ "kind": "Listing",+ "data": {+ "children": []+ }+ }+]diff --git a/spec/fixtures/onebox/reddit_self_post.response b/spec/fixtures/onebox/reddit_self_post.responsenew file mode 100644index 00000000000..4f1ac12d878--- /dev/null+++ b/spec/fixtures/onebox/reddit_self_post.response@@ -0,0 +1,31 @@+[+ {+ "kind": "Listing",+ "data": {+ "children": [+ {+ "kind": "t3",+ "data": {+ "title": "What are some underrated local LLMs?",+ "author": "llm_enthusiast",+ "subreddit_name_prefixed": "r/LocalLLaMA",+ "score": 256,+ "num_comments": 89,+ "selftext": "I've been experimenting with various local models and wanted to hear what hidden gems people have found. Specifically looking for models under 13B parameters that punch above their weight.",+ "is_self": true,+ "is_video": false,+ "over_18": false,+ "url": "https://www.reddit.com/r/LocalLLaMA/comments/xyz789/what_are_some_underrated_local_llms/",+ "permalink": "/r/LocalLLaMA/comments/xyz789/what_are_some_underrated_local_llms/"+ }+ }+ ]+ }+ },+ {+ "kind": "Listing",+ "data": {+ "children": []+ }+ }+]diff --git a/spec/fixtures/onebox/reddit_video.response b/spec/fixtures/onebox/reddit_video.responsenew file mode 100644index 00000000000..873c69e4039--- /dev/null+++ b/spec/fixtures/onebox/reddit_video.response@@ -0,0 +1,43 @@+[+ {+ "kind": "Listing",+ "data": {+ "children": [+ {+ "kind": "t3",+ "data": {+ "title": "My cat doing a backflip",+ "author": "cat_person_42",+ "subreddit_name_prefixed": "r/cats",+ "score": 12500,+ "num_comments": 432,+ "selftext": "",+ "is_self": false,+ "post_hint": "hosted:video",+ "is_video": true,+ "over_18": false,+ "url": "https://v.redd.it/abc123def456",+ "permalink": "/r/cats/comments/abc123/my_cat_doing_a_backflip/",+ "preview": {+ "images": [+ {+ "source": {+ "url": "https://preview.redd.it/abc123def456.png?auto=webp&s=deadbeef",+ "width": 1920,+ "height": 1080+ }+ }+ ]+ }+ }+ }+ ]+ }+ },+ {+ "kind": "Listing",+ "data": {+ "children": []+ }+ }+]diff --git a/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb b/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rbindex 95bd5d039e7..bb9eedcee9e 100644--- a/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb+++ b/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb@@ -251,10 +251,11 @@ RSpec.describe Onebox::Engine::AllowlistedGenericOnebox docontext "when using basic meta description when necessary" dobefore do- stub_request(- :get,- "https://www.reddit.com/r/colors/comments/b4d5xm/literally_nothing_black_edition/",- ).to_return(status: 200, body: onebox_response("reddit_image"))+ stub_request(:get, "https://www.example.com/og-content").to_return(+ status: 200,+ body:+ '<html><head><meta property="og:title" content="OG Title"/><meta property="og:description" content="OG description for testing"/></head><body></body></html>',+ )stub_request(:get, "https://www.example.com/content").to_return(status: 200,body: onebox_response("basic_description"),@@ -262,11 +263,8 @@ RSpec.describe Onebox::Engine::AllowlistedGenericOnebox doendit "uses opengraph tags when present" do- onebox =- described_class.new(- "https://www.reddit.com/r/colors/comments/b4d5xm/literally_nothing_black_edition/",- )- expect(onebox.to_html).to include("4 votes and 1 comment so far on Reddit")+ onebox = described_class.new("https://www.example.com/og-content")+ expect(onebox.to_html).to include("OG description for testing")endit "fallback to basic meta description if other description tags are missing" dodiff --git a/spec/lib/onebox/engine/reddit_media_onebox_spec.rb b/spec/lib/onebox/engine/reddit_media_onebox_spec.rbindex c5d09bc46fc..970f3a1073d 100644--- a/spec/lib/onebox/engine/reddit_media_onebox_spec.rb+++ b/spec/lib/onebox/engine/reddit_media_onebox_spec.rb@@ -1,35 +1,116 @@# frozen_string_literal: trueRSpec.describe Onebox::Engine::RedditMediaOnebox do- let(:link) { "https://www.reddit.com/r/colors/comments/b4d5xm/literally_nothing_black_edition" }- let(:html) { described_class.new(link).to_html }-- before do- stub_request(:head, "#{link}/").to_return(status: 200)- stub_request(:get, link).to_return(status: 200, body: onebox_response("reddit_image"))- stub_request(:get, "#{link}/").to_return(status: 200, body: onebox_response("reddit_image"))+ let(:image_link) do+ "https://www.reddit.com/r/colors/comments/b4d5xm/literally_nothing_black_edition"+ end+ let(:self_post_link) do+ "https://www.reddit.com/r/LocalLLaMA/comments/xyz789/what_are_some_underrated_local_llms"end+ let(:video_link) { "https://www.reddit.com/r/cats/comments/abc123/my_cat_doing_a_backflip" }++ describe "image post" do+ let(:html) { described_class.new(image_link).to_html }++ before do+ stub_request(:get, "#{image_link}.json").to_return(+ status: 200,+ body: onebox_response("reddit_image"),+ )+ end++ it "includes image" do+ expect(html).to include("https://i.redd.it/vsg59iw0srn21.jpg")+ end++ it "includes title" do+ expect(html).to include("Literally nothing black edition")+ end- it "includes title" do- expect(html).to include(- '<a href="https://www.reddit.com/r/colors/comments/b4d5xm/literally_nothing_black_edition/" target="_blank" rel="nofollow ugc noopener">reddit</a>',- )+ it "includes subreddit" do+ expect(html).to include("r/colors")+ end++ it "includes score and comments" do+ expect(html).to include("4 points")+ expect(html).to include("1 comments")+ endend- it "includes image" do- expect(html).to include("https://preview.redd.it/vsg59iw0srn21.jpg")+ describe "self/text post" do+ let(:html) { described_class.new(self_post_link).to_html }++ before do+ stub_request(:get, "#{self_post_link}.json").to_return(+ status: 200,+ body: onebox_response("reddit_self_post"),+ )+ end++ it "includes title" do+ expect(html).to include("What are some underrated local LLMs?")+ end++ it "includes selftext" do+ expect(html).to include("experimenting with various local models")+ end++ it "includes author" do+ expect(html).to include("u/llm_enthusiast")+ end++ it "does not include image markup" do+ expect(html).not_to include("scale-image")+ endend- it "includes description" do- expect(html).to include("Literally nothing black edition")+ describe "video post" do+ let(:html) { described_class.new(video_link).to_html }++ before do+ stub_request(:get, "#{video_link}.json").to_return(+ status: 200,+ body: onebox_response("reddit_video"),+ )+ end++ it "includes title" do+ expect(html).to include("My cat doing a backflip")+ end++ it "includes preview thumbnail" do+ expect(html).to include("thumbnail")+ end++ it "includes preview image" do+ expect(html).to include("https://preview.redd.it/abc123def456.png")+ endenddescribe ".===" doit "matches valid Reddit URL" do- valid_url = URI(link)+ valid_url = URI(image_link)expect(described_class === valid_url).to eq(true)end+ it "matches old.reddit.com URL" do+ expect(described_class === URI("https://old.reddit.com/r/cats/comments/abc123/post/")).to eq(+ true,+ )+ end++ it "matches np.reddit.com URL" do+ expect(described_class === URI("https://np.reddit.com/r/cats/comments/abc123/post/")).to eq(+ true,+ )+ end++ it "matches new.reddit.com URL" do+ expect(described_class === URI("https://new.reddit.com/r/cats/comments/abc123/post/")).to eq(+ true,+ )+ end+it "does not match invalid Reddit URL" doinvalid_url = URI("https://www.reddit.com.somedomain.com/r/colors/comments/b4d5xm/")expect(described_class === invalid_url).to eq(false)