-
Notifications
You must be signed in to change notification settings - Fork 0
/
GithubReleaseBridge.php
63 lines (59 loc) · 1.83 KB
/
GithubReleaseBridge.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
class GithubReleaseBridge extends FeedExpander
{
const MAINTAINER = 'philipp-r';
const NAME = 'Github Release';
const URI = 'https://github.com/';
const CACHE_TIMEOUT = 86400; // 24hrs
const DESCRIPTION = 'Returns the releases of a GitHub project with the ability to filter.';
const PARAMETERS = [ [
'u' => [
'name' => 'User name',
'exampleValue' => 'RSS-Bridge',
'required' => true
],
'p' => [
'name' => 'Project name',
'exampleValue' => 'rss-bridge',
'required' => true
],
'rt' => [
'name' => 'releases or tags',
'type' => 'list',
'required' => true,
'values' => array(
'releases' => 'releases',
'tags' => 'tags'
)
],
's' => [
'type' => 'text',
'required' => false,
'exampleValue' => 'stable',
'name' => 'Include only if title contains'
],
'x' => [
'type' => 'text',
'required' => false,
'exampleValue' => 'rc',
'name' => 'Exclude if title contains'
]
]];
protected function parseItem($feedItem){
$item = parent::parseItem($feedItem);
// Test if string contains the word
if (
( empty($this->getInput('s')) || str_contains($item['title'], $this->getInput('s')) ) &&
( empty($this->getInput('x')) || !str_contains($item['title'], $this->getInput('x')) )
){
return $item;
}
else{
return NULL;
}
}
public function collectData()
{
$this->collectExpandableDatas('https://github.com/'.urlencode($this->getInput('u')).'/'.urlencode($this->getInput('p')).'/'.$this->getInput('rt').'.atom');
}
}