From d23488205e9254df35214b49b2f6f2b13c8305c6 Mon Sep 17 00:00:00 2001 From: erwan Date: Mon, 19 Aug 2013 16:51:58 +0200 Subject: [PATCH 1/4] add AliasBridge v0.0 add FlickrTag v0.0 --- bridges/AliasBridge.php | 35 ++++++++++++++++++++++++++ bridges/FlickrTagBridge.php | 49 +++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100755 bridges/AliasBridge.php create mode 100755 bridges/FlickrTagBridge.php diff --git a/bridges/AliasBridge.php b/bridges/AliasBridge.php new file mode 100755 index 00000000..4ef42e74 --- /dev/null +++ b/bridges/AliasBridge.php @@ -0,0 +1,35 @@ +returnError('Could not request Alias.', 404); + + foreach($html->find('.views-row') as $element) { + $item = new \Item(); + $item->uri = 'http://alias.sh/'.$element->find('a',0)->href; + //$item->thumbnailUri = $element->find('img',0)->getAttribute('data-defer-src'); + $item->content = $element->find('.bash',0)->plaintext; + $item->title = $element->find('a',0)->plaintext; + $this->items[] = $item; + } + } + + public function getName(){ + return 'Alias latest'; + } + + public function getURI(){ + return 'http://alias.sh/'; + } + + public function getCacheDuration(){ + return 21600; // 6 hours + } +} diff --git a/bridges/FlickrTagBridge.php b/bridges/FlickrTagBridge.php new file mode 100755 index 00000000..9f31526f --- /dev/null +++ b/bridges/FlickrTagBridge.php @@ -0,0 +1,49 @@ +returnError('Could not request Flickr.', 404); + if (isset($param['q'])) { /* keyword search mode */ + $this->request = $param['q']; + $html = file_get_html('http://www.flickr.com/search/?q='.urlencode($this->request).'&s=rec') or $this->returnError('No results for this query.', 404); + } + elseif (isset($param['u'])) { /* user timeline mode */ + $this->request = $param['u']; + $html = file_get_html('http://www.flickr.com/photos/'.urlencode($this->request).'/') or $this->returnError('Requested username can\'t be found.', 404); + } + + else { + $this->returnError('You must specify a keyword or a Flickr username.', 400); + } + + foreach($html->find('span.photo_container') as $element) { + $item = new \Item(); + $item->uri = 'http://flickr.com'.$element->find('a',0)->href; + $item->thumbnailUri = $element->find('img',0)->getAttribute('data-defer-src'); + $item->content = ''; // FIXME: Filter javascript ? + $item->title = $element->find('a',0)->title; + $this->items[] = $item; + } + } + + public function getName(){ + return 'Flickr Tag'; + } + + public function getURI(){ + return 'http://www.flickr.com/search/'; + } + + public function getCacheDuration(){ + return 21600; // 6 hours + } +} From 280edb5adf9453aae4725f2ec378d457514b6b9c Mon Sep 17 00:00:00 2001 From: erwan Date: Mon, 19 Aug 2013 17:07:42 +0200 Subject: [PATCH 2/4] =?UTF-8?q?correction=20d'un=20bug=20sur=20la=20s?= =?UTF-8?q?=C3=A9lection=20des=20articles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bridges/AliasBridge.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridges/AliasBridge.php b/bridges/AliasBridge.php index 4ef42e74..4143cbcc 100755 --- a/bridges/AliasBridge.php +++ b/bridges/AliasBridge.php @@ -10,12 +10,12 @@ class AliasBridge extends BridgeAbstract{ public function collectData(array $param){ $html = file_get_html('http://alias.sh/latest-aliases/') or $this->returnError('Could not request Alias.', 404); - + $html = $html->find('#content',0); foreach($html->find('.views-row') as $element) { $item = new \Item(); $item->uri = 'http://alias.sh/'.$element->find('a',0)->href; //$item->thumbnailUri = $element->find('img',0)->getAttribute('data-defer-src'); - $item->content = $element->find('.bash',0)->plaintext; + $item->content = '
'.$element->find('.bash',0)->outertext.'
'; $item->title = $element->find('a',0)->plaintext; $this->items[] = $item; } From 1316248beb18396094caf1a2d7eccb2acd2be33f Mon Sep 17 00:00:00 2001 From: erwan Date: Mon, 19 Aug 2013 17:10:47 +0200 Subject: [PATCH 3/4] Modification de la description --- bridges/FlickrTagBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/FlickrTagBridge.php b/bridges/FlickrTagBridge.php index 9f31526f..551b16b7 100755 --- a/bridges/FlickrTagBridge.php +++ b/bridges/FlickrTagBridge.php @@ -1,7 +1,7 @@ Date: Mon, 19 Aug 2013 17:18:39 +0200 Subject: [PATCH 4/4] Modification de l'URL --- bridges/AliasBridge.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bridges/AliasBridge.php b/bridges/AliasBridge.php index 4143cbcc..994bd061 100755 --- a/bridges/AliasBridge.php +++ b/bridges/AliasBridge.php @@ -1,15 +1,15 @@ returnError('Could not request Alias.', 404); + $html = file_get_html('http://alias.sh/most-popular/usage') or $this->returnError('Could not request Alias.', 404); $html = $html->find('#content',0); foreach($html->find('.views-row') as $element) { $item = new \Item(); @@ -22,7 +22,7 @@ class AliasBridge extends BridgeAbstract{ } public function getName(){ - return 'Alias latest'; + return 'Alias most used'; } public function getURI(){