Update PicoFeed

This commit is contained in:
Frederic Guillot 2017-01-15 16:05:50 -05:00
parent c01619d835
commit 898dd9bea2
7 changed files with 30 additions and 23 deletions

View File

@ -157,8 +157,9 @@ function fetch_favicon($feed_id, $site_url, $icon_link)
{
if (Helper\bool_config('favicons') && ! Model\Favicon\has_favicon($feed_id)) {
$favicon = new Favicon();
$icon_url = $favicon->find($site_url, $icon_link);
if ($favicon->find($site_url, $icon_link)) {
if (! empty($icon_url)) {
Model\Favicon\create_feed_favicon($feed_id, $favicon->getType(), $favicon->getContent());
}
}

View File

@ -17,7 +17,7 @@
"fguillot/simple-validator": "v1.0.0",
"fguillot/json-rpc": "v1.2.3",
"fguillot/picodb": "v1.0.14 ",
"fguillot/picofeed": "v0.1.29",
"fguillot/picofeed": "v0.1.30",
"pda/pheanstalk": "v3.1.0",
"ircmaxell/password-compat": "^1.0.4"
},

14
composer.lock generated
View File

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "a1111f43530dee7323d23b4fe76637b0",
"content-hash": "957098eb24a77f8299716d34353d0fc8",
"hash": "c801ae93ae28d98a0c8786921d325a53",
"content-hash": "6f772b24ec9a4cc603ef6060b3df7865",
"packages": [
{
"name": "fguillot/json-rpc",
@ -88,16 +88,16 @@
},
{
"name": "fguillot/picofeed",
"version": "v0.1.29",
"version": "v0.1.30",
"source": {
"type": "git",
"url": "https://github.com/fguillot/picoFeed.git",
"reference": "03a0a603173f5d5916d54fd6b8191a3981f949e7"
"reference": "f39a9ec07ee73c969f1c4a7d08c9e319a7f290d7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/03a0a603173f5d5916d54fd6b8191a3981f949e7",
"reference": "03a0a603173f5d5916d54fd6b8191a3981f949e7",
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/f39a9ec07ee73c969f1c4a7d08c9e319a7f290d7",
"reference": "f39a9ec07ee73c969f1c4a7d08c9e319a7f290d7",
"shasum": ""
},
"require": {
@ -137,7 +137,7 @@
],
"description": "Modern library to handle RSS/Atom feeds",
"homepage": "https://github.com/fguillot/picoFeed",
"time": "2017-01-09 23:10:47"
"time": "2017-01-15 20:30:23"
},
{
"name": "fguillot/simple-validator",

View File

@ -265,17 +265,17 @@
},
{
"name": "fguillot/picofeed",
"version": "v0.1.29",
"version_normalized": "0.1.29.0",
"version": "v0.1.30",
"version_normalized": "0.1.30.0",
"source": {
"type": "git",
"url": "https://github.com/fguillot/picoFeed.git",
"reference": "03a0a603173f5d5916d54fd6b8191a3981f949e7"
"reference": "f39a9ec07ee73c969f1c4a7d08c9e319a7f290d7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/03a0a603173f5d5916d54fd6b8191a3981f949e7",
"reference": "03a0a603173f5d5916d54fd6b8191a3981f949e7",
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/f39a9ec07ee73c969f1c4a7d08c9e319a7f290d7",
"reference": "f39a9ec07ee73c969f1c4a7d08c9e319a7f290d7",
"shasum": ""
},
"require": {
@ -295,7 +295,7 @@
"suggest": {
"ext-curl": "PicoFeed will use cURL if present"
},
"time": "2017-01-09 23:10:47",
"time": "2017-01-15 20:30:23",
"bin": [
"picofeed"
],

View File

@ -111,7 +111,7 @@ class Curl extends Client
}
// Do not work with PHP-FPM
if (substr(PHP_SAPI, 0, 3) !== 'cgi') {
if (strpos(PHP_SAPI, 'cgi') !== false) {
header(':', true, $status);
}

View File

@ -95,8 +95,7 @@ class Favicon extends Base
* Download and check if a resource exists.
*
* @param string $url URL
*
* @return \PicoFeed\Client Client instance
* @return \PicoFeed\Client\Client Client instance
*/
public function download($url)
{
@ -118,7 +117,6 @@ class Favicon extends Base
* Check if a remote file exists.
*
* @param string $url URL
*
* @return bool
*/
public function exists($url)
@ -131,7 +129,6 @@ class Favicon extends Base
*
* @param string $website_link URL
* @param string $favicon_link optional URL
*
* @return string
*/
public function find($website_link, $favicon_link = '')
@ -165,7 +162,6 @@ class Favicon extends Base
* Extract the icon links from the HTML.
*
* @param string $html HTML
*
* @return array
*/
public function extract($html)

View File

@ -4,6 +4,7 @@
require_once 'vendor/autoload.php';
use PicoFeed\Config\Config;
use PicoFeed\Reader\Favicon;
use PicoFeed\Scraper\Scraper;
use PicoFeed\Reader\Reader;
use PicoFeed\Logging\Logger;
@ -92,6 +93,12 @@ function grabber($url)
echo $grabber->getFilteredContent().PHP_EOL;
}
function fetch_favicon($url)
{
$favicon = new Favicon();
echo $favicon->find($url) . PHP_EOL;
}
// Parse command line arguments
if ($argc === 4) {
switch ($argv[1]) {
@ -102,8 +109,7 @@ if ($argc === 4) {
nofilter_item($argv[2], $argv[3]);
die;
}
}
else if ($argc === 3) {
} else if ($argc === 3) {
switch ($argv[1]) {
case 'feed':
dump_feed($argv[2]);
@ -114,6 +120,9 @@ else if ($argc === 3) {
case 'grabber':
grabber($argv[2]);
die;
case 'favicon':
fetch_favicon($argv[2]);
die;
}
}
@ -123,3 +132,4 @@ printf("%s debug <feed-url>\n", $argv[0]);
printf("%s item <feed-url> <item-id>\n", $argv[0]);
printf("%s nofilter <feed-url> <item-id>\n", $argv[0]);
printf("%s grabber <url>\n", $argv[0]);
printf("%s favicon <url>\n", $argv[0]);