-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
193 changed files
with
4,177 additions
and
4,315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/fixtures/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Use this file as a starting point for your project's .eslintrc. | ||
// Copy this file, and add rule overrides as needed. | ||
{ | ||
"parser": "babel-eslint", | ||
"extends": "airbnb", | ||
"plugins": [ | ||
"babel" | ||
], | ||
"globals": { | ||
/* mocha */ | ||
"describe", | ||
"it" | ||
}, | ||
"rules": { | ||
"no-param-reassign": 0, | ||
/* TODO fix this; this should work w/import/resolver below, but doesn't */ | ||
"import/no-extraneous-dependencies": 0, | ||
"import/no-unresolved": 0, | ||
"no-control-regex": 0, | ||
"import/prefer-default-export": 0, | ||
"generator-star-spacing": 0, | ||
"babel/generator-star-spacing": 0, | ||
"func-names": 0, | ||
"no-useless-escape": 0, | ||
"no-confusing-arrow": 0, | ||
}, | ||
"settings": { | ||
"import/resolver": { | ||
"babel-module": { | ||
"extensions": [".js"] | ||
} | ||
} | ||
}, | ||
"parserOptions":{ | ||
"ecmaFeatures": { | ||
"experimentalObjectRestSpread": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/local/bin/fish | ||
|
||
set file $argv[1] | ||
set function $argv[2] | ||
|
||
touch src/extractors/generic/next-page-url/scoring/utils/index.js | ||
touch src/extractors/generic/next-page-url/scoring/utils/$file.js | ||
touch src/extractors/generic/next-page-url/scoring/utils/$file.test.js | ||
|
||
echo "import assert from 'assert';" > src/extractors/generic/next-page-url/scoring/utils/$file.test.js | ||
echo "" >> src/extractors/generic/next-page-url/scoring/utils/$file.test.js | ||
echo "import $function from './$file';" >> src/extractors/generic/next-page-url/scoring/utils/$file.test.js | ||
echo "" >> src/extractors/generic/next-page-url/scoring/utils/$file.test.js | ||
echo "export { default as $function } from './$file'" >> src/extractors/generic/next-page-url/scoring/utils/index.js | ||
|
||
echo "Now make it a default export" | ||
echo "Move it to its file" | ||
echo "Move its tests to its test file" | ||
echo "import in score-links" | ||
echo "Test it." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { CLEAN_AUTHOR_RE } from './constants' | ||
import { CLEAN_AUTHOR_RE } from './constants'; | ||
|
||
// Take an author string (like 'By David Smith ') and clean it to | ||
// just the name(s): 'David Smith'. | ||
export default function cleanAuthor(author) { | ||
return author.replace(CLEAN_AUTHOR_RE, '$2').trim() | ||
return author.replace(CLEAN_AUTHOR_RE, '$2').trim(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import assert from 'assert' | ||
import assert from 'assert'; | ||
|
||
import cleanAuthor from './author' | ||
import cleanAuthor from './author'; | ||
|
||
describe('cleanAuthor(author)', () => { | ||
it('removes the By from an author string', () => { | ||
const author = cleanAuthor('By Bob Dylan') | ||
const author = cleanAuthor('By Bob Dylan'); | ||
|
||
assert.equal(author, 'Bob Dylan') | ||
}) | ||
assert.equal(author, 'Bob Dylan'); | ||
}); | ||
|
||
it('trims trailing whitespace and line breaks', () => { | ||
const text = ` | ||
written by | ||
Bob Dylan | ||
` | ||
const author = cleanAuthor(text) | ||
`; | ||
const author = cleanAuthor(text); | ||
|
||
assert.equal(author, 'Bob Dylan') | ||
}) | ||
}) | ||
assert.equal(author, 'Bob Dylan'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
import assert from 'assert' | ||
import cheerio from 'cheerio' | ||
import fs from 'fs' | ||
import assert from 'assert'; | ||
import cheerio from 'cheerio'; | ||
import fs from 'fs'; | ||
|
||
import extractCleanNode from './content' | ||
import extractBestNode from 'extractors/generic/content/extract-best-node' | ||
import extractBestNode from 'extractors/generic/content/extract-best-node'; | ||
import extractCleanNode from './content'; | ||
|
||
describe('extractCleanNode(article, { $, cleanConditionally, title } })', () => { | ||
it("cleans cruft out of a DOM node", () => { | ||
const html = fs.readFileSync('./fixtures/wired.html', 'utf-8') | ||
let $ = cheerio.load(html) | ||
it('cleans cruft out of a DOM node', () => { | ||
const html = fs.readFileSync('./fixtures/wired.html', 'utf-8'); | ||
const $ = cheerio.load(html); | ||
|
||
const opts = { | ||
stripUnlikelyCandidates: true, | ||
weightNodes: true, | ||
cleanConditionally: true, | ||
} | ||
stripUnlikelyCandidates: true, | ||
weightNodes: true, | ||
cleanConditionally: true, | ||
}; | ||
|
||
const bestNode = extractBestNode($, opts) | ||
let result = $.html(bestNode) | ||
// console.log(result) | ||
// console.log(result.length) | ||
const cleanNode = extractCleanNode(bestNode, { $, opts }) | ||
result = $.html(cleanNode) | ||
// console.log(result.length) | ||
// console.log(result) | ||
// console.log(bestNode.html()) | ||
const bestNode = extractBestNode($, opts); | ||
// let result = $.html(bestNode); | ||
// // console.log(result) | ||
// // console.log(result.length) | ||
const cleanNode = extractCleanNode(bestNode, { $, opts }); | ||
// result = $.html(cleanNode); | ||
// // console.log(result.length) | ||
// // console.log(result) | ||
// // console.log(bestNode.html()) | ||
|
||
assert.equal($(bestNode).text().length, 2687) | ||
}) | ||
}) | ||
assert.equal($(cleanNode).text().length, 2687); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.