-
Notifications
You must be signed in to change notification settings - Fork 1
/
GitHubDesktopBridge.php
41 lines (33 loc) · 1.12 KB
/
GitHubDesktopBridge.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
<?php
class GitHubDesktopBridge extends BridgeAbstract {
const NAME = 'GitHub Desktop Bridge';
const URI = 'https://desktop.github.com/release-notes/';
const DESCRIPTION = 'Returns release notes for GitHub Desktop';
const MAINTAINER = 'VerifiedJoseph';
const PARAMETERS = array();
const CACHE_TIMEOUT = 3600; // 1 hour
private $jsonURl = 'https://central.github.com/deployments/desktop/desktop/changelog.json';
public function collectData() {
$json = getContents($this->jsonURl)
or returnServerError('Could not request: ' . $this->jsonURl);
$data = json_decode($json);
foreach ($data as $release) {
$item = array();
$item['title'] = $release->version;
$item['timestamp'] = $release->pub_date;
$item['content'] = '<ul>';
foreach ($release->notes as $note) {
$item['content'] .= '<li>' . $this->createLinks($note) . '</li>';
}
$item['content'] .= '</ul>';
$this->items[] = $item;
}
}
private function createLinks($note) {
return preg_replace(
'/(?:#([0-9]+))/ims',
'<a target="_blank" href="https://github.com/desktop/desktop/issues/$1" target="_blank">#$1</a> ',
$note
);
}
}