mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-10 05:54:41 +02:00
Reformat codebase v4 (#2872)
Reformat code base to PSR12 Co-authored-by: rssbridge <noreply@github.com>
This commit is contained in:
parent
66568e3a39
commit
4f75591060
398 changed files with 58607 additions and 56442 deletions
|
@ -1,67 +1,69 @@
|
|||
<?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',
|
||||
'required' => true,
|
||||
'exampleValue' => 'rss-bridge',
|
||||
'name' => 'Search query'
|
||||
)
|
||||
));
|
||||
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 = [ [
|
||||
's' => [
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'exampleValue' => 'rss-bridge',
|
||||
'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);
|
||||
public function collectData()
|
||||
{
|
||||
$params = ['utf8' => '✓',
|
||||
'q' => urlencode($this->getInput('s')),
|
||||
's' => 'updated',
|
||||
'o' => 'desc',
|
||||
'type' => 'Repositories'];
|
||||
$url = self::URI . 'search?' . http_build_query($params);
|
||||
|
||||
$html = getSimpleHTMLDOM($url);
|
||||
$html = getSimpleHTMLDOM($url);
|
||||
|
||||
foreach($html->find('li.repo-list-item') as $element) {
|
||||
$item = array();
|
||||
foreach ($html->find('li.repo-list-item') as $element) {
|
||||
$item = [];
|
||||
|
||||
$uri = $element->find('.f4 a', 0)->href;
|
||||
$uri = substr(self::URI, 0, -1) . $uri;
|
||||
$item['uri'] = $uri;
|
||||
$uri = $element->find('.f4 a', 0)->href;
|
||||
$uri = substr(self::URI, 0, -1) . $uri;
|
||||
$item['uri'] = $uri;
|
||||
|
||||
$title = $element->find('.f4', 0)->plaintext;
|
||||
$item['title'] = $title;
|
||||
$title = $element->find('.f4', 0)->plaintext;
|
||||
$item['title'] = $title;
|
||||
|
||||
// Description
|
||||
if (count($element->find('p.mb-1')) != 0) {
|
||||
$content = $element->find('p.mb-1', 0)->innertext;
|
||||
} else{
|
||||
$content = 'No description';
|
||||
}
|
||||
// Description
|
||||
if (count($element->find('p.mb-1')) != 0) {
|
||||
$content = $element->find('p.mb-1', 0)->innertext;
|
||||
} else {
|
||||
$content = 'No description';
|
||||
}
|
||||
|
||||
// Tags
|
||||
$content = $content . '<br />';
|
||||
$tags = $element->find('a.topic-tag');
|
||||
$tags_array = array();
|
||||
if (count($tags) != 0) {
|
||||
$content = $content . 'Tags : ';
|
||||
foreach($tags as $tag_element) {
|
||||
$tag_link = 'https://github.com' . $tag_element->href;
|
||||
$tag_name = trim($tag_element->innertext);
|
||||
$content = $content . '<a href="' . $tag_link . '">' . $tag_name . '</a> ';
|
||||
array_push($tags_array, $tag_element->innertext);
|
||||
}
|
||||
}
|
||||
// Tags
|
||||
$content = $content . '<br />';
|
||||
$tags = $element->find('a.topic-tag');
|
||||
$tags_array = [];
|
||||
if (count($tags) != 0) {
|
||||
$content = $content . 'Tags : ';
|
||||
foreach ($tags as $tag_element) {
|
||||
$tag_link = 'https://github.com' . $tag_element->href;
|
||||
$tag_name = trim($tag_element->innertext);
|
||||
$content = $content . '<a href="' . $tag_link . '">' . $tag_name . '</a> ';
|
||||
array_push($tags_array, $tag_element->innertext);
|
||||
}
|
||||
}
|
||||
|
||||
$item['categories'] = $tags_array;
|
||||
$item['content'] = $content;
|
||||
$date = $element->find('relative-time', 0)->datetime;
|
||||
$item['timestamp'] = strtotime($date);
|
||||
$item['categories'] = $tags_array;
|
||||
$item['content'] = $content;
|
||||
$date = $element->find('relative-time', 0)->datetime;
|
||||
$item['timestamp'] = strtotime($date);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue