From b1f6c62b2512e3350f46bfd5ddb3761ad689667f Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Wed, 25 Mar 2015 13:53:12 +0000 Subject: [PATCH] Fix tests for readability to also work with jsdom For instance, jsdom's more spec-compliant parsing causes issues with auto-closing elements (lifehacker article) and with not having self-closing and
tags. The former was fixed by removing offending markup, the latter by adjusting JSDOMParser to be more sane, and the expected outputs to cope with this. Finally, JSDOMParser automatically drops comments. The test code needed to manually do this in the jsdom case. --- test/test-pages/001/expected.html | 11 ++- test/test-pages/002/expected.html | 58 ++++++------- test/test-pages/base-url/expected.html | 10 +-- test/test-pages/embedded-videos/expected.html | 13 +-- test/test-pages/herald-sun-1/expected.html | 5 +- test/test-pages/keep-images/expected.html | 50 ++++------- .../expected.html | 24 +++--- .../lifehacker-post-comment-load/source.html | 4 +- .../lifehacker-working/expected.html | 20 ++--- test/test-pages/medium-1/expected.html | 45 +++++----- test/test-pages/medium-2/expected.html | 5 +- .../reordering-paragraphs/expected.html | 4 +- test/test-pages/tmz-1/expected.html | 11 +-- test/test-pages/wapo-1/expected.html | 7 +- test/test-pages/wapo-2/expected.html | 4 +- test/test-readability.js | 84 +++++++++++-------- 16 files changed, 167 insertions(+), 188 deletions(-) diff --git a/test/test-pages/001/expected.html b/test/test-pages/001/expected.html index 89c7eb3..dc510a8 100644 --- a/test/test-pages/001/expected.html +++ b/test/test-pages/001/expected.html @@ -18,9 +18,9 @@ help. actually works…

Drinking game for web devs: -
(1) Think of a noun -
(2) Google "<noun>.js" -
(3) If a library with that name exists - drink

— Shay Friedman (@ironshay) +
(1) Think of a noun +
(2) Google "<noun>.js" +
(3) If a library with that name exists - drink

