Bug 1285543 - Only use "og:title" or "twitter:title" if _getArticleTitle does not return a valid title, r=Gijs

pull/313/merge
Evan Tseng 8 years ago committed by Gijs
parent c2f7db51f5
commit e84c0c3f07

@ -1055,12 +1055,15 @@ Readability.prototype = {
metadata.excerpt = values["twitter:description"];
}
if ("og:title" in values) {
// Use facebook open graph title.
metadata.title = values["og:title"];
} else if ("twitter:title" in values) {
// Use twitter cards title.
metadata.title = values["twitter:title"];
metadata.title = this._getArticleTitle();
if (!metadata.title) {
if ("og:title" in values) {
// Use facebook open graph title.
metadata.title = values["og:title"];
} else if ("twitter:title" in values) {
// Use twitter cards title.
metadata.title = values["twitter:title"];
}
}
return metadata;
@ -1850,7 +1853,7 @@ Readability.prototype = {
this._prepDocument();
var metadata = this._getArticleMetadata();
var articleTitle = metadata.title || this._getArticleTitle();
var articleTitle = metadata.title;
var articleContent = this._grabArticle();
if (!articleContent)

@ -1,5 +1,5 @@
{
"title": "This API is so Fetching!",
"title": "This API is so Fetching! ✩ Mozilla Hacks the Web developer blog",
"byline": "Nikhil Marathe",
"excerpt": "For more than a decade the Web has used XMLHttpRequest (XHR) to achieve asynchronous requests in JavaScript. While very useful, XHR is not a very ...",
"readerable": true

@ -1,5 +1,5 @@
{
"title": "Obama admits US gun laws are his 'biggest frustration' - BBC News",
"title": "Obama admits US gun laws are his 'biggest frustration'",
"byline": null,
"excerpt": "President Barack Obama tells the BBC his failure to pass",
"readerable": true

@ -1,5 +1,5 @@
{
"title": "Seven secrets that hotel owners don't want you to know",
"title": "The seven secrets that hotel owners don't want you to know",
"byline": "Hazel Sheffield",
"excerpt": "Most people go to hotels for the pleasure of sleeping in a giant bed with clean white sheets and waking up to fresh towels in the morning. But those towels and sheets might not be as clean as they look, according to the hotel bosses that responded to an online thread about the things hotel owners dont want you to know.",
"readerable": true

@ -1,5 +1,5 @@
{
"title": "How to Build a Terrarium | eHow",
"title": "How to Build a Terrarium (with Pictures)",
"byline": "Lucy Akins",
"excerpt": "How to Build a Terrarium. Glass cloche terrariums are not only appealing to the eye, but they also preserve a bit of nature in your home and serve as a simple, yet beautiful, piece of art. Closed terrariums are easy to care for, as they retain much of their own moisture and provide a warm environment with a consistent level of humidity. You...",
"readerable": true

@ -1,5 +1,5 @@
{
"title": "Angry media wont buckle over new surveillance laws",
"title": "Angry media wont buckle over new surveillance laws\n\t\t\t\t\t\t| Herald Sun",
"byline": "JOE HILDEBRAND",
"excerpt": "A HIGH-powered federal government team has been doing the rounds of media organisations in the past few days in an attempt to allay concerns about the impact of new surveillance legislation on press freedom. It failed.",
"readerable": true

@ -1,5 +1,5 @@
{
"title": "Getting LEAN with Digital Ad UX | IAB",
"title": "Getting LEAN with Digital Ad UX",
"byline": "By\n\t\t\tScott Cunningham",
"excerpt": "We messed up. As technologists, tasked with delivering content and services to users, we lost track of the user experience. Twenty years ago we saw an explosion of websites, built by developers around the world, providing all forms of content. This was the beginning of an age of enlightenment, the intersection of content and technology. … Continued",
"readerable": true

@ -1,5 +1,5 @@
{
"title": "Inside the Deep Web Drug Lab",
"title": "Inside the Deep Web Drug Lab — Backchannel — Medium",
"byline": "Joseph Cox",
"excerpt": "Welcome to DoctorXs Barcelona lab, where the drugs you bought online are tested for safety and purity. No questions ask…",
"readerable": true

@ -1,5 +1,5 @@
{
"title": "The Open Journalism Project: Better Student Journalism",
"title": "Better Student Journalism — Medium",
"byline": "Pippin Lee",
"excerpt": "We pushed out the first version of the Open Journalism site in January. Heres what weve learned about student journali…",
"readerable": true

@ -1,5 +1,5 @@
{
"title": "On Behalf of “Literally”",
"title": "On Behalf of “Literally” — Medium",
"byline": "Courtney Kirchoff",
"excerpt": "In defense of the word “literally” and why you or someone you know should stop misusing the word, lest they drive us fig…",
"readerable": true

@ -1,5 +1,5 @@
{
"title": "Firefox — Customize and make it your own — The most flexible browser on the Web",
"title": "Firefox — Customize and make it your own — The most flexible browser on\n the Web — Mozilla",
"byline": null,
"dir": "ltr",
"excerpt": "Its easier than ever to personalize Firefox and make it work the way\n you do.\n No other browser gives you so much choice and flexibility.",

@ -1,5 +1,5 @@
{
"title": "The sharing economy is a lie: Uber, Ayn Rand and the truth about tech and libertarians",
"title": "The sharing economy is a lie: Uber, Ayn Rand and the truth about tech\n and libertarians",
"byline": "Joanna Rothkopf",
"excerpt": "Disruptive companies talk a good game about sharing. Uber's really just an under-regulated company making riches",
"readerable": true

@ -0,0 +1,6 @@
{
"title": "Russia: Space ship malfunctions, breaks up over Siberia",
"byline": "NATALIYA VASILYEVA",
"excerpt": "The latest news and headlines from Yahoo! News. Get breaking news stories and in-depth coverage with videos and photos.",
"readerable": true
}

@ -0,0 +1,31 @@
<div id="readability-page-1" class="page">
<div id="tgt1-Col1-2-ContentCanvas" class="content-canvas Bgc(#fff) Pos(r) P(20px)--sm Pt(17px)--sm">
<article data-uuid="8dd27580-6b4e-3cfb-a389-5b1ab90bd0eb" data-type="story">
<div class="canvas-atom Mb(24px) Mb(22px)--sm">
<div class="Bdbc(#e8e8e8) Bdbs(s) Bdbw(1px)">
<div class="Pos(r) Lh(1.4) Fz(13px) Pb(10px) Pt(6px)">
<p class="Fw(500) Fz(19px) Mb(8px)"><span>1 / 5</span></p>
<div class="Pos(r) Ovy(h)">
<div>
<p class="slideshow-description">In this photo dated Tuesday, Nov, 29, 2016 the Soyuz-FG rocket booster with the Progress MS-04 cargo ship is installed on a launch pad in Baikonur, Kazakhstan. The unmanned Russian cargo space ship Progress MS-04 broke up in the atmosphere over Siberia on Thursday Dec. 1, 2016, just minutes after the launch en route to the International Space Station due to an unspecified malfunction, the Russian space agency said.(Oleg Urusov/ Roscosmos Space Agency Press Service photo via AP)</p>
</div>
</div><button class="C(#157cfb) Cur(p) W(100%) Ta(start) Fz(13px) P(0) Bd(0) O(0) O(n):f"><span>More</span></button></div>
</div>
</div>
<div class="canvas-body C(#26282a) Wow(bw) Cl(start) Mb(20px) Fz(15px) Lh(1.6) Ff($ff-secondary)">
<p class="canvas-text Mb(1.0em) Mb(0)--sm Mt(0.8em)--sm canvas-atom" data-type="text">MOSCOW (AP) — An unmanned Russian cargo spaceship heading to the International Space Station broke up in the atmosphere over Siberia on Thursday due to an unspecified malfunction, the Russian space agency said.</p>
<p class="canvas-text Mb(1.0em) Mb(0)--sm Mt(0.8em)--sm canvas-atom" data-type="text">The Progress MS-04 cargo craft broke up at an altitude of 190 kilometers (118 miles) over the remote Russian Tuva region in Siberia that borders Mongolia, Roscosmos said in a statement. It said most of spaceship's debris burnt up as it entered the atmosphere but some fell to Earth over what it called an uninhabited area.</p>
<p class="canvas-text Mb(1.0em) Mb(0)--sm Mt(0.8em)--sm canvas-atom" data-type="text">Local people reported seeing a flash of light and hearing a loud thud west of the regional capital of Kyzyl, more than 3,600 kilometers (2,200 miles) east of Moscow, the Tuva government was quoted as saying late Thursday by the Interfax news agency.</p>
<p class="canvas-text Mb(1.0em) Mb(0)--sm Mt(0.8em)--sm canvas-atom" data-type="text">The Progress cargo ship had lifted off as scheduled at 8:51 p.m. (1451 GMT) from Russia's space launch complex in Baikonur, Kazakhstan, to deliver 2.5 metric tons of fuel, water, food and other supplies. It was set to dock with the space station on Saturday.</p>
<p class="canvas-text Mb(1.0em) Mb(0)--sm Mt(0.8em)--sm canvas-atom" data-type="text">Roscosmos said the craft was operating normally before it stopped transmitting data 6 ½ minutes after the launch. The Russian space agency would not immediately describe the malfunction, saying its experts were looking into it.</p>
<p class="canvas-text Mb(1.0em) Mb(0)--sm Mt(0.8em)--sm canvas-atom" data-type="text">This is the third botched launch of a Russian spacecraft in two years. A Progress cargo ship plunged into the Pacific Ocean in May 2015, and a Proton-M rocket carrying an advanced satellite broke up in the atmosphere in May 2014.</p>
<p class="canvas-text Mb(1.0em) Mb(0)--sm Mt(0.8em)--sm canvas-atom" data-type="text">But both Roscosmos and NASA said the crash of the ship would have no impact on the operations of the orbiting space lab that is currently home to a six-member crew, including three cosmonauts from Russia, two NASA astronauts and one from the European Union.</p>
<p class="canvas-text Mb(1.0em) Mb(0)--sm Mt(0.8em)--sm canvas-atom" data-type="text">Orbital ATK, NASA's other shipper, successfully sent up supplies to the space station in October, and a Japanese cargo spaceship is scheduled to launch a full load in mid-December.</p>
<p class="canvas-text Mb(1.0em) Mb(0)--sm Mt(0.8em)--sm canvas-atom" data-type="text">NASA supplier SpaceX, meanwhile, has been grounded since a rocket explosion in September on the launch pad at Cape Canaveral, Florida. The company hopes to resume launches in December to deliver communication satellites.</p>
<p class="canvas-text Mb(1.0em) Mb(0)--sm Mt(0.8em)--sm canvas-atom" data-type="text">___</p>
<p class="canvas-text Mb(1.0em) Mb(0)--sm Mt(0.8em)--sm canvas-atom" data-type="text">This version corrects the spelling of the region to Tuva, not Tyva.</p>
<p class="canvas-text Mb(1.0em) Mb(0)--sm Mt(0.8em)--sm canvas-atom" data-type="text">__</p>
<p class="canvas-text Mb(1.0em) Mb(0)--sm Mt(0.8em)--sm canvas-atom" data-type="text">Aerospace Writer Marcia Dunn in Cape Canaveral, Florida, and Vladimir Isachenkov in Moscow contributed to this report.</p>
</div>
</article><span class="canvas-bottom-anchor-8dd27580-6b4e-3cfb-a389-5b1ab90bd0eb" aria-hidden="true"></span></div>
</div>

File diff suppressed because one or more lines are too long

@ -51,7 +51,7 @@ function htmlTransform(str) {
function runTestsWithItems(label, domGenerationFn, uri, source, expectedContent, expectedMetadata) {
describe(label, function() {
this.timeout(5000);
this.timeout(6000);
var result;

Loading…
Cancel
Save