mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-12-04 11:41:07 +03:00
a4b9611e66
- Do not add spaces after opening or before closing parenthesis // Wrong if( !is_null($var) ) { ... } // Right if(!is_null($var)) { ... } - Add space after closing parenthesis // Wrong if(true){ ... } // Right if(true) { ... } - Add body into new line - Close body in new line // Wrong if(true) { ... } // Right if(true) { ... } Notice: Spaces after keywords are not detected: // Wrong (not detected) // -> space after 'if' and missing space after 'else' if (true) { ... } else{ ... } // Right if(true) { ... } else { ... }
50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
class GithubSearchBridge extends BridgeAbstract {
|
|
|
|
const MAINTAINER = 'corenting';
|
|
const NAME = 'Github Repositories Search';
|
|
const URI = 'https://github.com/';
|
|
const CACHE_TIMEOUT = 600; // 10min
|
|
const DESCRIPTION = 'Returns a specified repositories search (sorted by recently updated)';
|
|
const PARAMETERS = array( array(
|
|
's' => array(
|
|
'type' => 'text',
|
|
'name' => 'Search query'
|
|
)
|
|
));
|
|
|
|
public function collectData(){
|
|
$params = array('utf8' => '✓',
|
|
'q' => urlencode($this->getInput('s')),
|
|
's' => 'updated',
|
|
'o' => 'desc',
|
|
'type' => 'Repositories');
|
|
$url = self::URI . 'search?' . http_build_query($params);
|
|
|
|
$html = getSimpleHTMLDOM($url)
|
|
or returnServerError('Error while downloading the website content');
|
|
|
|
foreach($html->find('div.repo-list-item') as $element) {
|
|
$item = array();
|
|
|
|
$uri = $element->find('h3 a', 0)->href;
|
|
$uri = substr(self::URI, 0, -1) . $uri;
|
|
$item['uri'] = $uri;
|
|
|
|
$title = $element->find('h3', 0)->plaintext;
|
|
$item['title'] = $title;
|
|
|
|
if (count($element->find('p')) == 2) {
|
|
$content = $element->find('p', 0)->innertext;
|
|
} else{
|
|
$content = '';
|
|
}
|
|
$item['content'] = $content;
|
|
|
|
$date = $element->find('relative-time', 0)->datetime;
|
|
$item['timestamp'] = strtotime($date);
|
|
|
|
$this->items[] = $item;
|
|
}
|
|
}
|
|
}
|