hide version for bundled plugins because it's meaningless; for everything else support showing version using git (if about[0] is null)

master
Andrew Dolgov 4 years ago
parent 1e6973307c
commit 20a844085f

@ -795,6 +795,7 @@ class Pref_Prefs extends Handler_Protected {
foreach ($tmppluginhost->get_plugins() as $name => $plugin) { foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
$about = $plugin->about(); $about = $plugin->about();
$version = htmlspecialchars($this->_get_plugin_version($plugin));
if ($about[3] ?? false) { if ($about[3] ?? false) {
$is_checked = in_array($name, $system_enabled) ? "checked" : ""; $is_checked = in_array($name, $system_enabled) ? "checked" : "";
@ -811,9 +812,11 @@ class Pref_Prefs extends Handler_Protected {
<i class='material-icons'>open_in_new</i> <?= __("More info...") ?></button> <i class='material-icons'>open_in_new</i> <?= __("More info...") ?></button>
<?php } ?> <?php } ?>
<div dojoType='dijit.Tooltip' connectId='PLABEL-<?= htmlspecialchars($name) ?>' position='after'> <?php if ($version) { ?>
<?= htmlspecialchars(T_sprintf("v%.2f, by %s", $about[0], $about[2])) ?> <div dojoType='dijit.Tooltip' connectId='PLABEL-<?= htmlspecialchars($name) ?>' position='after'>
</div> <?= $version ?>
</div>
<?php } ?>
</fieldset> </fieldset>
<?php <?php
} }
@ -829,6 +832,7 @@ class Pref_Prefs extends Handler_Protected {
foreach ($tmppluginhost->get_plugins() as $name => $plugin) { foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
$about = $plugin->about(); $about = $plugin->about();
$version = htmlspecialchars($this->_get_plugin_version($plugin));
if (empty($about[3]) || $about[3] == false) { if (empty($about[3]) || $about[3] == false) {
@ -875,9 +879,11 @@ class Pref_Prefs extends Handler_Protected {
<i class='material-icons'>open_in_new</i> <?= __("More info...") ?></button> <i class='material-icons'>open_in_new</i> <?= __("More info...") ?></button>
<?php } ?> <?php } ?>
<div dojoType='dijit.Tooltip' connectId="PLABEL-<?= htmlspecialchars($name) ?>" position='after'> <?php if ($version) { ?>
<?= htmlspecialchars(T_sprintf("v%.2f, by %s", $about[0], $about[2])) ?> <div dojoType='dijit.Tooltip' connectId='PLABEL-<?= htmlspecialchars($name) ?>' position='after'>
</div> <?= $version ?>
</div>
<?php } ?>
</fieldset> </fieldset>
<?php <?php
@ -1093,6 +1099,49 @@ class Pref_Prefs extends Handler_Protected {
set_pref(Prefs::_ENABLED_PLUGINS, $plugins); set_pref(Prefs::_ENABLED_PLUGINS, $plugins);
} }
function _get_version_from_git(string $dir) {
$descriptorspec = [
1 => ["pipe", "w"], // STDOUT
2 => ["pipe", "w"], // STDERR
];
$proc = proc_open("git --no-pager log --pretty=\"%ct %h\" -n1 HEAD",
$descriptorspec, $pipes, $dir);
if (is_resource($proc)) {
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
$status = proc_close($proc);
if ($status == 0) {
list($timestamp, $commit) = explode(" ", $stdout);
return trim(strftime("%y.%m", (int)$timestamp) . "-$commit");
} else {
return T_sprintf("Git error [RC=%d]: %s", $status, $stderr);
}
}
}
function _get_plugin_version(Plugin $plugin) {
$about = $plugin->about();
if (!empty($about[0])) {
return T_sprintf("v%.2f, by %s", $about[0], $about[2]);
} else {
$ref = new ReflectionClass(get_class($plugin));
$plugin_dir = dirname($ref->getFileName());
if (basename($plugin_dir) == "plugins") {
return "";
}
if (is_dir("$plugin_dir/.git")) {
return T_sprintf("v%s, by %s", $this->_get_version_from_git($plugin_dir), $about[2]);
}
}
}
static function _get_updated_plugins() { static function _get_updated_plugins() {
$root_dir = dirname(dirname(__DIR__)); # we're in classes/pref/ $root_dir = dirname(dirname(__DIR__)); # we're in classes/pref/
$plugin_dirs = array_filter(glob("$root_dir/plugins.local/*"), "is_dir"); $plugin_dirs = array_filter(glob("$root_dir/plugins.local/*"), "is_dir");

@ -5,7 +5,7 @@ class Af_Comics extends Plugin {
private $filters = array(); private $filters = array();
function about() { function about() {
return array(2.0, return array(null,
"Fixes RSS feeds of assorted comic strips", "Fixes RSS feeds of assorted comic strips",
"fox"); "fox");
} }

@ -4,7 +4,7 @@ class Af_Fsckportal extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Remove feedsportal spamlinks from article content", "Remove feedsportal spamlinks from article content",
"fox"); "fox");
} }

@ -8,7 +8,7 @@ class Af_Proxy_Http extends Plugin {
private $cache; private $cache;
function about() { function about() {
return array(1.0, return array(null,
"Loads media served over plain HTTP via built-in secure proxy", "Loads media served over plain HTTP via built-in secure proxy",
"fox"); "fox");
} }

@ -7,7 +7,7 @@ class Af_Psql_Trgm extends Plugin {
private $default_min_length = 32; private $default_min_length = 32;
function about() { function about() {
return array(1.0, return array(null,
"Marks similar articles as read (requires pg_trgm)", "Marks similar articles as read (requires pg_trgm)",
"fox"); "fox");
} }

@ -10,7 +10,7 @@ class Af_Readability extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Try to inline article content using Readability", "Try to inline article content using Readability",
"fox"); "fox");
} }

