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)) { if (Helper\bool_config('favicons') && ! Model\Favicon\has_favicon($feed_id)) {
$favicon = new Favicon(); $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()); Model\Favicon\create_feed_favicon($feed_id, $favicon->getType(), $favicon->getContent());
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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