From 7a866114e1236da92c0a35c9441903640a6bdf63 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 24 Dec 2012 15:39:42 +0400 Subject: [PATCH] add -list-plugins option; about sections to plugins --- classes/pluginhost.php | 4 ++++ plugins/digest/digest.php | 6 ++++++ plugins/example/example.php | 6 ++++++ plugins/example_feed/example_feed.php | 6 ++++++ plugins/example_routing/example_routing.php | 6 ++++++ plugins/flattr/flattr.php | 6 ++++++ plugins/googleplus/googleplus.php | 6 ++++++ plugins/identica/identica.php | 6 ++++++ plugins/import_export/import_export.php | 6 ++++++ plugins/instances/instances.php | 6 ++++++ plugins/mail/mail.php | 6 ++++++ plugins/note/note.php | 6 ++++++ plugins/pinterest/pinterest.php | 6 ++++++ plugins/pocket/pocket.php | 6 ++++++ plugins/redditimgur/redditimgur.php | 6 ++++++ plugins/share/share.php | 6 ++++++ plugins/updater/updater.php | 6 ++++++ update.php | 13 ++++++++++++- 18 files changed, 112 insertions(+), 1 deletion(-) diff --git a/classes/pluginhost.php b/classes/pluginhost.php index c55667e12..a637a5216 100644 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -65,6 +65,10 @@ class PluginHost { return array(); } } + function load_all() { + $plugins = array_map("basename", glob("plugins/*")); + $this->load(join(",", $plugins)); + } function load($classlist) { $plugins = explode(",", $classlist); diff --git a/plugins/digest/digest.php b/plugins/digest/digest.php index 5535c3222..d0cbd5b0f 100644 --- a/plugins/digest/digest.php +++ b/plugins/digest/digest.php @@ -4,6 +4,12 @@ class Digest extends Plugin implements IHandler { private $link; private $host; + function _about() { + return array(1.0, + "Digest mode for tt-rss (tablet friendly UI)", + "fox"); + } + function __construct($host) { $this->link = $host->get_link(); $this->host = $host; diff --git a/plugins/example/example.php b/plugins/example/example.php index e49ee5f27..42550b171 100644 --- a/plugins/example/example.php +++ b/plugins/example/example.php @@ -6,6 +6,12 @@ class Example extends Plugin { private $link; private $host; + function _about() { + return array(1.0, + "Example plugin #1", + "fox"); + } + function __construct($host) { $this->link = $host->get_link(); $this->host = $host; diff --git a/plugins/example_feed/example_feed.php b/plugins/example_feed/example_feed.php index 26f392bd7..205594edd 100644 --- a/plugins/example_feed/example_feed.php +++ b/plugins/example_feed/example_feed.php @@ -7,6 +7,12 @@ class Example_Feed extends Plugin { private $link; private $host; + function _about() { + return array(1.0, + "Example feed plugin", + "fox"); + } + function __construct($host) { $this->link = $host->get_link(); $this->host = $host; diff --git a/plugins/example_routing/example_routing.php b/plugins/example_routing/example_routing.php index c8d352ac8..024bf5b22 100644 --- a/plugins/example_routing/example_routing.php +++ b/plugins/example_routing/example_routing.php @@ -15,6 +15,12 @@ class Example_Routing extends Plugin implements IHandler { private $link; private $host; + function _about() { + return array(1.0, + "Example routing plugin", + "fox"); + } + function __construct($host) { $this->link = $host->get_link(); $this->host = $host; diff --git a/plugins/flattr/flattr.php b/plugins/flattr/flattr.php index 3bc427211..e5042632c 100644 --- a/plugins/flattr/flattr.php +++ b/plugins/flattr/flattr.php @@ -10,6 +10,12 @@ class Flattr extends Plugin { $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); } + function _about() { + return array(1.0, + "Share on Flattr plugin", + "Nic Honing"); + } + function hook_article_button($line) { $article_id = $line["id"]; diff --git a/plugins/googleplus/googleplus.php b/plugins/googleplus/googleplus.php index 9505b4096..a100573de 100644 --- a/plugins/googleplus/googleplus.php +++ b/plugins/googleplus/googleplus.php @@ -10,6 +10,12 @@ class GooglePlus extends Plugin { $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); } + function _about() { + return array(1.0, + "Share on Google+ plugin", + "homolibere"); + } + function get_js() { return file_get_contents(dirname(__FILE__) . "/googleplus.js"); } diff --git a/plugins/identica/identica.php b/plugins/identica/identica.php index 5b7d4b3f6..67ca6ae2c 100644 --- a/plugins/identica/identica.php +++ b/plugins/identica/identica.php @@ -10,6 +10,12 @@ class Identica extends Plugin { $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); } + function _about() { + return array(1.0, + "Share on Identi.ca", + "fox"); + } + function get_js() { return file_get_contents(dirname(__FILE__) . "/identica.js"); } diff --git a/plugins/import_export/import_export.php b/plugins/import_export/import_export.php index 7a843c45b..68597978b 100644 --- a/plugins/import_export/import_export.php +++ b/plugins/import_export/import_export.php @@ -12,6 +12,12 @@ class Import_Export extends Plugin implements IHandler { $host->add_command("xml-import", "USER FILE: import articles from XML", $this); } + function _about() { + return array(1.0, + "Imports and exports user data using a neutral XML format", + "fox"); + } + function xml_import($args) { array_shift($args); diff --git a/plugins/instances/instances.php b/plugins/instances/instances.php index f95d511ff..c6a5531cd 100644 --- a/plugins/instances/instances.php +++ b/plugins/instances/instances.php @@ -10,6 +10,12 @@ class Instances extends Plugin implements IHandler { 2 => "Invalid object received", 16 => "Access denied" ); + function _about() { + return array(1.0, + "Support for linking tt-rss instances together and sharing popular feeds.", + "fox"); + } + function __construct($host) { $this->link = $host->get_link(); $this->host = $host; diff --git a/plugins/mail/mail.php b/plugins/mail/mail.php index c9b6ed541..648148cd3 100644 --- a/plugins/mail/mail.php +++ b/plugins/mail/mail.php @@ -4,6 +4,12 @@ class Mail extends Plugin { private $link; private $host; + function _about() { + return array(1.0, + "Adds a share article via email button", + "fox"); + } + function __construct($host) { $this->link = $host->get_link(); $this->host = $host; diff --git a/plugins/note/note.php b/plugins/note/note.php index ebb0b5a25..c6c1ef903 100644 --- a/plugins/note/note.php +++ b/plugins/note/note.php @@ -3,6 +3,12 @@ class Note extends Plugin { private $link; private $host; + function _about() { + return array(1.0, + "Adds support for setting article notes", + "fox"); + } + function __construct($host) { $this->link = $host->get_link(); $this->host = $host; diff --git a/plugins/pinterest/pinterest.php b/plugins/pinterest/pinterest.php index d50691baf..c42549170 100644 --- a/plugins/pinterest/pinterest.php +++ b/plugins/pinterest/pinterest.php @@ -3,6 +3,12 @@ class Pinterest extends Plugin { private $link; private $host; + function _about() { + return array(1.0, + "Share article via Pinterest", + "?"); + } + function __construct($host) { $this->link = $host->get_link(); $this->host = $host; diff --git a/plugins/pocket/pocket.php b/plugins/pocket/pocket.php index 6449b891d..6b5ccddec 100644 --- a/plugins/pocket/pocket.php +++ b/plugins/pocket/pocket.php @@ -4,6 +4,12 @@ class Pocket extends Plugin { private $link; private $host; + function _about() { + return array(1.0, + "Share article via Pocket (formerly Read It Later)", + "?"); + } + function __construct($host) { $this->link = $host->get_link(); $this->host = $host; diff --git a/plugins/redditimgur/redditimgur.php b/plugins/redditimgur/redditimgur.php index 0255dd71b..59bb4d15d 100644 --- a/plugins/redditimgur/redditimgur.php +++ b/plugins/redditimgur/redditimgur.php @@ -4,6 +4,12 @@ class RedditImgur extends Plugin { private $link; private $host; + function _about() { + return array(1.0, + "Inline image links in Reddit RSS feeds", + "fox"); + } + function __construct($host) { $this->link = $host->get_link(); $this->host = $host; diff --git a/plugins/share/share.php b/plugins/share/share.php index 3c7d7943b..254b68bca 100644 --- a/plugins/share/share.php +++ b/plugins/share/share.php @@ -3,6 +3,12 @@ class Share extends Plugin { private $link; private $host; + function _about() { + return array(1.0, + "Share article by unique URL", + "fox"); + } + function __construct($host) { $this->link = $host->get_link(); $this->host = $host; diff --git a/plugins/updater/updater.php b/plugins/updater/updater.php index 0aee1ba79..c85ef3280 100644 --- a/plugins/updater/updater.php +++ b/plugins/updater/updater.php @@ -4,6 +4,12 @@ class Updater extends Plugin { private $link; private $host; + function _about() { + return array(1.0, + "Updates tt-rss installation to latest version.", + "fox"); + } + function __construct($host) { $this->link = $host->get_link(); $this->host = $host; diff --git a/update.php b/update.php index 0da46647a..7bf6807ff 100755 --- a/update.php +++ b/update.php @@ -22,7 +22,6 @@ init_connection($link); - $op = $argv; if (count($argv) == 0 && !defined('STDIN')) { @@ -55,6 +54,7 @@ print " -indexes - recreate missing schema indexes\n"; print " -convert-filters - convert type1 filters to type2\n"; print " -force-update - force update of all feeds\n"; + print " -list-plugins - list all available plugins\n"; print " -help - show this help\n"; print "Plugin options:\n"; @@ -258,6 +258,17 @@ last_updated = '1970-01-01'"); } + if (in_array("-list-plugins", $op)) { + $tmppluginhost = new PluginHost($link); + $tmppluginhost->load_all(); + foreach ($tmppluginhost->get_plugins() as $name => $plugin) { + $about = $plugin->_about(); + + printf("%-60s - v%.2f (by %s)\n%s\n\n", + $name, $about[0], $about[2], $about[1]); + } + } + $pluginhost->run_commands($op); db_close($link);