@ -8,7 +8,7 @@ class Af_RedditImgur extends Plugin {
private $fallback_preview_urls = []; private $fallback_preview_urls = [];
function about() { function about() {
return array(1.0, return array(null,
"Inline images (and other content) in Reddit RSS feeds", "Inline images (and other content) in Reddit RSS feeds",
"fox"); "fox");
} }

@ -3,7 +3,7 @@ class Af_Unburn extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Resolves feedburner and similar feed redirector URLs (requires CURL)", "Resolves feedburner and similar feed redirector URLs (requires CURL)",
"fox"); "fox");
} }

@ -3,7 +3,7 @@ class Af_Youtube_Embed extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Embed videos in Youtube RSS feeds (and whitelist Youtube iframes)", "Embed videos in Youtube RSS feeds (and whitelist Youtube iframes)",
"fox"); "fox");
} }

@ -3,7 +3,7 @@ class Af_Zz_NoAutoPlay extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Don't autoplay HTML5 videos", "Don't autoplay HTML5 videos",
"fox"); "fox");
} }

@ -3,7 +3,7 @@ class Af_Zz_VidMute extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Mute audio in HTML5 videos", "Mute audio in HTML5 videos",
"fox"); "fox");
} }

@ -4,7 +4,7 @@ class Auth_Internal extends Auth_Base {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Authenticates against internal tt-rss database", "Authenticates against internal tt-rss database",
"fox", "fox",
true); true);

@ -4,7 +4,7 @@ class Auth_Remote extends Auth_Base {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Authenticates against remote password (e.g. supplied by Apache)", "Authenticates against remote password (e.g. supplied by Apache)",
"fox", "fox",
true); true);

@ -5,7 +5,7 @@ class Auto_Assign_Labels extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Assign labels automatically based on article title, content, and tags", "Assign labels automatically based on article title, content, and tags",
"fox"); "fox");
} }

@ -3,7 +3,7 @@ class Bookmarklets extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Easy feed subscription and web page sharing using bookmarklets", "Easy feed subscription and web page sharing using bookmarklets",
"fox", "fox",
false, false,

@ -8,7 +8,7 @@ class Cache_Starred_Images extends Plugin {
private $max_cache_attempts = 5; // per-article private $max_cache_attempts = 5; // per-article
function about() { function about() {
return array(1.0, return array(null,
"Automatically cache media files in Starred articles", "Automatically cache media files in Starred articles",
"fox"); "fox");
} }

@ -9,7 +9,7 @@ class Close_Button extends Plugin {
} }
function about() { function about() {
return array(1.0, return array(null,
"Adds a button to close article panel", "Adds a button to close article panel",
"fox"); "fox");
} }

@ -3,7 +3,7 @@ class Hotkeys_Force_Top extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Force open article to the top", "Force open article to the top",
"itsamenathan"); "itsamenathan");
} }

@ -3,7 +3,7 @@ class Hotkeys_Noscroll extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"n/p (and up/down) hotkeys move between articles without scrolling", "n/p (and up/down) hotkeys move between articles without scrolling",
"fox"); "fox");
} }

@ -4,7 +4,7 @@ class Hotkeys_Swap_JK extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Swap j and k hotkeys (for vi brethren)", "Swap j and k hotkeys (for vi brethren)",
"fox"); "fox");
} }

@ -5,7 +5,7 @@ class Mail extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Share article via email", "Share article via email",
"fox"); "fox");
} }

@ -3,7 +3,7 @@ class MailTo extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Share article via email (using mailto: links, invoking your mail client)", "Share article via email (using mailto: links, invoking your mail client)",
"fox"); "fox");
} }

@ -3,7 +3,7 @@ class No_Iframes extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Remove embedded iframes (unless whitelisted)", "Remove embedded iframes (unless whitelisted)",
"fox"); "fox");
} }

@ -3,7 +3,7 @@ class No_Title_Counters extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Remove counters from window title (prevents tab flashing on new articles)", "Remove counters from window title (prevents tab flashing on new articles)",
"fox"); "fox");
} }

@ -3,7 +3,7 @@ class No_URL_Hashes extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Disable URL hash usage (e.g. #f=10, etc)", "Disable URL hash usage (e.g. #f=10, etc)",
"fox"); "fox");
} }

@ -5,7 +5,7 @@ class Note extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Adds support for setting article notes", "Adds support for setting article notes",
"fox"); "fox");
} }

@ -3,7 +3,7 @@ class NSFW extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Hide article content based on tags", "Hide article content based on tags",
"fox", "fox",
false); false);

@ -21,7 +21,7 @@ class Scored_Oldest_First extends Plugin {
} }
function about() { function about() {
return array(1.0, return array(null,
"Consider article score while sorting by oldest first", "Consider article score while sorting by oldest first",
"fox", "fox",
false, false,

@ -3,7 +3,7 @@ class Share extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Share article by unique URL", "Share article by unique URL",
"fox"); "fox");
} }

@ -3,7 +3,7 @@ class Shorten_Expanded extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Shorten overly long articles in CDM/expanded", "Shorten overly long articles in CDM/expanded",
"fox"); "fox");
} }

@ -4,7 +4,7 @@ class Toggle_Sidebar extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Adds a main toolbar button to toggle sidebar", "Adds a main toolbar button to toggle sidebar",
"fox"); "fox");
} }

@ -5,7 +5,7 @@ class VF_Shared extends Plugin {
private $host; private $host;
function about() { function about() {
return array(1.0, return array(null,
"Feed for all articles actively shared by URL", "Feed for all articles actively shared by URL",
"fox", "fox",
false); false);

Loading…
Cancel
Save