From 3922b9534c122f1fa5856b350cd2542256346916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Sun, 26 Jun 2016 00:33:27 +0200 Subject: [PATCH 1/3] new bridge: Github Issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/GithubIssueBridge.php | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 bridges/GithubIssueBridge.php diff --git a/bridges/GithubIssueBridge.php b/bridges/GithubIssueBridge.php new file mode 100644 index 00000000..390c2e82 --- /dev/null +++ b/bridges/GithubIssueBridge.php @@ -0,0 +1,67 @@ +maintainer = 'Pierre Mazière'; + $this->name = 'Github Issue'; + $this->uri = ''; + $this->description = 'Returns the comments of a github project issue'; + $this->update = '2016-06-25'; + + $this->parameters= + '[ + { + "name" : "User name", + "identifier" : "u" + }, + { + "name" : "Project name", + "identifier" : "p" + } + { + "name" : "Issue number", + "identifier" : "i" + } + + ]'; + } + + public function collectData(array $param){ + $uri = 'https://github.com/'.$param['u'].'/'.$param['p'].'/issues/'.$param['i']; + $html = file_get_html($uri) + or $this->returnError('No results for Github Issue '.$param[i].' in project '.$param['u'].'/'.$param['p'], 404); + + foreach($html->find('.js-comment-container') as $comment){ + + $item = new \Item(); + $item->name=$comment->find('img',0)->getAttribute('alt'); + + $comment=$comment->firstChild()->nextSibling(); + + $item->uri=$uri.'#'.$comment->getAttribute('id'); + $item->title=trim($comment->firstChild()->plaintext); + $item->timestamp=strtotime($comment->find('relative-time',0)->getAttribute('datetime')); + $item->content=$comment->find('.comment-body',0)->innertext; + + $this->items[]=$item; + } + } + + public function getName(){ + return 'Github Issue'; + } + + public function getURI(){ + return ''; + } + + public function getCacheDuration(){ + return 600; // ten minutes + } +} From aa96c6b1d2451fb611fd4c8bd6c64700a3aef864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Sun, 26 Jun 2016 11:28:41 +0200 Subject: [PATCH 2/3] fix malformed JSON MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/GithubIssueBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/GithubIssueBridge.php b/bridges/GithubIssueBridge.php index 390c2e82..c932abd3 100644 --- a/bridges/GithubIssueBridge.php +++ b/bridges/GithubIssueBridge.php @@ -23,7 +23,7 @@ class GithubIssueBridge extends BridgeAbstract{ { "name" : "Project name", "identifier" : "p" - } + }, { "name" : "Issue number", "identifier" : "i" From e03a7de15f111b3d6ad723272244221221b384e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Sun, 26 Jun 2016 11:53:44 +0200 Subject: [PATCH 3/3] fix missing quotes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/GithubIssueBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/GithubIssueBridge.php b/bridges/GithubIssueBridge.php index c932abd3..eaf4d9dd 100644 --- a/bridges/GithubIssueBridge.php +++ b/bridges/GithubIssueBridge.php @@ -35,7 +35,7 @@ class GithubIssueBridge extends BridgeAbstract{ public function collectData(array $param){ $uri = 'https://github.com/'.$param['u'].'/'.$param['p'].'/issues/'.$param['i']; $html = file_get_html($uri) - or $this->returnError('No results for Github Issue '.$param[i].' in project '.$param['u'].'/'.$param['p'], 404); + or $this->returnError('No results for Github Issue '.$param['i'].' in project '.$param['u'].'/'.$param['p'], 404); foreach($html->find('.js-comment-container') as $comment){