From 9e5b91ed8b1c1a8c03d4c1380238435ad92b8210 Mon Sep 17 00:00:00 2001 From: Janet Date: Thu, 22 Dec 2016 00:57:13 -0500 Subject: [PATCH] feat: refinery29 parser (#71) --- .../www.refinery29.com/1481661863250.html | 1 + src/extractors/custom/index.js | 1 + .../custom/www.refinery29.com/index.js | 59 +++++++++++++ .../custom/www.refinery29.com/index.test.js | 87 +++++++++++++++++++ 4 files changed, 148 insertions(+) create mode 100644 fixtures/www.refinery29.com/1481661863250.html create mode 100644 src/extractors/custom/www.refinery29.com/index.js create mode 100644 src/extractors/custom/www.refinery29.com/index.test.js diff --git a/fixtures/www.refinery29.com/1481661863250.html b/fixtures/www.refinery29.com/1481661863250.html new file mode 100644 index 000000000..dd0ac5e95 --- /dev/null +++ b/fixtures/www.refinery29.com/1481661863250.html @@ -0,0 +1 @@ + Donald Robertson Creative Style Statement Shirts

For Holiday Parties This Year, Let's Get Behind The Conversation-Starter Tee

In a year when so much (too much?) happened that we're all still trying to make sense of, it makes a lot of sense that graphic tees — the kinds with sound bites, provocative statements, and subversive takes on familiar logos — were so ubiquitous. A tee like these lets you broadcast what you think and feel every second you're wearing it. But isn't it curious that at those events where we tend to need a little help with conversation — awkward holiday parties — clothes that elicit anything other than "That looks nice!" are nowhere to be found?
"That looks nice" hardly ever leads to a deep, buddy-making conversation. And, to be frank, saying, "that looks nice" is also a deflated kind of way to wrap up a year and look forward to the next. Why not say, "Let's be kind toward one another." Or even, "Yes! I see you, Queen!"
Advertisement
So, we're going to be introducing T-shirts into our holiday-party wardrobe for the above reason — and because they're a fresh way to make fancy dresses and separates feel more like something you'd wear, and less like something the Lifetime movie version of you would wear. To help us out in this endeavor, we've turned to six of our favorite illustrators and artists whose work we've looked to for eye candy and wisdom in the past year — and have commissioned six one-of-a-kind T-shirts that communicate exactly what's on their minds.
Because if we've learned anything from this year, it's that we're all better off if we talk to one another.
Photographed by Sharokh Mirzai.
Isa Arfen pants; RED Valentino dress; Sonia Rykiel corset; Frye Addison Belt, $148, available at Frye.
The statement: "I enjoy writing out my own maxims on Instagram, which are generally about my own vulnerability and fucked-up-ness. I like exposing that and having a dialogue with people."
The ideal conversation-starter scenario: "[They'd say,] 'Hey, I fucking care about shit, too!'"
Advertisement
The styling tip: This is the perfect time to buy one of those totally sheer dresses you've been seeing. Instead of a slip, wear your tee underneath, and tuck it into either a slip skirt or a pair of superhero tights.
Photographed by Sharokh Mirzai.
Topshop Mesh and Flower Applique Midi Skirt, $130, available at Topshop; Lane Bryant Lurex Chevron Shimmer Tights, $20, available at Lane Bryant; Perrin gloves; Meira T Pave Diamond Circle Earrings, $4,590, available at Meira T.

Muuto E27 Halogen Pendant, $79, available at ABC Carpet & Home.
Photographed by Sharokh Mirzai.
Topshop Mesh and Flower Applique Midi Skirt, $130, available at Topshop; Lane Bryant Lurex Chevron Shimmer Tights, $20, available at Lane Bryant; Perrin gloves; Meira T Pave Diamond Circle Earrings, $4,590, available at Meira T.

Softline Pink Noomi Swivel Chair, $1,329, available at ABC Carpet & Home.
The statement: "Someone’s choice in lingerie style reveals more about their personality than any piece of outerwear. But great lingerie can get a little pricey. Enter, The Braless Bra Tee, the T-shirt that bridges the gap between multi-pack, 50%-off, getting-shit-done bras, and embroidered, jewel-dripping, couture brassieres."
The ideal conversation-starter scenario: "It's a great ice-breaker. Walk up to fellow partier with your coat buttoned-up: 'Hi, want to see a magic trick? I can go braless and be wearing a bra at the same time.' Unbutton coat, reveal T-shirt…then walk away abracada-bra."
The styling tip: Instead of a blazer or another jacket, try a pair of evening gloves (yes, really!). Long elbow gloves have been trending hard on the runways for the past couple years, and it's time to bring that look home.
Advertisement
Photographed by Sharokh Mirzai.
Dsquared sweater; Cedric Charlier top; Miu Miu pants; Miu Miu shoes; Bounkit Rectangular Buttons, $275, available at Bounkit; Edie Parker Melissa Crushed Velvet Jewel Shoulder Bag, available at Bergdorf Goodman.

ABC DNA Sent Sofia Rectangular Pouf Fuchsia, $2,295, available at ABC Carpet & Home.
The statement: "I'm never really happy when I draw just one person. I prefer drawing a crowd. Takes the pressure off."
The ideal conversation-starter scenario: "If you wore this shirt to a party, you would be the only one in it, because I made it just for you. [It's a] couture D-shirt!

The styling tip: To build up the drama, layer on a bustier, a ruffled crop top, or even a fancy swimsuit top. Balance it with with a bottom that has a higher waist to streamline your outfit.
Photographed by Sharokh Mirzai.
Cinq a Sept Celtic Mesh Turtleneck, $219, available at Intermix; Preen By Thornton Bregazzi Rebecca V-Neck Ruched Velvet Dress, $2,037, available at MatchesFashion.com; Sarah Flint Luisa Flat, $995, available at Sarah Flint; Holly Dyment ring;
Photographed by Sharokh Mirzai.
Cinq a Sept Celtic Mesh Turtleneck, $219, available at Intermix; Preen By Thornton Bregazzi Rebecca V-Neck Ruched Velvet Dress, $2,037, available at MatchesFashion.com; Sarah Flint Luisa Flat, $995, available at Sarah Flint; Holly Dyment ring.

Flos White AIM Pendant Light, $620, available at ABC Carpet & Home.
Advertisement
The statement: "The statement tee I made is [part of] an ongoing series that I call Journey Journal Tees. Each tee is hand-drawn and inspired by pages from my actual journals."
The ideal conversation-starter scenario: "Sparked-up conversations ignite ideas, and hopefully this tee would become a conversation piece!"
The styling tip: Off-the-shoulder dresses look dramatic, but can be a pain in the butt to wear. Wear a tee underneath — not only will the friction help keep the dress in place (no more yanking!), but the generous cut of the dress is made to show off a great graphic.
Photographed by Sharokh Mirzai.
Fleur Du Mal Bias Slip Gown, $495, available at Fleur du Mal; Yandy Fence Net Pantyhose, $6, available at Yandy.com.
Photographed by Sharokh Mirzai.
Fleur Du Mal Bias Slip Gown, $495, available at Fleur du Mal; Yandy Fence Net Pantyhose, $6, available at Yandy.com; Chiara Ferragni shoes.
The statement: "This is a DIY band shirt for the early '80s band, Marine Girls, featuring one of their lyrics, 'All dressed up and nowhere to go.' I really like the idea of a fan-made band tee. I think more people should make their own!"
Advertisement
The ideal conversation-starter scenario: "Two Marine Girls fans meet because of the tee and bond over their love of emotional early-'80s post-punk. And then she would put their record on and everyone would dance to them!"
The styling tip: A low-back slip dress perfectly frames a tee with a back graphic. Start your night with both layers, and start stripping when — if Karman's predictions come true — the '80s dance party really starts going.
Photographed by Sharokh Mirzai.
Stella McCartney Carmen Metallic-Paneled Pleated Crepe Maxi Skirt, $1,017, available at Net-A-Porter.com; Alexandre Birman shoes; Topman suspenders; Shebee Gray Foil Topaz Drops, $950, available at Shebee.
The statement: "[This shirt is] inspired from my For My Girls art series, which celebrates bold and confident women inspired by '90s female hip-hop artists. I wanted the wearer of the shirt to feel like a bad ass! I want them to own the statement 'For My Girls.'
The ideal conversation-starter scenario: "I hope that when a woman sees another woman wearing this shirt, she’s like, 'Yes! I see you, Queen!'"
Advertisement
The styling tip: A pair of suspenders might seem more like a Halloween thing than a holidays thing, but with the right outfit, they can look incredibly festive. With a glitzy skirt and turn-up heels, suspenders can nod to black-tie dressing, without actually going there.
Special thanks to ABC Carpet & Home.
Advertisement
\ No newline at end of file diff --git a/src/extractors/custom/index.js b/src/extractors/custom/index.js index c755f747c..090b9c3d5 100644 --- a/src/extractors/custom/index.js +++ b/src/extractors/custom/index.js @@ -37,3 +37,4 @@ export * from './247sports.com'; export * from './uproxx.com'; export * from './www.eonline.com'; export * from './www.miamiherald.com'; +export * from './www.refinery29.com'; diff --git a/src/extractors/custom/www.refinery29.com/index.js b/src/extractors/custom/www.refinery29.com/index.js new file mode 100644 index 000000000..95cbaf03c --- /dev/null +++ b/src/extractors/custom/www.refinery29.com/index.js @@ -0,0 +1,59 @@ +export const WwwRefinery29ComExtractor = { + domain: 'www.refinery29.com', + + title: { + selectors: [ + 'h1.title', + ], + }, + + author: { + selectors: [ + '.contributor', + ], + }, + + date_published: { + selectors: [ + ['meta[name="sailthru.date"]', 'value'], + ], + + timezone: 'America/New_York', + }, + + lead_image_url: { + selectors: [ + ['meta[name="og:image"]', 'value'], + ], + }, + + content: { + selectors: [ + ['.full-width-opener', '.article-content'], + '.article-content', + '.body', + ], + + // Is there anything in the content you selected that needs transformed + // before it's consumable content? E.g., unusual lazy loaded images + transforms: { + 'div.loading noscript': ($node) => { + const imgHtml = $node.html(); + $node.parents('.loading').replaceWith(imgHtml); + }, + + '.section-image': 'figure', + + '.section-image .content-caption': 'figcaption', + + '.section-text': 'p', + }, + + // Is there anything that is in the result that shouldn't be? + // The clean selectors will remove anything that matches from + // the result + clean: [ + '.story-share', + ], + }, +}; diff --git a/src/extractors/custom/www.refinery29.com/index.test.js b/src/extractors/custom/www.refinery29.com/index.test.js new file mode 100644 index 000000000..e59b6c91c --- /dev/null +++ b/src/extractors/custom/www.refinery29.com/index.test.js @@ -0,0 +1,87 @@ +import assert from 'assert'; +import fs from 'fs'; +import URL from 'url'; +import cheerio from 'cheerio'; + +import Mercury from 'mercury'; +import getExtractor from 'extractors/get-extractor'; +import { excerptContent } from 'utils/text'; + +describe('WwwRefinery29ComExtractor', () => { + describe('initial test case', () => { + let result; + let url; + beforeAll(() => { + url = + 'http://www.refinery29.com/2016/12/132377/graphic-tees-statement-shirt-style-tips'; + const html = + fs.readFileSync('./fixtures/www.refinery29.com/1481661863250.html'); + result = + Mercury.parse(url, html, { fallback: false }); + }); + + it('is selected properly', () => { + // This test should be passing by default. + // It sanity checks that the correct parser + // is being selected for URLs from this domain + const extractor = getExtractor(url); + assert.equal(extractor.domain, URL.parse(url).hostname); + }); + + it('returns the title', async () => { + // To pass this test, fill out the title selector + // in ./src/extractors/custom/www.refinery29.com/index.js. + const { title } = await result; + + // Update these values with the expected values from + // the article. + assert.equal(title, 'For Holiday Parties This Year, Let\'s Get Behind The Conversation-Starter Tee'); + }); + + it('returns the author', async () => { + // To pass this test, fill out the author selector + // in ./src/extractors/custom/www.refinery29.com/index.js. + const { author } = await result; + + // Update these values with the expected values from + // the article. + assert.equal(author, 'Connie Wang'); + }); + + it('returns the date_published', async () => { + // To pass this test, fill out the date_published selector + // in ./src/extractors/custom/www.refinery29.com/index.js. + const { date_published } = await result; + + // Update these values with the expected values from + // the article. + assert.equal(date_published, '2016-12-13T01:00:00.000Z'); + }); + + it('returns the lead_image_url', async () => { + // To pass this test, fill out the lead_image_url selector + // in ./src/extractors/custom/www.refinery29.com/index.js. + const { lead_image_url } = await result; + + // Update these values with the expected values from + // the article. + assert.equal(lead_image_url, 'http://s3.r29static.com//bin/entry/fc5/0,213,2000,1050/x,80/1708221/image.jpg'); + }); + + it('returns the content', async () => { + // To pass this test, fill out the content selector + // in ./src/extractors/custom/www.refinery29.com/index.js. + // You may also want to make use of the clean and transform + // options. + const { content } = await result; + + const $ = cheerio.load(content || ''); + + const first13 = excerptContent($('*').first().text(), 13); + + // Update these values with the expected values from + // the article. + assert.equal(first13, 'In a year when so much (too much?) happened that we\'re all still'); + }); + }); +});