diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..15154f0d
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,8 @@
+.git
+cache/*
+DEBUG
+Dockerfile
+whitelist.txt
+phpcs.xml
+CHANGELOG.md
+CONTRIBUTING.md
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index cd5e2d9a..5c746a4d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,12 +3,26 @@ sudo: false
language: php
install:
- - pear channel-update pear.php.net
- - pear install PHP_CodeSniffer
+ - if [[ $TRAVIS_PHP_VERSION == "hhvm" ]]; then
+ composer global require squizlabs/PHP_CodeSniffer;
+ else
+ pear channel-update pear.php.net;
+ pear install PHP_CodeSniffer;
+ fi
+ - if [[ $TRAVIS_PHP_VERSION == "7.0" ]]; then
+ composer global require phpunit/phpunit ^6;
+ fi
script:
- phpenv rehash
- - phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p
+ - if [[ $TRAVIS_PHP_VERSION == "hhvm" ]]; then
+ /home/travis/.composer/vendor/bin/phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p;
+ else
+ phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p;
+ fi
+ - if [[ $TRAVIS_PHP_VERSION == "7.0" ]]; then
+ phpunit --configuration=phpunit.xml --include-path=lib/;
+ fi
matrix:
fast_finish: true
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..35caac84
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,5 @@
+FROM ulsmith/alpine-apache-php7
+
+COPY ./ /app/public/
+
+RUN chown -R apache:root /app/public
\ No newline at end of file
diff --git a/README.md b/README.md
index 45bbc6d9..1fcf6023 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
rss-bridge
===
-[![LICENSE](https://img.shields.io/badge/license-UNLICENSE-blue.svg)](UNLICENSE) [![Build Status](https://travis-ci.org/RSS-Bridge/rss-bridge.svg?branch=master)](https://travis-ci.org/RSS-Bridge/rss-bridge)
+[![LICENSE](https://img.shields.io/badge/license-UNLICENSE-blue.svg)](UNLICENSE) [![GitHub release](https://img.shields.io/github/release/rss-bridge/rss-bridge.svg)](https://github.com/rss-bridge/rss-bridge/releases/latest) [![Debian Release](https://img.shields.io/badge/dynamic/json.svg?label=debian%20release&url=https%3A%2F%2Fsources.debian.org%2Fapi%2Fsrc%2Frss-bridge%2F&query=%24.versions%5B0%5D.version&colorB=blue)](https://tracker.debian.org/pkg/rss-bridge) [![Guix Release](https://img.shields.io/badge/guix%20release-unknown-light--gray.svg)](https://www.gnu.org/software/guix/packages/R/) [![Build Status](https://travis-ci.org/RSS-Bridge/rss-bridge.svg?branch=master)](https://travis-ci.org/RSS-Bridge/rss-bridge) [![Docker Build Status](https://img.shields.io/docker/build/rssbridge/rss-bridge.svg)](https://hub.docker.com/r/rssbridge/rss-bridge/)
-rss-bridge is a PHP project capable of generating ATOM feeds for websites which don't have one.
+RSS-Bridge is a PHP project capable of generating RSS and Atom feeds for websites which don't have one. It can be used on webservers or as stand alone application in CLI mode.
-Supported sites/pages (main)
+Supported sites/pages (examples)
===
* `Bandcamp` : Returns last release from [bandcamp](https://bandcamp.com/) for a tag
@@ -25,106 +25,188 @@ Supported sites/pages (main)
* `Wikipedia`: highlighted articles from [Wikipedia](https://wikipedia.org/) in English, German, French or Esperanto
* `YouTube` : YouTube user channel, playlist or search
-Plus [many other bridges](bridges/) to enable, thanks to the community
+And [many more](bridges/), thanks to the community!
Output format
===
-Output format can take several forms:
-* `Atom` : ATOM Feed, for use in RSS/Feed readers
-* `Html` : Simple html page.
-* `Json` : Json, for consumption by other applications.
-* `Mrss` : MRSS Feed, for use in RSS/Feed readers
-* `Plaintext` : raw text (php object, as returned by print_r)
-
+RSS-Bridge is capable of producing several output formats:
+
+* `Atom` : Atom feed, for use in feed readers
+* `Html` : Simple HTML page
+* `Json` : JSON, for consumption by other applications
+* `Mrss` : MRSS feed, for use in feed readers
+* `Plaintext` : Raw text, for consumption by other applications
+
+You can extend RSS-Bridge with your own format, using the [Format API](https://github.com/RSS-Bridge/rss-bridge/wiki/Format-API)!
+
Screenshot
===
Welcome screen:
![Screenshot](https://github.com/RSS-Bridge/rss-bridge/wiki/images/screenshot_rss-bridge_welcome.png)
-
-RSS-Bridge hashtag (#rss-bridge) search on Twitter, in ATOM format (as displayed by Firefox):
+
+***
+
+RSS-Bridge hashtag (#rss-bridge) search on Twitter, in Atom format (as displayed by Firefox):
![Screenshot](https://github.com/RSS-Bridge/rss-bridge/wiki/images/screenshot_twitterbridge_atom.png)
-
+
Requirements
===
- * PHP 5.6, e.g. `AddHandler application/x-httpd-php56 .php` in `.htaccess`
- * `openssl` extension enabled in PHP config (`php.ini`)
- * `allow_url_fopen=1` in `php.ini`
+RSS-Bridge requires PHP 5.6 or higher with following extensions enabled:
-Enabling/Disabling bridges
+ - [`openssl`](https://secure.php.net/manual/en/book.openssl.php)
+ - [`libxml`](https://secure.php.net/manual/en/book.libxml.php)
+ - [`mbstring`](https://secure.php.net/manual/en/book.mbstring.php)
+ - [`simplexml`](https://secure.php.net/manual/en/book.simplexml.php)
+ - [`curl`](https://secure.php.net/manual/en/book.curl.php)
+ - [`json`](https://secure.php.net/manual/en/book.json.php)
+
+Find more information on our [Wiki](https://github.com/rss-bridge/rss-bridge/wiki)
+
+Enable / Disable bridges
===
-By default, the script creates `whitelist.txt` and adds the main bridges (see above). `whitelist.txt` is ignored by git, you can edit it:
- * to enable extra bridges (one bridge per line)
- * to disable main bridges (remove the line)
- * to enable all bridges (just one wildcard `*` as file content)
+RSS-Bridge allows you to take full control over which bridges are displayed to the user. That way you can host your own RSS-Bridge service with your favorite collection of bridges!
-New bridges are disabled by default, so make sure to check regularly what's new and whitelist what you want!
+Find more information on the [Wiki](https://github.com/RSS-Bridge/rss-bridge/wiki/Whitelisting)
+
+**Notice**: By default RSS-Bridge will only show a small subset of bridges. Make sure to read up on [whitelisting](https://github.com/RSS-Bridge/rss-bridge/wiki/Whitelisting) to unlock the full potential of RSS-Bridge!
Deploy
===
+
+Thanks to the community, hosting your own instance of RSS-Bridge is as easy as clicking a button!
+
[![Deploy on Scalingo](https://cdn.scalingo.com/deploy/button.svg)](https://my.scalingo.com/deploy?source=https://github.com/sebsauvage/rss-bridge)
-
+[![Deploy to Docker Cloud](https://files.cloud.docker.com/images/deploy-to-dockercloud.svg)](https://cloud.docker.com/stack/deploy/?repo=https://github.com/rss-bridge/rss-bridge)
+
+Getting involved
+===
+
+There are many ways for you to getting involved with RSS-Bridge. Here are a few things:
+
+- Share RSS-Bridge with your friends (Twitter, Facebook, ..._you name it_...)
+- Report broken bridges or bugs by opening [Issues](https://github.com/RSS-Bridge/rss-bridge/issues) on GitHub
+- Request new features or suggest ideas (via [Issues](https://github.com/RSS-Bridge/rss-bridge/issues))
+- Discuss bugs, features, ideas or [issues](https://github.com/RSS-Bridge/rss-bridge/issues)
+- Add new bridges or improve the API
+- Improve the [Wiki](https://github.com/RSS-Bridge/rss-bridge/wiki)
+- Host an instance of RSS-Bridge for your personal use or make it available to the community :sparkling_heart:
+
Authors
===
-We are RSS Bridge Community, a group of developers continuing the project initiated by sebsauvage, webmaster of [sebsauvage.net](http://sebsauvage.net), author of [Shaarli](http://sebsauvage.net/wiki/doku.php?id=php:shaarli) and [ZeroBin](http://sebsauvage.net/wiki/doku.php?id=php:zerobin).
-Patch/contributors :
+We are RSS-Bridge community, a group of developers continuing the project initiated by sebsauvage, webmaster of [sebsauvage.net](http://sebsauvage.net), author of [Shaarli](http://sebsauvage.net/wiki/doku.php?id=php:shaarli) and [ZeroBin](http://sebsauvage.net/wiki/doku.php?id=php:zerobin).
- * Yves ASTIER ([Draeli](https://github.com/Draeli)) : PHP optimizations, fixes, dynamic brigde/format list with all stuff behind and extend cache system. Mail : contact /at\ yves-astier.com
- * [Mitsukarenai](https://github.com/Mitsukarenai) : Initial inspiration, collaborator
- * [ArthurHoaro](https://github.com/ArthurHoaro)
- * [BoboTiG](https://github.com/BoboTiG)
- * [Astalaseven](https://github.com/Astalaseven)
- * [qwertygc](https://github.com/qwertygc)
- * [Djuuu](https://github.com/Djuuu)
- * [Anadrark](https://github.com/Anadrark])
- * [Grummfy](https://github.com/Grummfy)
- * [Polopollo](https://github.com/Polopollo)
- * [16mhz](https://github.com/16mhz)
- * [kranack](https://github.com/kranack)
- * [logmanoriginal](https://github.com/logmanoriginal)
- * [polo2ro](https://github.com/polo2ro)
- * [Riduidel](https://github.com/Riduidel)
- * [superbaillot.net](http://superbaillot.net/)
- * [vinzv](https://github.com/vinzv)
- * [teromene](https://github.com/teromene)
- * [nel50n](https://github.com/nel50n)
- * [nyutag](https://github.com/nyutag)
- * [ORelio](https://github.com/ORelio)
- * [Pitchoule](https://github.com/Pitchoule)
- * [pit-fgfjiudghdf](https://github.com/pit-fgfjiudghdf)
- * [aledeg](https://github.com/aledeg)
- * [alexAubin](https://github.com/alexAubin)
- * [cnlpete](https://github.com/cnlpete)
- * [corenting](https://github.com/corenting)
- * [Daiyousei](https://github.com/Daiyousei)
- * [erwang](https://github.com/erwang)
- * [gsurrel](https://github.com/gsurrel)
- * [kraoc](https://github.com/kraoc)
- * [lagaisse](https://github.com/lagaisse)
- * [az5he6ch](https://github.com/az5he6ch)
- * [niawag](https://github.com/niawag)
- * [JeremyRand](https://github.com/JeremyRand)
- * [mro](https://github.com/mro)
+**Contributors** (sorted alphabetically):
+
+
+ * [16mhz](https://api.github.com/users/16mhz)
+ * [Ahiles3005](https://api.github.com/users/Ahiles3005)
+ * [Albirew](https://api.github.com/users/Albirew)
+ * [AmauryCarrade](https://api.github.com/users/AmauryCarrade)
+ * [ArthurHoaro](https://api.github.com/users/ArthurHoaro)
+ * [Astalaseven](https://api.github.com/users/Astalaseven)
+ * [Astyan-42](https://api.github.com/users/Astyan-42)
+ * [Daiyousei](https://api.github.com/users/Daiyousei)
+ * [Djuuu](https://api.github.com/users/Djuuu)
+ * [Draeli](https://api.github.com/users/Draeli)
+ * [EtienneM](https://api.github.com/users/EtienneM)
+ * [Frenzie](https://api.github.com/users/Frenzie)
+ * [Ginko-Aloe](https://api.github.com/users/Ginko-Aloe)
+ * [Glandos](https://api.github.com/users/Glandos)
+ * [GregThib](https://api.github.com/users/GregThib)
+ * [Grummfy](https://api.github.com/users/Grummfy)
+ * [JackNUMBER](https://api.github.com/users/JackNUMBER)
+ * [JeremyRand](https://api.github.com/users/JeremyRand)
+ * [Jocker666z](https://api.github.com/users/Jocker666z)
+ * [LogMANOriginal](https://api.github.com/users/LogMANOriginal)
+ * [MonsieurPoutounours](https://api.github.com/users/MonsieurPoutounours)
+ * [ORelio](https://api.github.com/users/ORelio)
+ * [PaulVayssiere](https://api.github.com/users/PaulVayssiere)
+ * [Piranhaplant](https://api.github.com/users/Piranhaplant)
+ * [Riduidel](https://api.github.com/users/Riduidel)
+ * [Strubbl](https://api.github.com/users/Strubbl)
+ * [TheRadialActive](https://api.github.com/users/TheRadialActive)
+ * [TwizzyDizzy](https://api.github.com/users/TwizzyDizzy)
+ * [WalterBarrett](https://api.github.com/users/WalterBarrett)
+ * [ZeNairolf](https://api.github.com/users/ZeNairolf)
+ * [adamchainz](https://api.github.com/users/adamchainz)
+ * [aledeg](https://api.github.com/users/aledeg)
+ * [alexAubin](https://api.github.com/users/alexAubin)
+ * [az5he6ch](https://api.github.com/users/az5he6ch)
+ * [b1nj](https://api.github.com/users/b1nj)
+ * [benasse](https://api.github.com/users/benasse)
+ * [captn3m0](https://api.github.com/users/captn3m0)
+ * [chemel](https://api.github.com/users/chemel)
+ * [ckiw](https://api.github.com/users/ckiw)
+ * [cnlpete](https://api.github.com/users/cnlpete)
+ * [corenting](https://api.github.com/users/corenting)
+ * [da2x](https://api.github.com/users/da2x)
+ * [eMerzh](https://api.github.com/users/eMerzh)
+ * [em92](https://api.github.com/users/em92)
+ * [griffaurel](https://api.github.com/users/griffaurel)
+ * [hunhejj](https://api.github.com/users/hunhejj)
+ * [j0k3r](https://api.github.com/users/j0k3r)
+ * [jdigilio](https://api.github.com/users/jdigilio)
+ * [kranack](https://api.github.com/users/kranack)
+ * [kraoc](https://api.github.com/users/kraoc)
+ * [laBecasse](https://api.github.com/users/laBecasse)
+ * [lagaisse](https://api.github.com/users/lagaisse)
+ * [lalannev](https://api.github.com/users/lalannev)
+ * [ldidry](https://api.github.com/users/ldidry)
+ * [m0zes](https://api.github.com/users/m0zes)
+ * [matthewseal](https://api.github.com/users/matthewseal)
+ * [mcbyte-it](https://api.github.com/users/mcbyte-it)
+ * [mdemoss](https://api.github.com/users/mdemoss)
+ * [melangue](https://api.github.com/users/melangue)
+ * [metaMMA](https://api.github.com/users/metaMMA)
+ * [mickael-bertrand](https://api.github.com/users/mickael-bertrand)
+ * [mitsukarenai](https://api.github.com/users/mitsukarenai)
+ * [mro](https://api.github.com/users/mro)
+ * [mxmehl](https://api.github.com/users/mxmehl)
+ * [nel50n](https://api.github.com/users/nel50n)
+ * [niawag](https://api.github.com/users/niawag)
+ * [pellaeon](https://api.github.com/users/pellaeon)
+ * [pit-fgfjiudghdf](https://api.github.com/users/pit-fgfjiudghdf)
+ * [pitchoule](https://api.github.com/users/pitchoule)
+ * [pmaziere](https://api.github.com/users/pmaziere)
+ * [prysme01](https://api.github.com/users/prysme01)
+ * [quentinus95](https://api.github.com/users/quentinus95)
+ * [qwertygc](https://api.github.com/users/qwertygc)
+ * [regisenguehard](https://api.github.com/users/regisenguehard)
+ * [rogerdc](https://api.github.com/users/rogerdc)
+ * [sebsauvage](https://api.github.com/users/sebsauvage)
+ * [sublimz](https://api.github.com/users/sublimz)
+ * [sysadminstory](https://api.github.com/users/sysadminstory)
+ * [tameroski](https://api.github.com/users/tameroski)
+ * [teromene](https://api.github.com/users/teromene)
+ * [triatic](https://api.github.com/users/triatic)
+ * [wtuuju](https://api.github.com/users/wtuuju)
Licenses
===
-Code is [Public Domain](UNLICENSE).
-Including `PHP Simple HTML DOM Parser` under the [MIT License](http://opensource.org/licenses/MIT)
+The source code for RSS-Bridge is [Public Domain](UNLICENSE).
+RSS-Bridge uses third party libraries with their own license:
+
+ * [`PHP Simple HTML DOM Parser`](http://simplehtmldom.sourceforge.net/) licensed under the [MIT License](http://opensource.org/licenses/MIT)
+ * [`php-urljoin`](https://github.com/fluffy-critter/php-urljoin) licensed under the [MIT License](http://opensource.org/licenses/MIT)
Technical notes
===
- * There is a cache so that source services won't ban you even if you hammer the rss-bridge with requests. Each bridge can have a different duration for the cache. The `cache` subdirectory will be automatically created and cached objects older than 24 hours get purged.
- * To implement a new Bridge, [follow the specifications](https://github.com/RSS-Bridge/rss-bridge/wiki/Bridge-API) and take a look at existing Bridges for examples.
- * To enable debug mode (disabling cache and enabling error reporting), create an empty file named `DEBUG` in the root directory (next to `index.php`).
- * For more information refer to the [Wiki](https://github.com/RSS-Bridge/rss-bridge/wiki)
+
+ * RSS-Bridge uses caching to prevent services from banning your server for repeatedly updating feeds. The specific cache duration can be different between bridges. Cached files are deleted automatically after 24 hours.
+ * You can implement your own bridge, [following these instructions](https://github.com/RSS-Bridge/rss-bridge/wiki/Bridge-API).
+ * You can enable debug mode to disable caching. Find more information on the [Wiki](https://github.com/RSS-Bridge/rss-bridge/wiki/Debug-mode)
Rant
===
@@ -133,10 +215,10 @@ Rant
Your catchword is "share", but you don't want us to share. You want to keep us within your walled gardens. That's why you've been removing RSS links from webpages, hiding them deep on your website, or removed feeds entirely, replacing it with crippled or demented proprietary API. **FUCK YOU.**
-You're not social when you hamper sharing by removing feeds. You're happy to have customers creating content for your ecosystem, but you don't want this content out - a content you do not even own. Google Takeout is just a gimmick. We want our data to flow, we want RSS or ATOM feeds.
+You're not social when you hamper sharing by removing feeds. You're happy to have customers creating content for your ecosystem, but you don't want this content out - a content you do not even own. Google Takeout is just a gimmick. We want our data to flow, we want RSS or Atom feeds.
-We want to share with friends, using open protocols: RSS, ATOM, XMPP, whatever. Because no one wants to have *your* service with *your* applications using *your* API force-feeding them. Friends must be free to choose whatever software and service they want.
+We want to share with friends, using open protocols: RSS, Atom, XMPP, whatever. Because no one wants to have *your* service with *your* applications using *your* API force-feeding them. Friends must be free to choose whatever software and service they want.
We are rebuilding bridges you have wilfully destroyed.
-Get your shit together: Put RSS/ATOM back in.
+Get your shit together: Put RSS/Atom back in.
diff --git a/bridges/AmazonPriceTrackerBridge.php b/bridges/AmazonPriceTrackerBridge.php
new file mode 100644
index 00000000..e31a03bb
--- /dev/null
+++ b/bridges/AmazonPriceTrackerBridge.php
@@ -0,0 +1,187 @@
+ array(
+ 'name' => 'ASIN',
+ 'required' => true,
+ 'exampleValue' => 'B071GB1VMQ',
+ // https://stackoverflow.com/a/12827734
+ 'pattern' => 'B[\dA-Z]{9}|\d{9}(X|\d)',
+ ),
+ 'tld' => array(
+ 'name' => 'Country',
+ 'type' => 'list',
+ 'required' => true,
+ 'values' => array(
+ 'Australia' => 'com.au',
+ 'Brazil' => 'com.br',
+ 'Canada' => 'ca',
+ 'China' => 'cn',
+ 'France' => 'fr',
+ 'Germany' => 'de',
+ 'India' => 'in',
+ 'Italy' => 'it',
+ 'Japan' => 'co.jp',
+ 'Mexico' => 'com.mx',
+ 'Netherlands' => 'nl',
+ 'Spain' => 'es',
+ 'United Kingdom' => 'co.uk',
+ 'United States' => 'com',
+ ),
+ 'defaultValue' => 'com',
+ ),
+ ));
+
+ protected $title;
+
+ /**
+ * Generates domain name given a amazon TLD
+ */
+ private function getDomainName() {
+ return 'https://www.amazon.' . $this->getInput('tld');
+ }
+
+ /**
+ * Generates URI for a Amazon product page
+ */
+ public function getURI() {
+ if (!is_null($this->getInput('asin'))) {
+ return $this->getDomainName() . '/dp/' . $this->getInput('asin') . '/';
+ }
+ return parent::getURI();
+ }
+
+ /**
+ * Scrapes the product title from the html page
+ * returns the default title if scraping fails
+ */
+ private function getTitle($html) {
+ $titleTag = $html->find('#productTitle', 0);
+
+ if (!$titleTag) {
+ return $this->getDefaultTitle();
+ } else {
+ return trim(html_entity_decode($titleTag->innertext, ENT_QUOTES));
+ }
+ }
+
+ /**
+ * Title used by the feed if none could be found
+ */
+ private function getDefaultTitle() {
+ return 'Amazon.' . $this->getInput('tld') . ': ' . $this->getInput('asin');
+ }
+
+ /**
+ * Returns name for the feed
+ * Uses title (already scraped) if it has one
+ */
+ public function getName() {
+ if (isset($this->title)) {
+ return $this->title;
+ } else {
+ return parent::getName();
+ }
+ }
+
+ private function parseDynamicImage($attribute) {
+ $json = json_decode(html_entity_decode($attribute), true);
+
+ if ($json and count($json) > 0) {
+ return array_keys($json)[0];
+ }
+ }
+
+ /**
+ * Returns a generated image tag for the product
+ */
+ private function getImage($html) {
+ $imageSrc = $html->find('#main-image-container img', 0);
+
+ if ($imageSrc) {
+ $hiresImage = $imageSrc->getAttribute('data-old-hires');
+ $dynamicImageAttribute = $imageSrc->getAttribute('data-a-dynamic-image');
+ $image = $hiresImage ?: $this->parseDynamicImage($dynamicImageAttribute);
+ }
+ $image = $image ?: 'https://placekitten.com/200/300';
+
+ return <<
'. $serie . '
'; + $item['content'] .= 'Par {author} le {date} dans {category}
+ preg_match( + '/.+le(.+)dans.*/', + $element->find('div[class="blague-footer"]', 0)->plaintext, + $matches + ); + + $item['timestamp'] = strtotime($matches[1]); + + $this->items[] = $item; - if(isset($temp[2])) { - $item['content'] = trim($element->find('div.joke_text_contener', 0)->innertext); - $uri = $temp[2]->href; - $item['uri'] = $uri; - $item['title'] = substr($uri, (strrpos($uri, "/") + 1)); - $date = $element->find('li.bdm_date', 0)->innertext; - $time = mktime(0, 0, 0, substr($date, 3, 2), substr($date, 0, 2), substr($date, 6, 4)); - $item['timestamp'] = $time; - $item['author'] = $element->find('li.bdm_pseudo', 0)->innertext; - $this->items[] = $item; - } } + } + } diff --git a/bridges/BundesbankBridge.php b/bridges/BundesbankBridge.php new file mode 100644 index 00000000..972290bd --- /dev/null +++ b/bridges/BundesbankBridge.php @@ -0,0 +1,83 @@ + array( + 'name' => 'Language', + 'type' => 'list', + 'required' => true, + 'defaultValue' => self::LANG_DE, + 'values' => array( + 'English' => self::LANG_EN, + 'Deutsch' => self::LANG_DE + ) + ) + ) + ); + + public function getURI() { + switch($this->getInput(self::PARAM_LANG)) { + case self::LANG_EN: return self::URI . 'en/publications/reports/studies'; + case self::LANG_DE: return self::URI . 'de/publikationen/berichte/studien'; + } + + return parent::getURI(); + } + + public function collectData() { + + $html = getSimpleHTMLDOM($this->getURI()) + or returnServerError('No response for ' . $this->getURI()); + + $html = defaultLinkTo($html, $this->getURI()); + + foreach($html->find('ul.resultlist li') as $study) { + $item = array(); + + $item['uri'] = $study->find('.teasable__link', 0)->href; + + // Get title without child elements (i.e. subtitle) + $title = $study->find('.teasable__title div.h2', 0); + + foreach($title->children as &$child) { + $child->outertext = ''; + } + + $item['title'] = $title->innertext; + + // Add subtitle to the content if it exists + $item['content'] = ''; + + if($subtitle = $study->find('.teasable__subtitle', 0)) { + $item['content'] .= '' . $study->find('.teasable__subtitle', 0)->plaintext . ''; + } + + $item['content'] .= '' . $study->find('.teasable__text', 0)->plaintext . '
'; + + $item['timestamp'] = strtotime($study->find('.teasable__date', 0)->plaintext); + + // Downloads and older studies don't have images + if($study->find('.teasable__image', 0)) { + $item['enclosures'] = array( + $study->find('.teasable__image img', 0)->src + ); + } + + $this->items[] = $item; + } + + } + +} diff --git a/bridges/CADBridge.php b/bridges/CADBridge.php deleted file mode 100644 index 09e3e65a..00000000 --- a/bridges/CADBridge.php +++ /dev/null @@ -1,45 +0,0 @@ -collectExpandableDatas('http://cdn2.cad-comic.com/rss.xml', 10); - } - - protected function parseItem($newsItem){ - $item = parent::parseItem($newsItem); - $item['content'] = $this->extractCADContent($item['uri']); - return $item; - } - - private function extractCADContent($url) { - $html3 = getSimpleHTMLDOMCached($url); - - // The request might fail due to missing https support or wrong URL - if($html3 == false) - return 'Daily comic not released yet'; - - $htmlpart = explode("/", $url); - - switch ($htmlpart[3]) { - case 'cad': - preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/cad-\S*png/", $html3, $url2); - break; - case 'sillies': - preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/sillies-\S*gif/", $html3, $url2); - break; - default: - return 'Daily comic not released yet'; - } - $img = implode($url2[0]); - $html3->clear(); - unset($html3); - if ($img == '') - return 'Daily comic not released yet'; - return ''; - } -} diff --git a/bridges/CNETBridge.php b/bridges/CNETBridge.php index eefb7051..bd41febc 100644 --- a/bridges/CNETBridge.php +++ b/bridges/CNETBridge.php @@ -3,91 +3,107 @@ class CNETBridge extends BridgeAbstract { const MAINTAINER = 'ORelio'; const NAME = 'CNET News'; - const URI = 'http://www.cnet.com/'; - const CACHE_TIMEOUT = 1800; // 30min - const DESCRIPTION = 'Returns the newest articles.');
+ $offset_figure = strpos($article_html, ' {$fullArticle} {$item['title']}'
+ . $deal->find('a[class*='. $selectorLink .']', 0)->innertext
+ . '
'
+ . $this->getPrice($deal)
+ . $this->getDiscount($deal)
+ . $this->getShipsFrom($deal)
+ . $this->getShippingCost($deal)
+ . $this->GetSource($deal)
+ . $deal->find('div[class*='. $selectorDescription .']', 0)->innertext
+ . ''
+ . $deal->find('div[class*='. $selectorHot .']', 0)
+ ->find('span', 1)->outertext
+ . ' ';
+ $dealDateDiv = $deal->find('div[class*='. $selectorDate .']', 0)
->find('span[class=hide--toW3]');
$itemDate = end($dealDateDiv)->plaintext;
- if(substr( $itemDate, 0, 6 ) === 'il y a') {
+ // In case of a Local deal, there is no date, but we can use
+ // this case for other reason (like date not in the last field)
+ if ($this->contains($itemDate, $this->i8n('localdeal'))) {
+ $item['timestamp'] = time();
+ } else if ($this->contains($itemDate, $this->i8n('relative-date-indicator'))) {
$item['timestamp'] = $this->relativeDateToTimestamp($itemDate);
- } else {
+ } else {
$item['timestamp'] = $this->parseDate($itemDate);
}
$this->items[] = $item;
@@ -240,15 +1192,29 @@ class DealabsBridge extends BridgeAbstract {
}
}
+ /**
+ * Check if the string $str contains any of the string of the array $arr
+ * @return boolean true if the string matched anything otherwise false
+ */
+ private function contains($str, array $arr)
+ {
+ foreach ($arr as $a) {
+ if (stripos($str, $a) !== false) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Get the Price from a Deal if it exists
* @return string String of the deal price
*/
- private function getPrix($deal)
+ private function getPrice($deal)
{
- if($deal->find(
+ if ($deal->find(
'span[class*=thread-price]', 0) != null) {
- return '
Name: ' . $details->children(0)->children(1)->innertext;
@@ -139,4 +142,20 @@ class ETTVBridge extends BridgeAbstract {
$this->items[] = $item;
}
}
+
+ public function getName(){
+ if($this->getInput('query')) {
+ return '[' . self::NAME . '] ' . $this->getInput('query');
+ }
+
+ return self::NAME;
+ }
+
+ public function getURI(){
+ if(isset($this->results_link) && !empty($this->results_link)) {
+ return $this->results_link;
+ }
+
+ return self::URI;
+ }
}
diff --git a/bridges/EZTVBridge.php b/bridges/EZTVBridge.php
index 4fb9e578..c016ff33 100644
--- a/bridges/EZTVBridge.php
+++ b/bridges/EZTVBridge.php
@@ -1,7 +1,7 @@
getInput('i'));
+ $showList = explode(',', $this->getInput('i'));
foreach($showList as $showID) {
// Get show page
diff --git a/bridges/ElloBridge.php b/bridges/ElloBridge.php
index c0e266e1..07a91085 100644
--- a/bridges/ElloBridge.php
+++ b/bridges/ElloBridge.php
@@ -45,9 +45,10 @@ class ElloBridge extends BridgeAbstract {
$item = array();
$item['author'] = $this->getUsername($post, $postData);
$item['timestamp'] = strtotime($post->created_at);
- $item['title'] = $this->findText($post->summary);
+ $item['title'] = strip_tags($this->findText($post->summary));
$item['content'] = $this->getPostContent($post->body);
$item['enclosures'] = $this->getEnclosures($post, $postData);
+ $item['uri'] = self::URI . $item['author'] . '/post/' . $post->token;
$content = $post->body;
$this->items[] = $item;
@@ -57,7 +58,7 @@ class ElloBridge extends BridgeAbstract {
}
- public function findText($path) {
+ private function findText($path) {
foreach($path as $summaryElement) {
@@ -71,7 +72,7 @@ class ElloBridge extends BridgeAbstract {
}
- public function getPostContent($path) {
+ private function getPostContent($path) {
$content = '';
foreach($path as $summaryElement) {
@@ -92,7 +93,7 @@ class ElloBridge extends BridgeAbstract {
}
- public function getEnclosures($post, $postData) {
+ private function getEnclosures($post, $postData) {
$assets = [];
foreach($post->links->assets as $asset) {
@@ -108,7 +109,7 @@ class ElloBridge extends BridgeAbstract {
}
- public function getUsername($post, $postData) {
+ private function getUsername($post, $postData) {
foreach($postData->linked->users as $user) {
if($user->id == $post->links->author->id) {
@@ -118,7 +119,7 @@ class ElloBridge extends BridgeAbstract {
}
- public function getAPIKey() {
+ private function getAPIKey() {
$cache = Cache::create('FileCache');
$cache->setPath(CACHE_DIR);
$cache->setParameters(['key']);
diff --git a/bridges/EstCeQuonMetEnProdBridge.php b/bridges/EstCeQuonMetEnProdBridge.php
index db9d1d5f..4439d694 100644
--- a/bridges/EstCeQuonMetEnProdBridge.php
+++ b/bridges/EstCeQuonMetEnProdBridge.php
@@ -7,19 +7,9 @@ class EstCeQuonMetEnProdBridge extends BridgeAbstract {
const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = 'Should we put a website in production today? (French)';
- public function collectData(){
- function extractFromDelimiters($string, $start, $end){
- if(strpos($string, $start) !== false) {
- $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
- $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
- return $section_retrieved;
- }
-
- return false;
- }
-
- $html = getSimpleHTMLDOM($this->getURI())
- or returnServerError('Could not request EstCeQuonMetEnProd: ' . $this->getURI());
+ public function collectData() {
+ $html = getSimpleHTMLDOM(self::URI)
+ or returnServerError('Could not request EstCeQuonMetEnProd: ' . self::URI);
$item = array();
$item['uri'] = $this->getURI() . '#' . date('Y-m-d');
@@ -28,8 +18,8 @@ class EstCeQuonMetEnProdBridge extends BridgeAbstract {
$item['timestamp'] = strtotime('today midnight');
$item['content'] = str_replace(
'src="/',
- 'src="' . $this->getURI(),
- trim(extractFromDelimiters($html->outertext, '', '
'))
+ 'src="' . self::URI,
+ trim(extractFromDelimiters($html->outertext, '', '