forked from blallo/rss-bridge
[GithubIssueBriddge] list all issues when 'i' parameter is not provided
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
7961f8081e
commit
c9822bffa7
1 changed files with 33 additions and 20 deletions
|
@ -1,19 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* GithubIssueBridge
|
|
||||||
*
|
|
||||||
* @name GithubIssue Bridge
|
|
||||||
* @description Returns the comments of a github project issue
|
|
||||||
*/
|
|
||||||
class GithubIssueBridge extends BridgeAbstract{
|
class GithubIssueBridge extends BridgeAbstract{
|
||||||
public function loadMetadatas() {
|
public function loadMetadatas() {
|
||||||
|
|
||||||
$this->maintainer = 'Pierre Mazière';
|
$this->maintainer = 'Pierre Mazière';
|
||||||
$this->name = 'Github Issue';
|
$this->name = 'Github Issue';
|
||||||
$this->uri = '';
|
$this->uri = '';
|
||||||
$this->description = 'Returns the comments of a github project issue';
|
$this->description = 'Returns the issues or comments of an issue of a github project';
|
||||||
|
|
||||||
$this->parameters[]=array (
|
$this->parameters['global']=array (
|
||||||
'u'=>array(
|
'u'=>array(
|
||||||
'name'=>'User name',
|
'name'=>'User name',
|
||||||
'required'=>true
|
'required'=>true
|
||||||
|
@ -21,20 +15,25 @@ class GithubIssueBridge extends BridgeAbstract{
|
||||||
'p'=>array(
|
'p'=>array(
|
||||||
'name'=>'Project name',
|
'name'=>'Project name',
|
||||||
'required'=>true
|
'required'=>true
|
||||||
),
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->parameters['Project Issues']=array();
|
||||||
|
$this->parameters['Issue comments']=array(
|
||||||
'i'=>array(
|
'i'=>array(
|
||||||
'name'=>'Issue number',
|
'name'=>'Issue number',
|
||||||
'type'=>'number',
|
'type'=>'number',
|
||||||
'required'=>true
|
'required'=>'true'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectData(array $param){
|
public function collectData(array $param){
|
||||||
$uri = 'https://github.com/'.$param['u'].'/'.$param['p'].'/issues/'.$param['i'];
|
$uri = 'https://github.com/'.$param['u'].'/'.$param['p'].'/issues/'.(isset($param['i'])?$param['i']:'');
|
||||||
$html = $this->getSimpleHTMLDOM($uri)
|
$html = $this->getSimpleHTMLDOM($uri)
|
||||||
or $this->returnServerError('No results for Github Issue '.$param['i'].' in project '.$param['u'].'/'.$param['p']);
|
or $this->returnServerError('No results for Github Issue '.$param['i'].' in project '.$param['u'].'/'.$param['p']);
|
||||||
|
|
||||||
|
if(isset($param['i'])){
|
||||||
foreach($html->find('.js-comment-container') as $comment){
|
foreach($html->find('.js-comment-container') as $comment){
|
||||||
|
|
||||||
$item = array();
|
$item = array();
|
||||||
|
@ -49,6 +48,20 @@ class GithubIssueBridge extends BridgeAbstract{
|
||||||
|
|
||||||
$this->items[]=$item;
|
$this->items[]=$item;
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
foreach($html->find('.js-active-navigation-container .js-navigation-item') as $issue){
|
||||||
|
$item=array();
|
||||||
|
$info=$issue->find('.opened-by',0);
|
||||||
|
$item['author']=$info->find('a',0)->plaintext;
|
||||||
|
$item['timestamp']=strtotime($info->find('relative-time',0)->getAttribute('datetime'));
|
||||||
|
$item['title']=$issue->find('.js-navigation-open',0)->plaintext;
|
||||||
|
$comments=$issue->firstChild()->firstChild()
|
||||||
|
->nextSibling()->nextSibling()->nextSibling()->plaintext;
|
||||||
|
$item['content']='Comments: '.$comments;
|
||||||
|
$item['uri']='https://github.com'.$issue->find('.js-navigation-open',0)->getAttribute('href');
|
||||||
|
$this->items[]=$item;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCacheDuration(){
|
public function getCacheDuration(){
|
||||||
|
|
Loading…
Reference in a new issue