diff options
40 files changed, 2350 insertions, 320 deletions
diff --git a/composer.lock b/composer.lock index 0e25a2be0..a73fdcce7 100644 --- a/composer.lock +++ b/composer.lock @@ -57,12 +57,12 @@ "source": { "type": "git", "url": "https://github.com/fguillot/picoFeed.git", - "reference": "687cc58b51d739f06bc1729d69280e5a867840dd" + "reference": "6485f32d62698be73c3f0456bb87d960fcae1586" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fguillot/picoFeed/zipball/687cc58b51d739f06bc1729d69280e5a867840dd", - "reference": "687cc58b51d739f06bc1729d69280e5a867840dd", + "url": "https://api.github.com/repos/fguillot/picoFeed/zipball/6485f32d62698be73c3f0456bb87d960fcae1586", + "reference": "6485f32d62698be73c3f0456bb87d960fcae1586", "shasum": "" }, "require": { @@ -86,7 +86,7 @@ ], "description": "Modern library to write or read feeds (RSS/Atom)", "homepage": "http://fguillot.github.io/picoFeed", - "time": "2014-11-25 23:40:52" + "time": "2014-12-16 23:53:59" }, { "name": "pear/net_url2", diff --git a/fetcher/feedfetcher.php b/fetcher/feedfetcher.php index faf473475..28d1f951c 100644 --- a/fetcher/feedfetcher.php +++ b/fetcher/feedfetcher.php @@ -179,7 +179,7 @@ class FeedFetcher implements IFeedFetcher { $etag, $location) { $feed = new Feed(); - $link = $parsedFeed->getUrl(); + $link = $parsedFeed->getSiteUrl(); if (!$link) { $link = $location; diff --git a/tests/unit/fetcher/FeedFetcherTest.php b/tests/unit/fetcher/FeedFetcherTest.php index 5f68ff333..9c24524b0 100644 --- a/tests/unit/fetcher/FeedFetcherTest.php +++ b/tests/unit/fetcher/FeedFetcherTest.php @@ -77,7 +77,7 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase { ->disableOriginalConstructor() ->getMock(); $this->faviconFetcher = $this->getMockBuilder( - '\PicoFeed\Client\Favicon') + '\PicoFeed\Reader\Favicon') ->disableOriginalConstructor() ->getMock(); $this->faviconFactory = $this->getMockBuilder( @@ -228,7 +228,7 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase { private function createFeed($hasFavicon=false) { $this->expectFeed('getTitle', $this->feedTitle); - $this->expectFeed('getUrl', $this->feedLink); + $this->expectFeed('getSiteUrl', $this->feedLink); $feed = new Feed(); $feed->setTitle('&its a title'); diff --git a/utility/picofeedfaviconfactory.php b/utility/picofeedfaviconfactory.php index 4509b9e06..b3a48747a 100644 --- a/utility/picofeedfaviconfactory.php +++ b/utility/picofeedfaviconfactory.php @@ -15,7 +15,7 @@ namespace OCA\News\Utility; use \PicoFeed\Config\Config; -use \PicoFeed\Client\Favicon; +use \PicoFeed\Reader\Favicon; class PicoFeedFaviconFactory { diff --git a/vendor/autoload.php b/vendor/autoload.php index 357c2c52a..f8495def9 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInit80e526884d05a69ec5f87ea0eadf0d03::getLoader(); +return ComposerAutoloaderInitb70f37963a41b6db289ef240676024ef::getLoader(); diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index 443364959..70d78bc3f 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -56,7 +56,11 @@ class ClassLoader public function getPrefixes() { - return call_user_func_array('array_merge', $this->prefixesPsr0); + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); } public function getPrefixesPsr4() diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index bc6f011c7..113cd5ee5 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit80e526884d05a69ec5f87ea0eadf0d03 +class ComposerAutoloaderInitb70f37963a41b6db289ef240676024ef { private static $loader; @@ -19,9 +19,9 @@ class ComposerAutoloaderInit80e526884d05a69ec5f87ea0eadf0d03 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit80e526884d05a69ec5f87ea0eadf0d03', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitb70f37963a41b6db289ef240676024ef', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit80e526884d05a69ec5f87ea0eadf0d03', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitb70f37963a41b6db289ef240676024ef', 'loadClassLoader')); $includePaths = require __DIR__ . '/include_paths.php'; array_push($includePaths, get_include_path()); @@ -46,14 +46,14 @@ class ComposerAutoloaderInit80e526884d05a69ec5f87ea0eadf0d03 $includeFiles = require __DIR__ . '/autoload_files.php'; foreach ($includeFiles as $file) { - composerRequire80e526884d05a69ec5f87ea0eadf0d03($file); + composerRequireb70f37963a41b6db289ef240676024ef($file); } return $loader; } } -function composerRequire80e526884d05a69ec5f87ea0eadf0d03($file) +function composerRequireb70f37963a41b6db289ef240676024ef($file) { require $file; } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 7c9dac276..2a5124d70 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -119,20 +119,20 @@ "source": { "type": "git", "url": "https://github.com/fguillot/picoFeed.git", - "reference": "687cc58b51d739f06bc1729d69280e5a867840dd" + "reference": "6485f32d62698be73c3f0456bb87d960fcae1586" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fguillot/picoFeed/zipball/687cc58b51d739f06bc1729d69280e5a867840dd", - "reference": "687cc58b51d739f06bc1729d69280e5a867840dd", + "url": "https://api.github.com/repos/fguillot/picoFeed/zipball/6485f32d62698be73c3f0456bb87d960fcae1586", + "reference": "6485f32d62698be73c3f0456bb87d960fcae1586", "shasum": "" }, "require": { "php": ">=5.3.0" }, - "time": "2014-11-25 23:40:52", + "time": "2014-12-16 23:53:59", "type": "library", - "installation-source": "source", + "installation-source": "dist", "autoload": { "psr-0": { "PicoFeed": "lib/" diff --git a/vendor/fguillot/picofeed/README.markdown b/vendor/fguillot/picofeed/README.markdown index 868d532e9..a1e1e39c5 100644 --- a/vendor/fguillot/picofeed/README.markdown +++ b/vendor/fguillot/picofeed/README.markdown @@ -59,6 +59,7 @@ Documentation - [Favicon fetcher](docs/favicon.markdown) - [OPML file importation](docs/opml-import.markdown) - [OPML file exportation](docs/opml-export.markdown) +- [Image proxy](docs/image-proxy.markdown) (avoid SSL mixed content warnings) - [Web scraping](docs/grabber.markdown) - [Exceptions](docs/exceptions.markdown) - [Debugging](docs/debugging.markdown) diff --git a/vendor/fguillot/picofeed/docs/config.markdown b/vendor/fguillot/picofeed/docs/config.markdown index 5e0dfea53..75546abd1 100644 --- a/vendor/fguillot/picofeed/docs/config.markdown +++ b/vendor/fguillot/picofeed/docs/config.markdown @@ -261,3 +261,26 @@ $config->setFilterSchemeWhitelist(['http://', 'ftp://']); ```php $config->setFilterWhitelistedTags(['a' => ['href'], 'img' => ['src', 'title']]); ``` + +### Define a image proxy url + +- Method name: `setFilterImageProxyUrl()` +- Default value: Empty +- Argument value: string + +```php +$config->setFilterImageProxyUrl('http://myproxy.example.org/?url=%s'); +``` + +### Define a image proxy callback + +- Method name: `setFilterImageProxyCallback()` +- Default value: null +- Argument value: Closure + +```php +$config->setFilterImageProxyCallback(function ($image_url) { + $key = hash_hmac('sha1', $image_url, 'secret'); + return 'https://mypublicproxy/'.$key.'/'.urlencode($image_url); +}); +```
\ No newline at end of file diff --git a/vendor/fguillot/picofeed/docs/favicon.markdown b/vendor/fguillot/picofeed/docs/favicon.markdown index 14e25955d..1ac3ee1fc 100644 --- a/vendor/fguillot/picofeed/docs/favicon.markdown +++ b/vendor/fguillot/picofeed/docs/favicon.markdown @@ -5,7 +5,7 @@ Find and download the favicon ----------------------------- ```php -use PicoFeed\Client\Favicon; +use PicoFeed\Reader\Favicon; $favicon = new Favicon; @@ -21,11 +21,42 @@ PicoFeed will try first to find the favicon from the meta tags and fallback to t When the HTML page is parsed, relative links and protocol relative links are converted to absolute url. +Get Favicon file type +--------------------- + +It's possible to fetch the image type, this information come from the Content-Type HTTP header: + +```php +$favicon = new Favicon; +$favicon->find('http://example.net/'); + +echo $favicon->getType(); + +// Will output the content type, by example "image/png" +``` + +Get the Favicon as Data URI +--------------------------- + +You can also get the whole image as Data URI. +It's useful if you want to store the icon in your database and avoid too many HTTP requests. + +```php +$favicon = new Favicon; +$favicon->find('http://example.net/'); + +echo $favicon->getDataUri(); + +// Output something like that: data:image/png;base64,iVBORw0KGgoAAAANSUh..... +``` + +See: http://en.wikipedia.org/wiki/Data_URI_scheme + Check if a favicon link exists ------------------------------ ```php -use PicoFeed\Client\Favicon; +use PicoFeed\Reader\Favicon; $favicon = new Favicon; @@ -40,7 +71,7 @@ Like other classes, the Favicon class support the Config object as constructor a ```php use PicoFeed\Config\Config; -use PicoFeed\Client\Favicon; +use PicoFeed\Reader\Favicon; $config = new Config; $config->setClientUserAgent('My RSS Reader'); diff --git a/vendor/fguillot/picofeed/docs/feed-parsing.markdown b/vendor/fguillot/picofeed/docs/feed-parsing.markdown index df881400e..82d3703e9 100644 --- a/vendor/fguillot/picofeed/docs/feed-parsing.markdown +++ b/vendor/fguillot/picofeed/docs/feed-parsing.markdown @@ -43,7 +43,8 @@ Output: ```bash Feed::id = tag:linuxfr.org,2005:/news Feed::title = LinuxFr.org : les dĂ©pĂȘches -Feed::url = http://linuxfr.org/news +Feed::feed_url = http://linuxfr.org/news.atom +Feed::site_url = http://linuxfr.org/news Feed::date = 1415138079 Feed::language = en-US Feed::description = @@ -58,6 +59,7 @@ Item::language = en-US Item::author = Syvolc Item::enclosure_url = Item::enclosure_type = +Item::isRTL() = false Item::content = 18307 bytes .... ``` @@ -181,7 +183,8 @@ Feed and item properties // Feed object $feed->getId(); // Unique feed id $feed->getTitle(); // Feed title -$feed->getUrl(); // Website url +$feed->getFeedUrl(); // Feed url +$feed->getSiteUrl(); // Website url $feed->getDate(); // Feed last updated date $feed->getLanguage(); // Feed language $feed->getDescription(); // Feed description @@ -198,16 +201,16 @@ $feed->items[0]->getAuthor(); // Item author $feed->items[0]->getEnclosureUrl(); // Enclosure url $feed->items[0]->getEnclosureType(); // Enclosure mime-type (audio/mp3, image/png...) $feed->items[0]->getContent(); // Item content (filtered or raw) +$feed->items[0]->isRTL(); // Return true if the item language is Right-To-Left ``` RTL language detection ---------------------- -There is an utility method to determine if a language code is Right-To-Left or not: +Use the method `Item::isRTL()` to test if an item is RTL or not: ```php -// Return true if RTL -Parser::isLanguageRTL($item->getLanguage()); +var_dump($item->isRTL()); // true or false ``` Known RTL languages are: diff --git a/vendor/fguillot/picofeed/docs/image-proxy.markdown b/vendor/fguillot/picofeed/docs/image-proxy.markdown new file mode 100644 index 000000000..74e10d0c6 --- /dev/null +++ b/vendor/fguillot/picofeed/docs/image-proxy.markdown @@ -0,0 +1,66 @@ +Image Proxy +=========== + +To prevent mixed content warnings on SSL pages served from your RSS reader you might want to use an assets proxy. + +Images url will be rewritten to be downloaded through the proxy. + +Example: + +```html +<img src="http://example.org/image.png"/> +``` + +Can be rewritten like that: + +```html +<img src="http://myproxy.example.org/?url=http%3A%2F%2Fexample.org%2Fimage.png"/> +``` + +Currently this feature is only compatible with images. + +There is several open source SSL image proxy available like [Camo](https://github.com/atmos/camo). +You can also write your own proxy. + +Usage +----- + +There two different ways to use this feature, define a proxy url or a callback. + +### Define a proxy url + +A proxy url must be defined with a placeholder `%s`. +The placeholder will be replaced by the image source urlencoded. + +```php +$config = new Config; +$config->setFilterImageProxyUrl('http://myproxy.example.org/?url=%s'); +``` + +Will rewrite the image source like that: + +```html +<img src="http://myproxy.example.org/?url=http%3A%2F%2Fexample.org%2Fimage.png"/> +``` + +### Define a callback + +Your callback will be called each time an image url need to be rewritten. +The first argument is the original image url and your function must returns the new image url. + +Here an example if your proxy need a shared secret key: + +```php +$config = new Config; + +$config->setFilterImageProxyCallback(function ($image_url) { + $key = hash_hmac('sha1', $image_url, 'secret'); + return 'https://mypublicproxy/'.$key.'/'.urlencode($image_url); +}); +``` + +Will generate an image url like that: + +```html +<img src="https://mypublicproxy/4924964043f3119b3cf2b07b1922d491bcc20092/http%3A%2F%2Ffoo%2Fimage.png"/> +``` diff --git a/vendor/fguillot/picofeed/example.php b/vendor/fguillot/picofeed/example.php deleted file mode 100644 index 6bf9b6e20..000000000 --- a/vendor/fguillot/picofeed/example.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -require 'vendor/autoload.php'; - -use PicoFeed\Reader\Reader; -use PicoFeed\PicoFeedException; - -try { - - // Fetch from your database the previous values of the Etag and LastModified headers - $etag = '...'; - $last_modified = '...'; - - $reader = new Reader; - - // Provide those values to the download method - $resource = $reader->download('http://linuxfr.org/news.atom', $last_modified, $etag); - - if ($resource->isModified()) { - - $parser = $reader->getParser( - $resource->getUrl(), - $resource->getContent(), - $resource->getEncoding() - ); - - $feed = $parser->execute(); - - // Save your feed in your database - // ... - - // Store the Etag and the LastModified headers in your database - $etag = $resource->getEtag(); - $last_modified = $resource->getLastModified(); - - // ... - } - else { - - echo 'Not modified, nothing to do!'; - } -} -catch (PicoFeedException $e) { - // Do something... -} diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php index e962ba4e8..c8c812c1a 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php @@ -22,6 +22,14 @@ abstract class Client private $is_modified = true; /** + * HTTP Content-Type + * + * @access private + * @var string + */ + private $content_type = ''; + + /** * HTTP encoding * * @access private @@ -231,7 +239,8 @@ abstract class Client { if ($response['status'] == 200) { $this->content = $response['body']; - $this->encoding = $this->findCharset($response); + $this->content_type = $this->findContentType($response); + $this->encoding = $this->findCharset(); } } @@ -249,14 +258,26 @@ abstract class Client } /** - * Find charset from response headers + * Find content type from response headers * * @access public * @param array $response Client response + * @return string */ - public function findCharset(array $response) + public function findContentType(array $response) { - $result = explode('charset=', strtolower($this->getHeader($response, 'Content-Type'))); + return strtolower($this->getHeader($response, 'Content-Type')); + } + + /** + * Find charset from response headers + * + * @access public + * @return string + */ + public function findCharset() + { + $result = explode('charset=', $this->content_type); return isset($result[1]) ? $result[1] : ''; } @@ -390,6 +411,17 @@ abstract class Client } /** + * Get the content type value from HTTP headers + * + * @access public + * @return string + */ + public function getContentType() + { + return $this->content_type; + } + + /** * Get the encoding value from HTTP headers * * @access public diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Url.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Url.php index 90d7fb6f7..a74c23508 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Url.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Url.php @@ -80,6 +80,20 @@ class Url } /** + * Shortcut method to get a base url + * + * @static + * @access public + * @param string $url + * @return string + */ + public static function base($url) + { + $link = new Url($url); + return $link->getBaseUrl(); + } + + /** * Get the base URL * * @access public diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Config/Config.php b/vendor/fguillot/picofeed/lib/PicoFeed/Config/Config.php index 298b9a2d7..9a5381f0f 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Config/Config.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Config/Config.php @@ -30,6 +30,8 @@ namespace PicoFeed\Config; * @method \PicoFeed\Config\Config setFilterSchemeWhitelist(array $value) * @method \PicoFeed\Config\Config setFilterWhitelistedTags(array $value) * @method \PicoFeed\Config\Config setFilterBlacklistedTags(array $value) + * @method \PicoFeed\Config\Config setFilterImageProxyUrl($value) + * @method \PicoFeed\Config\Config setFilterImageProxyCallback($closure) * * @method integer getClientTimeout() * @method string getClientUserAgent() @@ -53,6 +55,8 @@ namespace PicoFeed\Config; * @method array getFilterSchemeWhitelist(array $default_value) * @method array getFilterWhitelistedTags(array $default_value) * @method array getFilterBlacklistedTags(array $default_value) + * @method string getFilterImageProxyUrl($default_value) + * @method string getFilterImageProxyCallback($default_value) */ class Config { diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php index 23b1103ad..66b3470f8 100644 --- a/vendor/fguil |