diff options
Diffstat (limited to 'vendor/fguillot')
32 files changed, 379 insertions, 154 deletions
diff --git a/vendor/fguillot/picofeed/README.markdown b/vendor/fguillot/picofeed/README.markdown index 8f01b4e8e..868d532e9 100644 --- a/vendor/fguillot/picofeed/README.markdown +++ b/vendor/fguillot/picofeed/README.markdown @@ -42,6 +42,13 @@ Authors - [Bernhard Posselt](https://github.com/Raydiation) - [David Pennington](https://github.com/Xeoncross) +Real world usage +---------------- + +- [AnythingNew](http://anythingnew.co) +- [Miniflux](http://miniflux.net) +- [Owncloud News](https://github.com/owncloud/news) + Documentation ------------- @@ -53,5 +60,6 @@ Documentation - [OPML file importation](docs/opml-import.markdown) - [OPML file exportation](docs/opml-export.markdown) - [Web scraping](docs/grabber.markdown) +- [Exceptions](docs/exceptions.markdown) - [Debugging](docs/debugging.markdown) - [Configuration](docs/config.markdown) diff --git a/vendor/fguillot/picofeed/docs/config.markdown b/vendor/fguillot/picofeed/docs/config.markdown index bf6fdee1f..5e0dfea53 100644 --- a/vendor/fguillot/picofeed/docs/config.markdown +++ b/vendor/fguillot/picofeed/docs/config.markdown @@ -8,8 +8,8 @@ To change the default parameters, you have to use the Config class. Create a new instance and pass it to the Reader object like that: ```php -use PicoFeed\Reader; -use PicoFeed\Config; +use PicoFeed\Reader\Reader; +use PicoFeed\Config\Config; $config = new Config; $config->setClientUserAgent('My custom RSS Reader') @@ -80,7 +80,7 @@ $config->setProxyHostname('proxy.example.org'); - Argument value: port number (integer) ```php -$config->getProxyPort(8118); +$config->setProxyPort(8118); ``` ### Proxy username @@ -132,7 +132,7 @@ Parser ### Hash algorithm used for item id generation - Method name: `setParserHashAlgo()` -- Default value: `crc32b` +- Default value: `sha256` - Argument value: any value returned by the function `hash_algos()` (string) - See: http://php.net/hash_algos @@ -147,7 +147,7 @@ $config->setParserHashAlgo('sha1'); - Argument value: boolean ```php -$config->setContentFiltering(); +$config->setContentFiltering(false); ``` ### Timezone diff --git a/vendor/fguillot/picofeed/docs/debugging.markdown b/vendor/fguillot/picofeed/docs/debugging.markdown index bbe1fd067..a9f8ab163 100644 --- a/vendor/fguillot/picofeed/docs/debugging.markdown +++ b/vendor/fguillot/picofeed/docs/debugging.markdown @@ -1,13 +1,18 @@ Debugging ========= -Get log messages ----------------- +Logging +------- PicoFeed log in memory the execution flow, if a feed doesn't work correctly it's easy to see what is wrong. +### Reading messages + ```php -print_r(PicoFeed\Logging::getMessages()); +use PicoFeed\Logging\Logger; + +// All messages are stored inside an Array +print_r(Logger::getMessages()); ``` You will got an output like that: @@ -36,11 +41,46 @@ Array ) ``` -Remove messages ---------------- +### Remove messages -All messages are stored in memory, if you need to clear them just call the method `Logging::deleteMessages()`: +All messages are stored in memory, if you need to clear them just call the method `Logger::deleteMessages()`: ```php -PicoFeed\Logging::deleteMessages(); +Logger::deleteMessages(); +``` + +Command line utility +==================== + +PicoFeed provides a basic command line tool to debug feeds quickly. +The tool is located in the root directory project. + +### Usage + +```bash +$ ./picofeed +Usage: +./picofeed feed <feed-url> # Parse a feed a dump the ouput on stdout +./picofeed debug <feed-url> # Display all logging messages for a feed +./picofeed item <feed-url> <item-id> # Fetch only one item +./picofeed nofilter <feed-url> <item-id> # Fetch an item but with no content filtering +``` + +### Example + +```bash +$ ./picofeed debug https://linuxfr.org/ +Exception thrown ===> "Invalid SSL certificate" +Array +( + [0] => [2014-11-08 14:04:14] PicoFeed\Client\Curl Fetch URL: https://linuxfr.org/ + [1] => [2014-11-08 14:04:14] PicoFeed\Client\Curl Etag provided: + [2] => [2014-11-08 14:04:14] PicoFeed\Client\Curl Last-Modified provided: + [3] => [2014-11-08 14:04:16] PicoFeed\Client\Curl cURL total time: 1.850634 + [4] => [2014-11-08 14:04:16] PicoFeed\Client\Curl cURL dns lookup time: 0.00093 + [5] => [2014-11-08 14:04:16] PicoFeed\Client\Curl cURL connect time: 0.115213 + [6] => [2014-11-08 14:04:16] PicoFeed\Client\Curl cURL speed download: 0 + [7] => [2014-11-08 14:04:16] PicoFeed\Client\Curl cURL effective url: https://linuxfr.org/ + [8] => [2014-11-08 14:04:16] PicoFeed\Client\Curl cURL error: SSL certificate problem: Invalid certificate chain +) ``` diff --git a/vendor/fguillot/picofeed/docs/exceptions.markdown b/vendor/fguillot/picofeed/docs/exceptions.markdown new file mode 100644 index 000000000..399ba3ef6 --- /dev/null +++ b/vendor/fguillot/picofeed/docs/exceptions.markdown @@ -0,0 +1,28 @@ +Exceptions +========== + +All exceptions inherits from the standard `Exception` class. + +### Library Exceptions + +- `PicoFeed\PicoFeedException`: Base class exception for the library + +### Client Exceptions + +- `PicoFeed\Client\ClientException`: Base exception class for the Client class +- `PicoFeed\Client\InvalidCertificateException`: Invalid SSL certificate +- `PicoFeed\Client\InvalidUrlException`: Malformed URL, page not found (404), unable to establish a connection +- `PicoFeed\Client\MaxRedirectException`: Maximum of HTTP redirections reached +- `PicoFeed\Client\MaxSizeException`: The response size exceeds to maximum allowed +- `PicoFeed\Client\TimeoutException`: Connection timeout + +### Parser Exceptions + +- `PicoFeed\Parser\ParserException`: Base exception class for the Parser class +- `PicoFeed\Parser\MalformedXmlException`: XML Parser error + +### Reader Exceptions + +- `PicoFeed\Reader\ReaderException`: Base exception class for the Reader +- `PicoFeed\Reader\SubscriptionNotFoundException`: Unable to find a feed for the given website +- `PicoFeed\Reader\UnsupportedFeedFormatException`: Unable to detect the feed format diff --git a/vendor/fguillot/picofeed/docs/favicon.markdown b/vendor/fguillot/picofeed/docs/favicon.markdown index 92ae11928..14e25955d 100644 --- a/vendor/fguillot/picofeed/docs/favicon.markdown +++ b/vendor/fguillot/picofeed/docs/favicon.markdown @@ -5,15 +5,13 @@ Find and download the favicon ----------------------------- ```php - -use PicoFeed\Favicon; +use PicoFeed\Client\Favicon; $favicon = new Favicon; // The icon link is https://bits.wikimedia.org/favicon/wikipedia.ico $icon_link = $favicon->find('https://en.wikipedia.org/'); $icon_content = $favicon->getContent(); - ``` PicoFeed will try first to find the favicon from the meta tags and fallback to the `favicon.ico` located in the website's root if nothing is found. @@ -27,14 +25,12 @@ Check if a favicon link exists ------------------------------ ```php - -use PicoFeed\Favicon; +use PicoFeed\Client\Favicon; $favicon = new Favicon; // Return true if the file exists var_dump($favicon->exists('http://php.net/favicon.ico')); - ``` Use personalized HTTP settings @@ -43,14 +39,12 @@ Use personalized HTTP settings Like other classes, the Favicon class support the Config object as constructor argument: ```php - -use PicoFeed\Config; -use PicoFeed\Favicon; +use PicoFeed\Config\Config; +use PicoFeed\Client\Favicon; $config = new Config; $config->setClientUserAgent('My RSS Reader'); $favicon = new Favicon($config); $favicon->find('https://github.com'); - ```
\ No newline at end of file diff --git a/vendor/fguillot/picofeed/docs/feed-creation.markdown b/vendor/fguillot/picofeed/docs/feed-creation.markdown index 24329f82c..35a24a9d7 100644 --- a/vendor/fguillot/picofeed/docs/feed-creation.markdown +++ b/vendor/fguillot/picofeed/docs/feed-creation.markdown @@ -1,11 +1,13 @@ Feed creation ============= +PicoFeed can also generate Atom and RSS feeds. + Generate RSS 2.0 feed ---------------------- ```php -use PicoFeed\Writers\Rss20; +use PicoFeed\Syndication\Rss20; $writer = new Rss20(); $writer->title = 'My site'; @@ -48,7 +50,7 @@ Generate Atom feed ------------------ ```php -use PicoFeed\Writers\Atom; +use PicoFeed\Syndication\Atom; $writer = new Atom(); $writer->title = 'My site'; diff --git a/vendor/fguillot/picofeed/docs/feed-parsing.markdown b/vendor/fguillot/picofeed/docs/feed-parsing.markdown index 22f84339b..df881400e 100644 --- a/vendor/fguillot/picofeed/docs/feed-parsing.markdown +++ b/vendor/fguillot/picofeed/docs/feed-parsing.markdown @@ -13,7 +13,7 @@ try { $reader = new Reader; // Return a resource - $resource = $reader->download('https://linuxfr.org/news.atom'); + $resource = $reader->download('http://linuxfr.org/news.atom'); // Return the right parser instance according to the feed format $parser = $reader->getParser( @@ -59,16 +59,6 @@ Item::author = Syvolc Item::enclosure_url = Item::enclosure_type = Item::content = 18307 bytes ----- -Item::id = d0ebddc90bfc3f109f9be00a3bb0b4a770af7a647cdc88454fe15d79168e0dea -Item::title = Fuzix OS, parce que les petites choses sont belles -Item::url = http://linuxfr.org/news/fuzix-os-parce-que-les-petites-choses-sont-belles -Item::date = 1415112167 -Item::language = en-US -Item::author = Thomas DEBESSE -Item::enclosure_url = -Item::enclosure_type = -Item::content = 6104 bytes .... ``` @@ -134,7 +124,54 @@ catch (PicoFeedException $e) { HTTP caching ------------ -TODO +PicoFeed supports HTTP caching to avoid unnecessary processing. + +1. After the first download, save in your database the values of the Etag and LastModified HTTP headers +2. For the next requests, provide those values to the `download()` method and check if the feed was modified or not + +Here an example: + +```php +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); + + // Return true if the remote content has changed + 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 for the next requests + $etag = $resource->getEtag(); + $last_modified = $resource->getLastModified(); + + // ... + } + else { + + echo 'Not modified, nothing to do!'; + } +} +catch (PicoFeedException $e) { + // Do something... +} +``` Feed and item properties @@ -162,3 +199,24 @@ $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) ``` + +RTL language detection +---------------------- + +There is an utility method to determine if a language code is Right-To-Left or not: + +```php +// Return true if RTL +Parser::isLanguageRTL($item->getLanguage()); +``` + +Known RTL languages are: + +- Arabic (ar-**) +- Farsi (fa-**) +- Urdu (ur-**) +- Pashtu (ps-**) +- Syriac (syr-**) +- Divehi (dv-**) +- Hebrew (he-**) +- Yiddish (yi-**) diff --git a/vendor/fguillot/picofeed/docs/grabber.markdown b/vendor/fguillot/picofeed/docs/grabber.markdown index 6a7dd2ada..2098b25d0 100644 --- a/vendor/fguillot/picofeed/docs/grabber.markdown +++ b/vendor/fguillot/picofeed/docs/grabber.markdown @@ -6,33 +6,48 @@ The web scraper is useful for feeds that display only a summary of articles, the How the content grabber works? ------------------------------ -1. Try with rules first (xpath patterns) for the domain name (see `PicoFeed\Rules\`) +1. Try with rules first (XPath queries) for the domain name (see `PicoFeed\Rules\`) 2. Try to find the text content by using common attributes for class and id 3. Finally, if nothing is found, the feed content is displayed -**The best results are obtained with Xpath rules file.** +**The best results are obtained with XPath rules file.** How to use the content scraper? ------------------------------- +Before parsing all items, just call the method `$parser->enableContentGrabber()`: + ```php -use PicoFeed\Reader; +use PicoFeed\Reader\Reader; +use PicoFeed\PicoFeedException; + +try { -$reader = new Reader; -$reader->download('http://www.egscomics.com/rss.php'); + $reader = new Reader; -$parser = $reader->getParser(); + // Return a resource + $resource = $reader->download('http://www.egscomics.com/rss.php'); -if ($parser !== false) { + // Return the right parser instance according to the feed format + $parser = $reader->getParser( + $resource->getUrl(), + $resource->getContent(), + $resource->getEncoding() + ); - $parser->enableContentGrabber(); // <= Enable the content grabber + // Enable content grabber before parsing items + $parser->enableContentGrabber(); + + // Return a Feed object $feed = $parser->execute(); - // ... +} +catch (PicoFeedException $e) { + // Do Something... } ``` When the content scraper is enabled, everything will be slower. -For each item a new HTTP request is made and the HTML downloaded is parsed with XML/Xpath. +**For each item a new HTTP request is made** and the HTML downloaded is parsed with XML/XPath. Configuration ------------- diff --git a/vendor/fguillot/picofeed/docs/installation.markdown b/vendor/fguillot/picofeed/docs/installation.markdown index 827908f75..894754ca4 100644 --- a/vendor/fguillot/picofeed/docs/installation.markdown +++ b/vendor/fguillot/picofeed/docs/installation.markdown @@ -4,12 +4,14 @@ Installation Versions -------- -- Development version: branch master +- Development version: master - Available versions: - v0.1.0 (stable) - v0.0.2 - v0.0.1 +Note: The public API has changed between 0.0.x and 0.1.0 + Installation with Composer -------------------------- @@ -35,7 +37,7 @@ And download the code: composer install # or update ``` -Usage example with the Composer autoloading: +Usage example with the Composer autoloader: ```php <?php @@ -47,7 +49,7 @@ use PicoFeed\Reader\Reader; try { $reader = new Reader; - $resource = $reader->download('https://linuxfr.org/news.atom'); + $resource = $reader->download('http://linuxfr.org/news.atom'); $parser = $reader->getParser( $resource->getUrl(), diff --git a/vendor/fguillot/picofeed/docs/opml-export.markdown b/vendor/fguillot/picofeed/docs/opml-export.markdown index 4d7cf8db0..bd4f0b04b 100644 --- a/vendor/fguillot/picofeed/docs/opml-export.markdown +++ b/vendor/fguillot/picofeed/docs/opml-export.markdown @@ -5,7 +5,7 @@ Example with no categories -------------------------- ```php -use PicoFeed\Export; +use PicoFeed\Serialization\Export; $feeds = array( array( @@ -26,7 +26,7 @@ Example with categories ----------------------- ```php -use PicoFeed\Export; +use PicoFeed\Serialization\Export; $feeds = array( 'my category' => array( diff --git a/vendor/fguillot/picofeed/docs/opml-import.markdown b/vendor/fguillot/picofeed/docs/opml-import.markdown index 9f47b376a..8ce2026c3 100644 --- a/vendor/fguillot/picofeed/docs/opml-import.markdown +++ b/vendor/fguillot/picofeed/docs/opml-import.markdown @@ -4,7 +4,7 @@ Import OPML file Importing a list of subscriptions is pretty straightforward: ```php -use PicoFeed\Import; +use PicoFeed\Serialization\Import; $opml = file_get_contents('mySubscriptions.opml'); $import = new Import($opml); diff --git a/vendor/fguillot/picofeed/example.php b/vendor/fguillot/picofeed/example.php new file mode 100644 index 000000000..6bf9b6e20 --- /dev/null +++ b/vendor/fguillot/picofeed/example.php @@ -0,0 +1,45 @@ +<?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 7328b2c75..e962ba4e8 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php @@ -3,7 +3,7 @@ namespace PicoFeed\Client; use LogicException; -use PicoFeed\Logging\Logging; +use PicoFeed\Logging\Logger; /** * Client class @@ -166,9 +166,9 @@ abstract class Client $this->url = $url; } - Logging::setMessage(get_called_class().' Fetch URL: '.$this->url); - Logging::setMessage(get_called_class().' Etag provided: '.$this->etag); - Logging::setMessage(get_called_class().' Last-Modified provided: '.$this->last_modified); + Logger::setMessage(get_called_class().' Fetch URL: '.$this->url); + Logger::setMessage(get_called_class().' Etag provided: '.$this->etag); + Logger::setMessage(get_called_class().' Last-Modified provided: '.$this->last_modified); $response = $this->doRequest(); @@ -204,7 +204,7 @@ abstract class Client } if ($this->is_modified === false) { - Logging::setMessage(get_called_class().' Resource not modified'); + Logger::setMessage(get_called_class().' Resource not modified'); } } @@ -297,10 +297,10 @@ abstract class Client } } - Logging::setMessage(get_called_class().' HTTP status code: '.$status); + Logger::setMessage(get_called_class().' HTTP status code: '.$status); foreach ($headers as $name => $value) { - Logging::setMessage(get_called_class().' HTTP header: '.$name.' => '.$value); + Logger::setMessage(get_called_class().' HTTP header: '.$name.' => '.$value); } return array($status, $headers); diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php index 9cf3eb6f4..4e4658639 100 |