— Shay Friedman (@ironshay) August 22, 2013
@@ -120,8 +120,7 @@ describe("Cow", function() {

Running the tests now gives us something like this:

- screenshot + screenshot

As you can see, the report at the bottom highlights that we haven't actually tested the case where an error is raised in case a target name is missing. @@ -138,4 +137,4 @@ sessions

- \ No newline at end of file + diff --git a/test/test-pages/002/expected.html b/test/test-pages/002/expected.html index bce7f40..00528ca 100644 --- a/test/test-pages/002/expected.html +++ b/test/test-pages/002/expected.html @@ -85,19 +85,19 @@

The fetch() function’s arguments are the same as those passed to the -
+
Request() constructor, so you may directly pass arbitrarily complex requests to fetch() as discussed below.

Headers

Fetch introduces 3 interfaces. These are Headers, Request and -
+
Response. They map directly to the underlying HTTP concepts, but have -
certain visibility filters in place for privacy and security reasons, +
certain visibility filters in place for privacy and security reasons, such as -
supporting CORS rules and ensuring cookies aren’t readable by third parties.

+
supporting CORS rules and ensuring cookies aren’t readable by third parties.

The Headers interface is a simple multi-map of names to values:

@@ -117,7 +117,7 @@ reqHeaders.append("X-Custom-Header"

The same can be achieved by passing an array of arrays or a JS object literal -
to the constructor:

+
to the constructor:

@@ -155,25 +155,25 @@ console.log(reqHeaders.getAll(

Some of these operations are only useful in ServiceWorkers, but they provide -
a much nicer API to Headers.

+
a much nicer API to Headers.

Since Headers can be sent in requests, or received in responses, and have various limitations about what information can and should be mutable, Headers objects have a guard property. This is not exposed to the Web, but it affects which mutation operations are allowed on the Headers object. -
Possible values are:

+
Possible values are:

  • “none”: default.
  • “request”: guard for a Headers object obtained from a Request (Request.headers).
  • “request-no-cors”: guard for a Headers object obtained from a Request created -
    with mode “no-cors”.
  • +
    with mode “no-cors”.
  • “response”: naturally, for Headers obtained from Response (Response.headers).
  • “immutable”: Mostly used for ServiceWorkers, renders a Headers object -
    read-only.
  • +
    read-only.

The details of how each guard affects the behaviors of the Headers object are -
in the specification. For example, +
in the specification. For example, you may not append or set a “request” guarded Headers’ “Content-Length” header. Similarly, inserting “Set-Cookie” into a Response header is not allowed so that ServiceWorkers may not set cookies via synthesized Responses.

@@ -221,9 +221,9 @@ console.log(req.url);<

You may also pass a Request to the Request() constructor to create a copy. -
(This is not the same as calling the clone() method, which +
(This is not the same as calling the clone() method, which is covered in -
the “Reading bodies” section.).

+
the “Reading bodies” section.).

@@ -240,7 +240,7 @@ console.log(copy.url);

Again, this form is probably only useful in ServiceWorkers.

The non-URL attributes of the Request can only be set by passing initial -
values as a second argument to the constructor. This argument is a dictionary.

+
values as a second argument to the constructor. This argument is a dictionary.

@@ -266,7 +266,7 @@ console.log(copy.url);

The "same-origin" mode is simple, if a request is made to another origin with this mode set, the result is simply an error. You could use this to ensure that -
a request is always being made to your origin.

+
a request is always being made to your origin.

@@ -295,7 +295,7 @@ fetch(arbitraryUrl,{ mode:

"cors" mode is what you’ll usually use to make known cross-origin requests to access various APIs offered by other vendors. These are expected to adhere to -
the CORS protocol. +
the CORS protocol. Only a limited set of headers is exposed in the Response, but the body is readable. For example, you could get a list of Flickr’s most interesting photos @@ -330,7 +330,7 @@ apiCall.then(function(respon

You may not read out the “Date” header since Flickr does not allow it via -
+
Access-Control-Expose-Headers.

@@ -345,21 +345,21 @@ apiCall.then(function(respon

The credentials enumeration determines if cookies for the other domain are -
sent to cross-origin requests. This is similar to XHR’s withCredentials +
sent to cross-origin requests. This is similar to XHR’s withCredentials -
flag, but tri-valued as "omit" (default), "same-origin" and "include".

+
flag, but tri-valued as "omit" (default), "same-origin" and "include".

The Request object will also give the ability to offer caching hints to the user-agent. This is currently undergoing some security review. Firefox exposes the attribute, but it has no effect.

Requests have two read-only attributes that are relevant to ServiceWorkers -
intercepting them. There is the string referrer, which is +
intercepting them. There is the string referrer, which is set by the UA to be -
the referrer of the Request. This may be an empty string. The other is -
+
the referrer of the Request. This may be an empty string. The other is +
context which is a rather large enumeration defining what sort of resource is being fetched. This could be “image” if the request is from an - tag in the controlled document, “worker” if it is an attempt to load a + tag in the controlled document, “worker” if it is an attempt to load a worker script, and so on. When used with the fetch() function, it is “fetch”.

@@ -377,11 +377,11 @@ apiCall.then(function(respon The url attribute reflects the URL of the corresponding request.

Response also has a type, which is “basic”, “cors”, “default”, “error” or -
“opaque”.

+
“opaque”.

@@ -421,7 +421,7 @@ apiCall.then(function(respon

The static method Response.error() simply returns an error response. Similarly, Response.redirect(url, status) returns a Response resulting in -
a redirect to url.

+
a redirect to url.

Dealing with bodies

@@ -561,7 +561,7 @@ res.text().catch(ServiceWorkerspecifications.

For a better web!

-

The author would like to thank Andrea Marchesini, Anne van Kesteren and Ben
+

The author would like to thank Andrea Marchesini, Anne van Kesteren and Ben
Kelly for helping with the specification and implementation.

@@ -575,4 +575,4 @@ on

- \ No newline at end of file + diff --git a/test/test-pages/base-url/expected.html b/test/test-pages/base-url/expected.html index 2e9b1f0..c193a05 100644 --- a/test/test-pages/base-url/expected.html +++ b/test/test-pages/base-url/expected.html @@ -19,19 +19,19 @@

Images

- +

- +

- +

- +

- +

Tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo diff --git a/test/test-pages/embedded-videos/expected.html b/test/test-pages/embedded-videos/expected.html index b37810a..8f4c572 100644 --- a/test/test-pages/embedded-videos/expected.html +++ b/test/test-pages/embedded-videos/expected.html @@ -10,20 +10,21 @@

At root

+ frameborder="0" allowfullscreen=""> + frameborder="0" allowfullscreen=""> + width="500" height="281" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" + allowfullscreen="">

In a paragraph

+ frameborder="0" allowfullscreen="">

In a div

+ frameborder="0" allowfullscreen="">

Foo

@@ -33,4 +34,4 @@ cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

- \ No newline at end of file + diff --git a/test/test-pages/herald-sun-1/expected.html b/test/test-pages/herald-sun-1/expected.html index 569a366..f2d2433 100644 --- a/test/test-pages/herald-sun-1/expected.html +++ b/test/test-pages/herald-sun-1/expected.html @@ -4,8 +4,7 @@
A new Bill would require telecommunications service providers to store so-called ‘metadat + alt="A new Bill would require telecommunications service providers to store so-called ‘metadat">

A new Bill would require telecommunications service providers to store so-called ‘metadata’ for two years. @@ -94,4 +93,4 @@ Supplied

- \ No newline at end of file + diff --git a/test/test-pages/keep-images/expected.html b/test/test-pages/keep-images/expected.html index 7515475..731cf7e 100644 --- a/test/test-pages/keep-images/expected.html +++ b/test/test-pages/keep-images/expected.html @@ -4,8 +4,7 @@
+ data-width="2100" data-height="1402" src="https://d262ilb51hltx0.cloudfront.net/max/2000/1*sLDnS1UWEFIS33uLMxq3cw.jpeg">
@@ -15,8 +14,7 @@
+ src="https://d262ilb51hltx0.cloudfront.net/max/800/1*3vIhkoHIzcxvUdijoCVx6w.png">

Standing at a table in a chemistry lab in Barcelona, Cristina Gil Lladanosa @@ -40,8 +38,7 @@

+ data-width="2100" data-height="1402" src="https://d262ilb51hltx0.cloudfront.net/max/2000/1*4gN1-fzOwCniw-DbqQjDeQ.jpeg">
Cristina Gil Lladanosa, at the Barcelona testing lab | photo by Joan Bardeletti
@@ -78,8 +75,7 @@
+ data-width="2100" data-height="1402" src="https://d262ilb51hltx0.cloudfront.net/max/2000/1*2KPmZkIBUrhps-2uwDvYFQ.jpeg">
Photo by Joan Bardeletti
@@ -98,8 +94,7 @@
+ data-width="2013" data-height="1241" src="https://d262ilb51hltx0.cloudfront.net/max/2000/1*PU40bbbox2Ompc5I3RE99A.jpeg">
Photo by Joan Bardeletti
@@ -130,8 +125,7 @@
+ src="https://d262ilb51hltx0.cloudfront.net/max/800/1*ohyycinH18fz98TCyUzVgQ.png">

The deep web drug lab is the brainchild of Fernando Caudevilla, a Spanish @@ -147,8 +141,7 @@

+ data-width="2100" data-height="1241" src="https://d262ilb51hltx0.cloudfront.net/max/2000/1*mKvUNOAVQxl6atCbxbCZsg.jpeg">
Fernando Caudevilla, AKA DoctorX. Photo: Joseph Cox
@@ -203,8 +196,7 @@
+ data-width="4400" data-height="3141" src="https://d262ilb51hltx0.cloudfront.net/max/2000/1*knT10_FNVUmqQIBLnutmzQ.jpeg">
Photo: Joseph Cox
@@ -214,8 +206,7 @@
+ src="https://d262ilb51hltx0.cloudfront.net/max/800/1*ohyycinH18fz98TCyUzVgQ.png">

While the Energy Control lab in Madrid lab only tests Spanish drugs from @@ -248,8 +239,7 @@

+ data-width="2100" data-height="1402" src="https://d262ilb51hltx0.cloudfront.net/max/2000/1*Vr61dyCTRwk6CemmVF8YAQ.jpeg">
Photo by Joan Bardeletti
@@ -296,8 +286,7 @@
+ data-width="2100" data-height="1402" src="https://d262ilb51hltx0.cloudfront.net/max/2000/1*a-1_13xE6_ErQ-QSlz6myw.jpeg">
Photo by Joan Bardeletti
@@ -307,8 +296,7 @@
+ src="https://d262ilb51hltx0.cloudfront.net/max/800/1*ohyycinH18fz98TCyUzVgQ.png">

Despite the prevalence of people using the service to gauge the quality @@ -357,8 +345,7 @@

+ data-width="2100" data-height="1192" src="https://d262ilb51hltx0.cloudfront.net/max/2000/1*IWXhtSsVv0gNnCwnDEXk-Q.jpeg">
Photo by Joan Bardeletti
@@ -391,8 +378,7 @@
+ data-width="1368" data-height="913" src="https://d262ilb51hltx0.cloudfront.net/max/2000/1*NGcrjfkV0l37iQH2uyYjEw.jpeg">
Photo by Joan Bardeletti
@@ -455,8 +441,7 @@
+ data-width="2100" data-height="1373" src="https://d262ilb51hltx0.cloudfront.net/max/2000/1*WRlKt3q3mt7utmwxcbl3sQ.jpeg">
Photo by Joan Bardeletti
@@ -475,8 +460,7 @@
+ src="https://d262ilb51hltx0.cloudfront.net/max/800/1*320_4I0lxbn5x3bx4XPI5Q.png">

Top photo by Joan Bardeletti @@ -493,4 +477,4 @@

- \ No newline at end of file + diff --git a/test/test-pages/lifehacker-post-comment-load/expected.html b/test/test-pages/lifehacker-post-comment-load/expected.html index 127b29b..4a644c4 100644 --- a/test/test-pages/lifehacker-post-comment-load/expected.html +++ b/test/test-pages/lifehacker-post-comment-load/expected.html @@ -1,11 +1,11 @@
-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

We all buy things from time to time that we don't really need. It's okay to appeal to your wants every once in a while, as long as you're in control. If you struggle with clutter, impulse buys, and buyer's remorse, here's how to put your mind in the right place before you even set foot in a store.

Understand How Your Own Brain Works Against You

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

It may come as no surprise to learn that stores employ all kinds of tricks to get you to part ways with your cash, and your brain plays right along. @@ -57,7 +57,7 @@ always research beforehand and be on the lookout for this common trick to avoid impulse buys.

Make a List of Everything You Own and Do Some Decluttering

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

Now that you know what you're up against, it's time to start changing the way you think. Before you can stop buying crap you don't need, you @@ -112,7 +112,7 @@ is all the crap you bought that you don't need. Take a good look and remember it.

See How Much Money and Time You Spent on the Stuff You Threw Out

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

Now take a look at your "crap" list again and start calculating how much you spent on all of it. If it was a gift, mark it as $0. Otherwise, figure @@ -137,7 +137,7 @@

List Every Non-Material Thing In Your Life that Makes You Happy

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

Now it's time to make a different list. While material items may bring plenty of joy, the things in your life that make you happiest probably @@ -148,7 +148,7 @@

These are probably the things that actually make you want to get out of bed in the morning and keep on keepin' on. Once you have it all down, put it in your purse or wallet. The next time you feel the urge to buy something, whip this list out first and remind yourself why you probably don't need it.

Spend Some Time Away from Material Things to Gain Perspective

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

If you're having a really hard time with your spending, it can help to get away from material objects completely. When you're constantly surrounded @@ -163,7 +163,7 @@ without your purse or wallet (but carry your ID). If you can't buy anything, you'll be forced to experience things a different way.

Develop a Personal "Should I Buy This?" Test

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

If you don't have a personal "should I buy this?" test, now's the perfect time to make one. When you find an item you think you need or want, it @@ -191,11 +191,7 @@

Learn to Delay Gratification and Destroy the Urge to Impulse Buy

-

How to Program Your Mind to Stop Buying Crap You Don’t Need - 1

Does it count that I'm waiting for Final Fantasy Type-0 before buying a PS4?

+

How to Program Your Mind to Stop Buying Crap You Don’t Need

When it comes to the unnecessary crap we buy, impulse purchases probably make up a good deal of them. We love to feel gratification instantly and @@ -245,7 +241,7 @@ do and you won't be subconsciously trying to fill that void with useless crap.

Turn the Money You Save Into More Money

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

Once you've programmed your mind to stop buying crap you don't need, you'll have some extra cash to play with. Take all that money and start putting @@ -279,4 +275,4 @@

Photos by cmgirl (Shutterstock), Macrovector (Shutterstock), J E Theriot, davidd, George Redgrave, David Amsler, Arup Malakar, J B, jakerome, 401(K) 2012.

-
\ No newline at end of file + diff --git a/test/test-pages/lifehacker-post-comment-load/source.html b/test/test-pages/lifehacker-post-comment-load/source.html index 8cc18f2..fb7f522 100644 --- a/test/test-pages/lifehacker-post-comment-load/source.html +++ b/test/test-pages/lifehacker-post-comment-load/source.html @@ -778,7 +778,7 @@ google_ad_channel = '1102379497'; -

How to Program Your Mind to Stop Buying Crap You Don’t Need1

Does it count that I'm waiting for Final Fantasy Type-0 before buying a PS4?

+

How to Program Your Mind to Stop Buying Crap You Don’t Need

@@ -1302,4 +1302,4 @@ google_ad_channel = '1102379497'; <img src="http://b.scorecardresearch.com/p?c1=2&c2=6770184&cv=2.0&cj=1" /> -
\ No newline at end of file +
diff --git a/test/test-pages/lifehacker-working/expected.html b/test/test-pages/lifehacker-working/expected.html index 3ec11ce..15fa3c5 100644 --- a/test/test-pages/lifehacker-working/expected.html +++ b/test/test-pages/lifehacker-working/expected.html @@ -1,11 +1,11 @@
-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

We all buy things from time to time that we don't really need. It's okay to appeal to your wants every once in a while, as long as you're in control. If you struggle with clutter, impulse buys, and buyer's remorse, here's how to put your mind in the right place before you even set foot in a store.

Understand How Your Own Brain Works Against You

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

It may come as no surprise to learn that stores employ all kinds of tricks to get you to part ways with your cash, and your brain plays right along. @@ -57,7 +57,7 @@ always research beforehand and be on the lookout for this common trick to avoid impulse buys.

Make a List of Everything You Own and Do Some Decluttering

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

Now that you know what you're up against, it's time to start changing the way you think. Before you can stop buying crap you don't need, you @@ -112,7 +112,7 @@ is all the crap you bought that you don't need. Take a good look and remember it.

See How Much Money and Time You Spent on the Stuff You Threw Out

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

Now take a look at your "crap" list again and start calculating how much you spent on all of it. If it was a gift, mark it as $0. Otherwise, figure @@ -137,7 +137,7 @@

List Every Non-Material Thing In Your Life that Makes You Happy

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

Now it's time to make a different list. While material items may bring plenty of joy, the things in your life that make you happiest probably @@ -148,7 +148,7 @@

These are probably the things that actually make you want to get out of bed in the morning and keep on keepin' on. Once you have it all down, put it in your purse or wallet. The next time you feel the urge to buy something, whip this list out first and remind yourself why you probably don't need it.

Spend Some Time Away from Material Things to Gain Perspective

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

If you're having a really hard time with your spending, it can help to get away from material objects completely. When you're constantly surrounded @@ -163,7 +163,7 @@ without your purse or wallet (but carry your ID). If you can't buy anything, you'll be forced to experience things a different way.

Develop a Personal "Should I Buy This?" Test

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

If you don't have a personal "should I buy this?" test, now's the perfect time to make one. When you find an item you think you need or want, it @@ -191,7 +191,7 @@

Learn to Delay Gratification and Destroy the Urge to Impulse Buy

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

When it comes to the unnecessary crap we buy, impulse purchases probably make up a good deal of them. We love to feel gratification instantly and @@ -241,7 +241,7 @@ do and you won't be subconsciously trying to fill that void with useless crap.

Turn the Money You Save Into More Money

-

How to Program Your Mind to Stop Buying Crap You Don’t Need +

How to Program Your Mind to Stop Buying Crap You Don’t Need

Once you've programmed your mind to stop buying crap you don't need, you'll have some extra cash to play with. Take all that money and start putting @@ -275,4 +275,4 @@

Photos by cmgirl (Shutterstock), Macrovector (Shutterstock), J E Theriot, davidd, George Redgrave, David Amsler, Arup Malakar, J B, jakerome, 401(K) 2012.

-
\ No newline at end of file + diff --git a/test/test-pages/medium-1/expected.html b/test/test-pages/medium-1/expected.html index 8858646..219b3e8 100644 --- a/test/test-pages/medium-1/expected.html +++ b/test/test-pages/medium-1/expected.html @@ -1,7 +1,7 @@

Better Student Journalism

-


+


We pushed out the first version of the Open Journalism site in January. Our goal is for the @@ -36,8 +36,7 @@

+ src="https://d262ilb51hltx0.cloudfront.net/max/800/1*AzYWbe4cZkMMEUbfRjysLQ.png">
topleftpixel.com
@@ -64,8 +63,7 @@
+ src="https://d262ilb51hltx0.cloudfront.net/max/800/1*d0Hp6KlzyIcGHcL6to1sYQ.png">

We don’t know what we don’t know

@@ -119,8 +117,7 @@
+ src="https://d262ilb51hltx0.cloudfront.net/max/800/1*_9KYIFrk_PqWFgptsMDeww.png">
From our 2011 research
@@ -180,8 +177,7 @@
+ data-height="560" src="https://d262ilb51hltx0.cloudfront.net/max/800/1*Vh2MpQjqjPkzYJaaWExoVg.png">
We designed many of these slides to help explain to ourselves what we were doing @@ -196,21 +192,21 @@
  1. The handoff -
    Problems arise because web editors are given roles that absolve the rest +
    Problems arise because web editors are given roles that absolve the rest of the editors from thinking about the web. All editors should be involved in the process of story development for the web. While it’s a good idea to have one specific editor manage the website, contributors and editors should all play with and learn about the web. Instead of “can you make a computer do XYZ for me?”, we should be saying “can you show me how to make a computer do XYZ?”
  2. -
  3. Not just social media
    A +
  4. Not just social media
    A web editor could do much more than simply being in charge of the social media accounts for the student paper. Their responsibility could include teaching all other editors to be listening to what’s happening online. The web editor can take advantage of live information to change how the student newsroom reports news in real time.
  5. Web (interactive) editor
    The + class="graf--li">Web (interactive) editor
    The goal of having a web editor should be for someone to build and tell stories that take full advantage of the web as their medium. Too often the web’s interactivity is not considered when developing the story. The web then @@ -234,8 +230,7 @@
    + src="https://d262ilb51hltx0.cloudfront.net/max/800/1*2Ln_DmC95Xpz6LzgywkcFQ.png">
    The current Open Journalism site was a few years in the making. This was an original launch page we use in 2012
    @@ -244,7 +239,7 @@
    • New process -
      Our rough research has told us newsrooms need to be reorganized. This +
      Our rough research has told us newsrooms need to be reorganized. This includes every part of the newsroom’s workflow: from where a story and its information comes from, to thinking of every word, pixel, and interaction the reader will have with your stories. If I was a photo editor that wanted @@ -258,7 +253,7 @@ fits your newsroom’s needs.
    • More (remote) mentorship -
      Lack of mentorship is still a big problem. Lack of mentorship is still a big problem. Google’s fellowship program is great. The fact that it only caters to United States students isn’t. There are only a handful of @@ -270,7 +265,7 @@
    • Changing a newsroom culture -
      Skill diversity needs to change. We encourage every student newsroom we +
      Skill diversity needs to change. We encourage every student newsroom we talk to, to start building a partnership with their school’s Computer Science department. It will take some work, but you’ll find there are many CS undergrads that love playing with web technologies, and using data to tell stories. @@ -285,7 +280,7 @@
      • Sharing curiosity for the web -
        We don’t know how to best teach students about the web. It’s not efficient +
        We don’t know how to best teach students about the web. It’s not efficient for us to teach coding classes. We do go into newsrooms and get them running their first code exercises, but if someone wants to learn to program, we can only provide the initial push and curiosity. We will be trying out @@ -293,13 +288,13 @@ of how to teach students about the web.
      • Business -
        We don’t know how to convince the business side of student papers that +
        We don’t know how to convince the business side of student papers that they should invest in the web. At the very least we’re able to explain that having students graduate with their current skill set is painful in the current job market.
      • The future -
        We don’t know what journalism or the web will be like in 10 years, but +
        We don’t know what journalism or the web will be like in 10 years, but we can start encouraging students to keep an open mind about the skills they’ll need. We’re less interested in preparing students for the current newsroom climate, than we are in teaching students to have the ability @@ -311,7 +306,7 @@
        • A concise guide to building stories for the web -
          There are too many options to get started. We hope to provide an opinionated +
          There are too many options to get started. We hope to provide an opinionated guide that follows both our experiences, research, and observations from trying to teach our peers.
        @@ -329,8 +324,7 @@ id="7ed3" class="graf--figure">
        + data-height="400" src="https://d262ilb51hltx0.cloudfront.net/max/800/1*bXaR_NBJdoHpRc8lUWSsow.png">
        2012
@@ -358,8 +352,7 @@
+ src="https://d262ilb51hltx0.cloudfront.net/max/800/1*lulfisQxgSQ209vPHMAifg.png">

Let’s talk. Let’s listen. @@ -381,4 +374,4 @@

-
\ No newline at end of file + diff --git a/test/test-pages/medium-2/expected.html b/test/test-pages/medium-2/expected.html index 83727b1..9b28943 100644 --- a/test/test-pages/medium-2/expected.html +++ b/test/test-pages/medium-2/expected.html @@ -4,8 +4,7 @@
+ src="https://d262ilb51hltx0.cloudfront.net/max/1600/1*eR_J8DurqygbhrwDg-WPnQ.png">
Words need defenders.
@@ -95,4 +94,4 @@ stopped, or the world will be lost to meaninglessness forever. Figuratively speaking.

- \ No newline at end of file + diff --git a/test/test-pages/reordering-paragraphs/expected.html b/test/test-pages/reordering-paragraphs/expected.html index 3a54fab..bc68b69 100644 --- a/test/test-pages/reordering-paragraphs/expected.html +++ b/test/test-pages/reordering-paragraphs/expected.html @@ -23,5 +23,5 @@ of matter is called quark-gluon plasma.[81] The exact conditions needed to give rise to this state are unknown and have been the subject of a great deal of speculation and experimentation.

-
- \ No newline at end of file +
+ diff --git a/test/test-pages/tmz-1/expected.html b/test/test-pages/tmz-1/expected.html index c53cc02..1fd4192 100644 --- a/test/test-pages/tmz-1/expected.html +++ b/test/test-pages/tmz-1/expected.html @@ -12,8 +12,7 @@

- 0225-lupita-nyongo-getty-01Lupita Nyong'o's now-famous Oscar dress + 0225-lupita-nyongo-getty-01Lupita Nyong'o's now-famous Oscar dress -- adorned in pearls -- was stolen right out of her hotel room ... TMZ has learned.

Law enforcement sources tell TMZ ... the dress was taken out of Lupita's @@ -24,14 +23,12 @@

We're told there is security footage that cops are looking at that could catch the culprit right in the act. 

- update_graphic_red_bar12:00 PM PT -- Sheriff's deputies were at The London Thursday + update_graphic_red_bar12:00 PM PT -- Sheriff's deputies were at The London Thursday morning.  We know they were in the manager's office and we're told they have looked at security footage to determine if they can ID the culprit.

- 0226-SUB-london-hotel-swipe-tmz-02 + 0226-SUB-london-hotel-swipe-tmz-02

- \ No newline at end of file + diff --git a/test/test-pages/wapo-1/expected.html b/test/test-pages/wapo-1/expected.html index 89e6082..cce10d7 100644 --- a/test/test-pages/wapo-1/expected.html +++ b/test/test-pages/wapo-1/expected.html @@ -114,9 +114,8 @@
-
+ src="https://img.washingtonpost.com/rf/image_480w/2010-2019/WashingtonPost/2015/03/18/Foreign/Graphics/tunisia600.jpg?uuid=1_yuLs2LEeSHME9HNBbnWQ"> +

Officials are worried about the number of Tunisian militants who may have joined the jihadists in Libya — with the goal of returning home to fight @@ -143,4 +142,4 @@

Tunisia’s Bardo museum is home to amazing Roman treasures

- \ No newline at end of file + diff --git a/test/test-pages/wapo-2/expected.html b/test/test-pages/wapo-2/expected.html index ff83c48..3b0c6f4 100644 --- a/test/test-pages/wapo-2/expected.html +++ b/test/test-pages/wapo-2/expected.html @@ -96,9 +96,9 @@

“That could be an issue forced onto the agenda about the same time as a potential nuclear deal.”

-
+

Steven Mufson covers the White House. Since joining The Post, he has covered economics, China, foreign policy and energy.

-
\ No newline at end of file + diff --git a/test/test-readability.js b/test/test-readability.js index d9bc99a..f5de43f 100644 --- a/test/test-readability.js +++ b/test/test-readability.js @@ -1,4 +1,5 @@ var prettyPrint = require("html").prettyPrint; +var jsdom = require("jsdom").jsdom; var chai = require("chai"); chai.config.includeStack = true; var expect = chai.expect; @@ -9,28 +10,45 @@ var JSDOMParser = readability.JSDOMParser; var testPages = require("./bootstrap").getTestPages(); -describe("Test isProbablyReaderable", function() { - testPages.forEach(function(testPage) { - describe(testPage.dir, function() { - var doc, isProbablyReaderable; +function suite(result, expectedContent, expectedMetadata) { + it("should return a result object", function() { + expect(result).to.include.keys("content", "title", "excerpt", "byline"); + }); - before(function() { - doc = new JSDOMParser().parse(testPage.source); - isProbablyReaderable = new Readability(null, doc).isProbablyReaderable(); - }); + it("should extract expected content", function() { + expect(expectedContent).eql(prettyPrint(result.content)); + }); - it("should probably be readerable", function() { - expect(isProbablyReaderable).eql(testPage.expectedMetadata.readerable); - }); - }); + it("should extract expected title", function() { + expect(expectedMetadata.title).eql(result.title); + }); + + it("should extract expected byline", function() { + expect(expectedMetadata.byline).eql(result.byline); }); -}); + + it("should extract expected excerpt", function() { + expect(expectedMetadata.excerpt).eql(result.excerpt); + }); + + it("should probably be readerable", function() { + expect(expectedMetadata.readerable).eql(result.readerable); + }); +} + +function removeCommentNodesRecursively(node) { + [].forEach.call(node.childNodes, function(child) { + if (child.nodeType === child.COMMENT_NODE) { + node.removeChild(child); + } else if (child.nodeType === child.ELEMENT_NODE) { + removeCommentNodesRecursively(child); + } + }); +} describe("Test page", function() { testPages.forEach(function(testPage) { describe(testPage.dir, function() { - var doc, result; - var uri = { spec: "http://fakehost/test/page.html", host: "fakehost", @@ -39,29 +57,23 @@ describe("Test page", function() { pathBase: "http://fakehost/test/" }; - before(function() { - doc = new JSDOMParser().parse(testPage.source); - result = new Readability(uri, doc).parse(); - }); - - it("should return a result object", function() { - expect(result).to.include.keys("content", "title", "excerpt", "byline"); - }); - - it("should extract expected content", function() { - expect(testPage.expectedContent).eql(prettyPrint(result.content)); - }); - - it("should extract expected title", function() { - expect(testPage.expectedMetadata.title).eql(result.title); - }); - - it("should extract expected byline", function() { - expect(testPage.expectedMetadata.byline).eql(result.byline); + describe("jsdom", function() { + var doc = jsdom(testPage.source); + removeCommentNodesRecursively(doc); + var readability = new Readability(uri, doc); + var readerable = readability.isProbablyReaderable(); + var result = readability.parse(); + result.readerable = readerable; + suite(result, testPage.expectedContent, testPage.expectedMetadata); }); - it("should extract expected excerpt", function() { - expect(testPage.expectedMetadata.excerpt).eql(result.excerpt); + describe("JSDOMParser", function() { + var doc = new JSDOMParser().parse(testPage.source); + var readability = new Readability(uri, doc); + var readerable = readability.isProbablyReaderable(); + var result = readability.parse(); + result.readerable = readerable; + suite(result, testPage.expectedContent, testPage.expectedMetadata); }); }); });