add plugin updates checker into normal updates checker
This commit is contained in:
parent
d821e4b090
commit
7f2fe465b0
|
@ -1093,7 +1093,28 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
set_pref(Prefs::_ENABLED_PLUGINS, $plugins);
|
set_pref(Prefs::_ENABLED_PLUGINS, $plugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _plugin_needs_update($root_dir, $plugin_name) {
|
static function _get_updated_plugins() {
|
||||||
|
$root_dir = dirname(dirname(__DIR__)); # we're in classes/pref/
|
||||||
|
$plugin_dirs = array_filter(glob("$root_dir/plugins.local/*"), "is_dir");
|
||||||
|
|
||||||
|
$rv = [];
|
||||||
|
|
||||||
|
foreach ($plugin_dirs as $dir) {
|
||||||
|
if (is_dir("$dir/.git")) {
|
||||||
|
$plugin_name = basename($dir);
|
||||||
|
|
||||||
|
array_push($rv, ["plugin" => $plugin_name, "rv" => self::_plugin_needs_update($root_dir, $plugin_name)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$rv = array_values(array_filter($rv, function ($item) {
|
||||||
|
return !empty($item["rv"]["o"]);
|
||||||
|
}));
|
||||||
|
|
||||||
|
return $rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function _plugin_needs_update($root_dir, $plugin_name) {
|
||||||
$plugin_dir = "$root_dir/plugins.local/" . basename($plugin_name);
|
$plugin_dir = "$root_dir/plugins.local/" . basename($plugin_name);
|
||||||
$rv = [];
|
$rv = [];
|
||||||
|
|
||||||
|
@ -1150,23 +1171,12 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
if ($_SESSION["access_level"] >= 10) {
|
if ($_SESSION["access_level"] >= 10) {
|
||||||
$plugin_name = $_REQUEST["name"] ?? "";
|
$plugin_name = $_REQUEST["name"] ?? "";
|
||||||
|
|
||||||
# we're in classes/pref/
|
$root_dir = dirname(dirname(__DIR__)); # we're in classes/pref/
|
||||||
$root_dir = dirname(dirname(__DIR__));
|
|
||||||
|
|
||||||
$rv = [];
|
|
||||||
|
|
||||||
if (!empty($plugin_name)) {
|
if (!empty($plugin_name)) {
|
||||||
array_push($rv, ["plugin" => $plugin_name, "rv" => $this->_plugin_needs_update($root_dir, $plugin_name)]);
|
$rv = ["plugin" => $plugin_name, "rv" => self::_plugin_needs_update($root_dir, $plugin_name)];
|
||||||
} else {
|
} else {
|
||||||
$plugin_dirs = array_filter(glob("$root_dir/plugins.local/*"), "is_dir");
|
$rv = self::_get_updated_plugins();
|
||||||
|
|
||||||
foreach ($plugin_dirs as $dir) {
|
|
||||||
if (is_dir("$dir/.git")) {
|
|
||||||
$plugin_name = basename($dir);
|
|
||||||
|
|
||||||
array_push($rv, ["plugin" => $plugin_name, "rv" => $this->_plugin_needs_update($root_dir, $plugin_name)]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print json_encode($rv);
|
print json_encode($rv);
|
||||||
|
@ -1191,7 +1201,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
if (is_dir("$dir/.git")) {
|
if (is_dir("$dir/.git")) {
|
||||||
$plugin_name = basename($dir);
|
$plugin_name = basename($dir);
|
||||||
|
|
||||||
$test = $this->_plugin_needs_update($root_dir, $plugin_name);
|
$test = self::_plugin_needs_update($root_dir, $plugin_name);
|
||||||
|
|
||||||
if (!empty($test["o"]))
|
if (!empty($test["o"]))
|
||||||
array_push($rv, ["plugin" => $plugin_name, "rv" => $this->_update_plugin($root_dir, $plugin_name)]);
|
array_push($rv, ["plugin" => $plugin_name, "rv" => $this->_update_plugin($root_dir, $plugin_name)]);
|
||||||
|
|
|
@ -394,7 +394,7 @@ class RPC extends Handler_Protected {
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkforupdates() {
|
function checkforupdates() {
|
||||||
$rv = [];
|
$rv = ["changeset" => [], "plugins" => []];
|
||||||
|
|
||||||
$git_timestamp = false;
|
$git_timestamp = false;
|
||||||
$git_commit = false;
|
$git_commit = false;
|
||||||
|
@ -411,10 +411,12 @@ class RPC extends Handler_Protected {
|
||||||
if ($git_timestamp < (int)$content["changeset"]["timestamp"] &&
|
if ($git_timestamp < (int)$content["changeset"]["timestamp"] &&
|
||||||
$git_commit != $content["changeset"]["id"]) {
|
$git_commit != $content["changeset"]["id"]) {
|
||||||
|
|
||||||
$rv = $content["changeset"];
|
$rv["changeset"] = $content["changeset"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$rv["plugins"] = Pref_Prefs::_get_updated_plugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
print json_encode($rv);
|
print json_encode($rv);
|
||||||
|
|
19
js/App.js
19
js/App.js
|
@ -812,10 +812,23 @@ const App = {
|
||||||
.then((reply) => {
|
.then((reply) => {
|
||||||
console.log('update reply', reply);
|
console.log('update reply', reply);
|
||||||
|
|
||||||
if (reply.id) {
|
const icon = App.byId("updates-available");
|
||||||
App.byId("updates-available").show();
|
|
||||||
|
if (reply.changeset.id || reply.plugins.length > 0) {
|
||||||
|
icon.show();
|
||||||
|
|
||||||
|
const tips = [];
|
||||||
|
|
||||||
|
if (reply.changeset.id)
|
||||||
|
tips.push(__("Updates for Tiny Tiny RSS are available."));
|
||||||
|
|
||||||
|
if (reply.plugins.length > 0)
|
||||||
|
tips.push(__("Updates for some local plugins are available."));
|
||||||
|
|
||||||
|
icon.setAttribute("title", tips.join("\n"));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
App.byId("updates-available").hide();
|
icon.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -117,6 +117,7 @@
|
||||||
title="<?= __("Communication problem with server.") ?>">error_outline</i>
|
title="<?= __("Communication problem with server.") ?>">error_outline</i>
|
||||||
<i class="material-icons log-alert" style="display : none" onclick="App.openPreferences('system')"
|
<i class="material-icons log-alert" style="display : none" onclick="App.openPreferences('system')"
|
||||||
title="<?= __("Recent entries found in event log.") ?>">warning</i>
|
title="<?= __("Recent entries found in event log.") ?>">warning</i>
|
||||||
|
<i id="updates-available" class="material-icons icon-new-version" style="display : none">new_releases</i>
|
||||||
<a href="#" onclick="document.location.href = 'index.php'"><?= __('Exit preferences') ?></a>
|
<a href="#" onclick="document.location.href = 'index.php'"><?= __('Exit preferences') ?></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -763,6 +763,10 @@ body.ttrss_main #header i.log-alert {
|
||||||
color: #ddba1c;
|
color: #ddba1c;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
body.ttrss_main #header #updates-available {
|
||||||
|
color: #69C671;
|
||||||
|
padding-right: 4px;
|
||||||
|
}
|
||||||
body.ttrss_main #header i {
|
body.ttrss_main #header i {
|
||||||
margin: 0 4px;
|
margin: 0 4px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -763,6 +763,10 @@ body.ttrss_main #header i.log-alert {
|
||||||
color: #ddba1c;
|
color: #ddba1c;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
body.ttrss_main #header #updates-available {
|
||||||
|
color: #69C671;
|
||||||
|
padding-right: 4px;
|
||||||
|
}
|
||||||
body.ttrss_main #header i {
|
body.ttrss_main #header i {
|
||||||
margin: 0 4px;
|
margin: 0 4px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -763,6 +763,10 @@ body.ttrss_main #header i.log-alert {
|
||||||
color: #ddba1c;
|
color: #ddba1c;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
body.ttrss_main #header #updates-available {
|
||||||
|
color: #69C671;
|
||||||
|
padding-right: 4px;
|
||||||
|
}
|
||||||
body.ttrss_main #header i {
|
body.ttrss_main #header i {
|
||||||
margin: 0 4px;
|
margin: 0 4px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -888,6 +888,11 @@ body.ttrss_main {
|
||||||
cursor : pointer;
|
cursor : pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#updates-available {
|
||||||
|
color : @color-checked;
|
||||||
|
padding-right : 4px;
|
||||||
|
}
|
||||||
|
|
||||||
i {
|
i {
|
||||||
margin : 0 4px;
|
margin : 0 4px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -764,6 +764,10 @@ body.ttrss_main #header i.log-alert {
|
||||||
color: #ddba1c;
|
color: #ddba1c;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
body.ttrss_main #header #updates-available {
|
||||||
|
color: #69C671;
|
||||||
|
padding-right: 4px;
|
||||||
|
}
|
||||||
body.ttrss_main #header i {
|
body.ttrss_main #header i {
|
||||||
margin: 0 4px;
|
margin: 0 4px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -764,6 +764,10 @@ body.ttrss_main #header i.log-alert {
|
||||||
color: #ddba1c;
|
color: #ddba1c;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
body.ttrss_main #header #updates-available {
|
||||||
|
color: #69C671;
|
||||||
|
padding-right: 4px;
|
||||||
|
}
|
||||||
body.ttrss_main #header i {
|
body.ttrss_main #header i {
|
||||||
margin: 0 4px;
|
margin: 0 4px;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue