-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.php
More file actions
82 lines (66 loc) · 2.22 KB
/
Copy pathinit.php
File metadata and controls
82 lines (66 loc) · 2.22 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
class Version_Info extends Plugin {
/** @return array<null|float|string|bool> */
public function about() {
return [
null, // version
'Show Tiny Tiny RSS (and related, e.g. PHP and OS) version info using Shift+V.', // description
'wn', // author
false, // is system
'https://github.com/tt-rss/tt-rss-plugin-version-info/', // more info URL
];
}
/** @return int */
public function api_version() {
return 2;
}
/**
* @param PluginHost $host
*
* @return void
**/
public function init($host): void {
$host->add_hook($host::HOOK_HOTKEY_MAP, $this);
$host->add_hook($host::HOOK_HOTKEY_INFO, $this);
}
/**
* @param array<string, string> $hotkeys
* @return array<string, string>
*/
public function hook_hotkey_map($hotkeys) {
$hotkeys['V'] = 'show_version';
return $hotkeys;
}
/**
* @param array<string, array<string, string>> $hotkeys
* @return array<string, array<string, string>>
*/
public function hook_hotkey_info($hotkeys) {
$hotkeys[__('Other')]['show_version'] = __('Show tt-rss version info');
// @phpstan-ignore-next-line '__()' returns strings
return $hotkeys;
}
public function get_version(): void {
/** @var array{'status': int, 'version': string, 'commit'?: string, 'timestamp'?: int|string} */
$ttrss_version = Config::get_version(false);
$is_git = array_key_exists('commit', $ttrss_version) && array_key_exists('timestamp', $ttrss_version);
if (!$is_git) {
print $ttrss_version['version'];
return;
}
$ttrss_version['friendly_timestamp'] = TimeHelper::make_local_datetime(gmdate('Y-m-d H:i:s', (int) $ttrss_version['timestamp']), true, null, true);
$alpine_version = trim(file_get_contents('/etc/alpine-release') ?: 'unknown');
print json_encode([
'versions' => [
'ttrss' => $ttrss_version,
'php' => ['PHP_MAJOR_VERSION' => \PHP_MAJOR_VERSION, 'PHP_VERSION' => \PHP_VERSION],
'alpine' => $alpine_version,
'db' => ORM::for_table('unused')->raw_query('SELECT VERSION()')->find_one()->version,
]
]);
}
/** @return string */
public function get_js() {
return file_get_contents(__DIR__ . '/init.js') ?: '';
}
}