Update picofeed

This commit is contained in:
Frederic Guillot 2015-10-12 15:29:25 -04:00
parent c40640e582
commit cd80440ae2
7 changed files with 82 additions and 63 deletions

View File

@ -6,7 +6,7 @@
"fguillot/simple-validator": "v1.0.0", "fguillot/simple-validator": "v1.0.0",
"fguillot/json-rpc": "v1.0.2", "fguillot/json-rpc": "v1.0.2",
"fguillot/picodb": "v1.0.2", "fguillot/picodb": "v1.0.2",
"fguillot/picofeed": "v0.1.10" "fguillot/picofeed": "v0.1.11"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "4.8.3", "phpunit/phpunit": "4.8.3",

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php'; require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit26454215d679bdaf4be648601e93de89::getLoader(); return ComposerAutoloaderInit6f38ac58c5736de0153f570459656edc::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer // autoload_real.php @generated by Composer
class ComposerAutoloaderInit26454215d679bdaf4be648601e93de89 class ComposerAutoloaderInit6f38ac58c5736de0153f570459656edc
{ {
private static $loader; private static $loader;
@ -19,9 +19,9 @@ class ComposerAutoloaderInit26454215d679bdaf4be648601e93de89
return self::$loader; return self::$loader;
} }
spl_autoload_register(array('ComposerAutoloaderInit26454215d679bdaf4be648601e93de89', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInit6f38ac58c5736de0153f570459656edc', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(); self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit26454215d679bdaf4be648601e93de89', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInit6f38ac58c5736de0153f570459656edc', 'loadClassLoader'));
$map = require __DIR__ . '/autoload_namespaces.php'; $map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) { foreach ($map as $namespace => $path) {
@ -42,14 +42,14 @@ class ComposerAutoloaderInit26454215d679bdaf4be648601e93de89
$includeFiles = require __DIR__ . '/autoload_files.php'; $includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) { foreach ($includeFiles as $file) {
composerRequire26454215d679bdaf4be648601e93de89($file); composerRequire6f38ac58c5736de0153f570459656edc($file);
} }
return $loader; return $loader;
} }
} }
function composerRequire26454215d679bdaf4be648601e93de89($file) function composerRequire6f38ac58c5736de0153f570459656edc($file)
{ {
require $file; require $file;
} }

View File

@ -37,55 +37,6 @@
"description": "Simple validator library", "description": "Simple validator library",
"homepage": "https://github.com/fguillot/simpleValidator" "homepage": "https://github.com/fguillot/simpleValidator"
}, },
{
"name": "fguillot/picofeed",
"version": "v0.1.10",
"version_normalized": "0.1.10.0",
"source": {
"type": "git",
"url": "https://github.com/fguillot/picoFeed.git",
"reference": "a2cc36244278afbfb9578037b1700ca3cd5a87d7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/a2cc36244278afbfb9578037b1700ca3cd5a87d7",
"reference": "a2cc36244278afbfb9578037b1700ca3cd5a87d7",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"php": ">=5.3.0"
},
"suggest": {
"ext-curl": "PicoFeed will use cURL if present"
},
"time": "2015-09-12 11:05:28",
"bin": [
"picofeed"
],
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"PicoFeed": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frédéric Guillot"
}
],
"description": "Modern library to handle RSS/Atom feeds",
"homepage": "https://github.com/fguillot/picoFeed"
},
{ {
"name": "fguillot/json-rpc", "name": "fguillot/json-rpc",
"version": "v1.0.2", "version": "v1.0.2",
@ -162,5 +113,54 @@
], ],
"description": "Minimalist database query builder", "description": "Minimalist database query builder",
"homepage": "https://github.com/fguillot/picoDb" "homepage": "https://github.com/fguillot/picoDb"
},
{
"name": "fguillot/picofeed",
"version": "v0.1.11",
"version_normalized": "0.1.11.0",
"source": {
"type": "git",
"url": "https://github.com/fguillot/picoFeed.git",
"reference": "14080ad7eef9f88744629d67a62da7c7b43d4e2c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/14080ad7eef9f88744629d67a62da7c7b43d4e2c",
"reference": "14080ad7eef9f88744629d67a62da7c7b43d4e2c",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"php": ">=5.3.0"
},
"suggest": {
"ext-curl": "PicoFeed will use cURL if present"
},
"time": "2015-10-12 18:20:52",
"bin": [
"picofeed"
],
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"PicoFeed": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frédéric Guillot"
}
],
"description": "Modern library to handle RSS/Atom feeds",
"homepage": "https://github.com/fguillot/picoFeed"
} }
] ]

View File

@ -88,9 +88,10 @@ class Html
*/ */
public function __construct($html, $website) public function __construct($html, $website)
{ {
$this->config = new Config;
$this->input = XmlParser::HtmlToXml($html); $this->input = XmlParser::HtmlToXml($html);
$this->output = ''; $this->output = '';
$this->tag = new Tag; $this->tag = new Tag($this->config);
$this->website = $website; $this->website = $website;
$this->attribute = new Attribute(new Url($website)); $this->attribute = new Attribute(new Url($website));
} }

View File

@ -3,7 +3,9 @@
namespace PicoFeed\Filter; namespace PicoFeed\Filter;
use DOMXpath; use DOMXpath;
use PicoFeed\Parser\XmlParser; use PicoFeed\Parser\XmlParser;
use PicoFeed\Config\Config;
/** /**
* Tag Filter class * Tag Filter class
@ -13,6 +15,14 @@ use PicoFeed\Parser\XmlParser;
*/ */
class Tag class Tag
{ {
/**
* Config object
*
* @access private
* @var \PicoFeed\Config\Config
*/
private $config;
/** /**
* Tags blacklist (Xpath expressions) * Tags blacklist (Xpath expressions)
* *
@ -71,6 +81,11 @@ class Tag
'q', 'q',
); );
public function __construct(Config $config)
{
$this->config = $config;
}
/** /**
* Check if the tag is allowed and is not a pixel tracker * Check if the tag is allowed and is not a pixel tracker
* *
@ -130,7 +145,10 @@ class Tag
*/ */
public function isAllowedTag($tag) public function isAllowedTag($tag)
{ {
return in_array($tag, $this->tag_whitelist); return in_array($tag, array_merge(
$this->tag_whitelist,
array_keys($this->config->getFilterWhitelistedTags(array()))
));
} }
/** /**

View File

@ -2,13 +2,13 @@
return array( return array(
'grabber' => array( 'grabber' => array(
'%.*%' => array( '%.*%' => array(
'test_url' => 'http://www.numerama.com/magazine/26857-bientot-des-robots-dans-les-cuisines-de-mcdo.html', 'test_url' => 'http://www.numerama.com/sciences/125959-recherches-ladn-recompensees-nobel-de-chimie.html',
'body' => array( 'body' => array(
'//div[@class="col_left"]//div[@class="content"]', '//article',
), ),
'strip' => array( 'strip' => array(
'//div[@class="news_social"]', '//footer',
'//div[@id="newssuiv"]', '//section[@class="related-article"]',
) )
) )
) )