Compare commits

..
5 Commits
Author SHA1 Message Date
Jérémy BenoistandGitHub 9306996b47 Merge pull request #53 from j0k3r/openload.co
Add openload.co to media detection
2019-06-25 17:15:37 +02:00
Jeremy Benoist bb75b4f089 Fix PHPStan 2019-06-25 17:06:49 +02:00
Jeremy Benoist 11d2946904 Add openload.co to media detection 2019-06-25 16:54:38 +02:00
Jérémy BenoistandGitHub f808c1b0a2 Merge pull request #50 from j0k3r/fix/non-well-formed-numeric-value
Fix “A non well formed numeric value encountered”
2019-05-11 22:07:19 +02:00
Jeremy Benoist bb65caf864 Fix “A non well formed numeric value encountered” 2019-05-11 21:58:11 +02:00
4 changed files with 5 additions and 6 deletions
+1 -1
View File
@@ -5,4 +5,4 @@ includes:
parameters: parameters:
# https://github.com/phpstan/phpstan/issues/694#issuecomment-350724288 # https://github.com/phpstan/phpstan/issues/694#issuecomment-350724288
autoload_files: autoload_files:
- vendor/bin/.phpunit/phpunit-6.5/vendor/autoload.php - vendor/bin/.phpunit/phpunit-7.4/vendor/autoload.php
-1
View File
@@ -7,7 +7,6 @@
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php" bootstrap="vendor/autoload.php"
> >
+3 -3
View File
@@ -61,7 +61,7 @@ class Readability implements LoggerAwareInterface
// constants // constants
const SCORE_CHARS_IN_PARAGRAPH = 100; const SCORE_CHARS_IN_PARAGRAPH = 100;
const SCORE_WORDS_IN_PARAGRAPH = 20; const SCORE_WORDS_IN_PARAGRAPH = 20;
const GRANDPARENT_SCORE_DIVISOR = 2.2; const GRANDPARENT_SCORE_DIVISOR = 2;
const MIN_PARAGRAPH_LENGTH = 20; const MIN_PARAGRAPH_LENGTH = 20;
const MIN_COMMAS_IN_PARAGRAPH = 6; const MIN_COMMAS_IN_PARAGRAPH = 6;
const MIN_ARTICLE_LENGTH = 200; const MIN_ARTICLE_LENGTH = 200;
@@ -95,7 +95,7 @@ class Readability implements LoggerAwareInterface
'negative' => '/bottom|stat|info|discuss|e[\-]?mail|comment|reply|log.{2}(n|ed)|sign|single|combx|com-|contact|_nav|link|media|promo|\bad-|related|scroll|shoutbox|sidebar|sponsor|shopping|teaser|recommend/i', 'negative' => '/bottom|stat|info|discuss|e[\-]?mail|comment|reply|log.{2}(n|ed)|sign|single|combx|com-|contact|_nav|link|media|promo|\bad-|related|scroll|shoutbox|sidebar|sponsor|shopping|teaser|recommend/i',
'divToPElements' => '/<(?:blockquote|header|section|code|div|article|footer|aside|img|p|pre|dl|ol|ul)/mi', 'divToPElements' => '/<(?:blockquote|header|section|code|div|article|footer|aside|img|p|pre|dl|ol|ul)/mi',
'killBreaks' => '/(<br\s*\/?>([ \r\n\s]|&nbsp;?)*)+/', 'killBreaks' => '/(<br\s*\/?>([ \r\n\s]|&nbsp;?)*)+/',
'media' => '!//(?:[^\.\?/]+\.)?(?:youtu(?:be)?|giphy|soundcloud|dailymotion|vimeo|pornhub|xvideos|twitvid|rutube|viddler)\.(?:com|be|org|net)/!i', 'media' => '!//(?:[^\.\?/]+\.)?(?:youtu(?:be)?|giphy|soundcloud|dailymotion|vimeo|pornhub|xvideos|twitvid|rutube|openload\.co|viddler)\.(?:com|be|org|net)/!i',
'skipFootnoteLink' => '/^\s*(\[?[a-z0-9]{1,2}\]?|^|edit|citation needed)\s*$/i', 'skipFootnoteLink' => '/^\s*(\[?[a-z0-9]{1,2}\]?|^|edit|citation needed)\s*$/i',
]; ];
public $tidy_config = [ public $tidy_config = [
@@ -1115,7 +1115,7 @@ class Readability implements LoggerAwareInterface
// Add the score to the parent. The grandparent gets half. // Add the score to the parent. The grandparent gets half.
$parentNode->getAttributeNode('readability')->value += $contentScore; $parentNode->getAttributeNode('readability')->value += $contentScore;
if ($grandParentNode) { if ($grandParentNode) {
$grandParentNode->getAttributeNode('readability')->value += $contentScore / self::GRANDPARENT_SCORE_DIVISOR; $grandParentNode->getAttributeNode('readability')->value += round($contentScore / self::GRANDPARENT_SCORE_DIVISOR);
} }
} }
+1 -1
View File
@@ -193,7 +193,7 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase
$this->assertEmpty($readability->getTitle()->getInnerHtml()); $this->assertEmpty($readability->getTitle()->getInnerHtml());
$this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml()); $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
$this->assertNotContains('<aside>', $readability->getContent()->getInnerHtml()); $this->assertNotContains('<aside>', $readability->getContent()->getInnerHtml());
$this->assertContains('<footer readability="4"/>', $readability->getContent()->getInnerHtml()); $this->assertContains('<footer readability="5"/>', $readability->getContent()->getInnerHtml());
} }
public function testWithClasses() public function testWithClasses()