1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-08 09:36:39 +02:00

Reformat codebase v4 (#2872)

Reformat code base to PSR12

Co-authored-by: rssbridge <noreply@github.com>
This commit is contained in:
Dag
2022-07-01 15:10:30 +02:00
committed by GitHub
parent 66568e3a39
commit 4f75591060
398 changed files with 58607 additions and 56442 deletions

View File

@@ -1,67 +1,71 @@
<?php
class GoogleGroupsBridge extends XPathAbstract {
const NAME = 'Google Groups Bridge';
const DESCRIPTION = 'Returns the latest posts on a Google Group';
const URI = 'https://groups.google.com';
const PARAMETERS = array( array(
'group' => array(
'name' => 'Group id',
'title' => 'The string that follows /g/ in the URL',
'exampleValue' => 'governance',
'required' => true
),
'account' => array(
'name' => 'Account id',
'title' => 'Some Google groups have an additional id following /a/ in the URL',
'exampleValue' => 'mozilla.org',
'required' => false
)
));
const CACHE_TIMEOUT = 3600;
class GoogleGroupsBridge extends XPathAbstract
{
const NAME = 'Google Groups Bridge';
const DESCRIPTION = 'Returns the latest posts on a Google Group';
const URI = 'https://groups.google.com';
const PARAMETERS = [ [
'group' => [
'name' => 'Group id',
'title' => 'The string that follows /g/ in the URL',
'exampleValue' => 'governance',
'required' => true
],
'account' => [
'name' => 'Account id',
'title' => 'Some Google groups have an additional id following /a/ in the URL',
'exampleValue' => 'mozilla.org',
'required' => false
]
]];
const CACHE_TIMEOUT = 3600;
const TEST_DETECT_PARAMETERS = array(
'https://groups.google.com/a/mozilla.org/g/announce' => array(
'account' => 'mozilla.org', 'group' => 'announce'
),
'https://groups.google.com/g/ansible-project' => array(
'account' => null, 'group' => 'ansible-project'
),
);
const TEST_DETECT_PARAMETERS = [
'https://groups.google.com/a/mozilla.org/g/announce' => [
'account' => 'mozilla.org', 'group' => 'announce'
],
'https://groups.google.com/g/ansible-project' => [
'account' => null, 'group' => 'ansible-project'
],
];
const XPATH_EXPRESSION_ITEM = '//div[@class="yhgbKd"]';
const XPATH_EXPRESSION_ITEM_TITLE = './/span[@class="o1DPKc"]';
const XPATH_EXPRESSION_ITEM_CONTENT = './/span[@class="WzoK"]';
const XPATH_EXPRESSION_ITEM_URI = './/a[@class="ZLl54"]/@href';
const XPATH_EXPRESSION_ITEM_AUTHOR = './/span[@class="z0zUgf"][last()]';
const XPATH_EXPRESSION_ITEM_TIMESTAMP = './/div[@class="tRlaM"]';
const XPATH_EXPRESSION_ITEM_ENCLOSURES = '';
const XPATH_EXPRESSION_ITEM_CATEGORIES = '';
const SETTING_FIX_ENCODING = true;
const XPATH_EXPRESSION_ITEM = '//div[@class="yhgbKd"]';
const XPATH_EXPRESSION_ITEM_TITLE = './/span[@class="o1DPKc"]';
const XPATH_EXPRESSION_ITEM_CONTENT = './/span[@class="WzoK"]';
const XPATH_EXPRESSION_ITEM_URI = './/a[@class="ZLl54"]/@href';
const XPATH_EXPRESSION_ITEM_AUTHOR = './/span[@class="z0zUgf"][last()]';
const XPATH_EXPRESSION_ITEM_TIMESTAMP = './/div[@class="tRlaM"]';
const XPATH_EXPRESSION_ITEM_ENCLOSURES = '';
const XPATH_EXPRESSION_ITEM_CATEGORIES = '';
const SETTING_FIX_ENCODING = true;
protected function getSourceUrl() {
$source = self::URI;
protected function getSourceUrl()
{
$source = self::URI;
$account = $this->getInput('account');
if($account) {
$source = $source . '/a/' . $account;
}
return $source . '/g/' . $this->getInput('group');
}
$account = $this->getInput('account');
if ($account) {
$source = $source . '/a/' . $account;
}
return $source . '/g/' . $this->getInput('group');
}
protected function provideWebsiteContent() {
return defaultLinkTo(getContents($this->getSourceUrl()), self::URI);
}
protected function provideWebsiteContent()
{
return defaultLinkTo(getContents($this->getSourceUrl()), self::URI);
}
const URL_REGEX = '#^https://groups.google.com(?:/a/(?<account>\S+))?(?:/g/(?<group>\S+))#';
const URL_REGEX = '#^https://groups.google.com(?:/a/(?<account>\S+))?(?:/g/(?<group>\S+))#';
public function detectParameters($url) {
$params = array();
if(preg_match(self::URL_REGEX, $url, $matches)) {
$params['group'] = $matches['group'];
$params['account'] = $matches['account'];
return $params;
}
return null;
}
public function detectParameters($url)
{
$params = [];
if (preg_match(self::URL_REGEX, $url, $matches)) {
$params['group'] = $matches['group'];
$params['account'] = $matches['account'];
return $params;
}
return null;
}
}