diff --git a/README.md b/README.md
index e4488c9..59baf4b 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
Wallabag v2: A TT-RSS to Wallabag v2 plugin
=====================
-A [TT-RSS](https://tt-rss.org/) plugin for saving links to a [Wallabag v2](https://www.wallabag.org/) instance.
+A [TT-RSS](https://tt-rss.org/) plugin for saving links to a [Wallabag v2](https://www.wallabag.org/) instance manually or automatically via content filters.
### Installing the plugin:
1. Clone this repo or just grab the [latest release](https://github.com/joshp23/ttrss-to-wallabag-v2/releases/latest) and extract the wallabag_v2 folder into the `plugins.local` folder of ttrss:
@@ -14,6 +14,7 @@ A [TT-RSS](https://tt-rss.org/) plugin for saving links to a [Wallabag v2](https
Special Note: Do not add trailing slashes to any URLs in either the Wallabag or TT-RSS settings or you will get nothing but 404 responses!
4. Enjoy 1-click posting to Wallabag! (Use _Hotkeys!_ S + W )
+5. Optional: Set [Content Filters](https://tt-rss.org/wiki/ContentFilters) in TT-RSS for automatic article sending to Wallabag.
### Note:
1. This plugin stores and sends Wallabag user credentials to obtain initial OAuth tokens and fetch new refresh tokens every 2 weeks as needed.
diff --git a/wallabag_v2/init.php b/wallabag_v2/init.php
index 7429a5c..e496c4d 100644
--- a/wallabag_v2/init.php
+++ b/wallabag_v2/init.php
@@ -4,7 +4,7 @@ class Wallabag_v2 extends Plugin {
private $host;
function about() {
- return array("1.8.1",
+ return array("1.9.0",
"Post articles to a Wallabag v 2.x instance",
"joshu@unfettered.net");
}
@@ -12,31 +12,29 @@ function about() {
function init($host) {
$this->host = $host;
$host->add_hook($host::HOOK_PREFS_TAB, $this);
- $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
- $host->add_hook($host::HOOK_HOTKEY_MAP, $this);
- $host->add_hook($host::HOOK_HOTKEY_INFO, $this);
+ $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
+ $host->add_hook($host::HOOK_HOTKEY_MAP, $this);
+ $host->add_hook($host::HOOK_HOTKEY_INFO, $this);
+ $host->add_hook($host::HOOK_ARTICLE_FILTER_ACTION, $this);
+ $host->add_filter_action($this, "wallabag_v2_send_to_Wallabag", "Send to Wallabag");
}
- function hook_hotkey_map($hotkeys) {
- // Use the new target "open_in_background_tab" to define your own
- // hotkey to this function in other plugins.
- $hotkeys['a w'] = 'send_to_wallabag';
-
- return $hotkeys;
- }
-
- function hook_hotkey_info($hotkeys) {
- $hotkeys[__("Article")]["send_to_wallabag"] = __("Send Article to your Wallabag");
+ function hook_hotkey_map($hotkeys) {
+ $hotkeys['a w'] = 'send_to_wallabag';
+ return $hotkeys;
+ }
+ function hook_hotkey_info($hotkeys) {
+ $hotkeys[__("Article")]['send_to_wallabag'] = __("Send Article to your Wallabag");
return $hotkeys;
}
function save() {
- $w_url = $_POST["wallabag_url"];
- $w_user = $_POST["wallabag_username"];
- $w_pass = $_POST["wallabag_password"];
- $w_cid = $_POST["wallabag_client_id"];
- $w_cs = $_POST["wallabag_client_secret"];
+ $w_url = $_POST['wallabag_url'];
+ $w_user = $_POST['wallabag_username'];
+ $w_pass = $_POST['wallabag_password'];
+ $w_cid = $_POST['wallabag_client_id'];
+ $w_cs = $_POST['wallabag_client_secret'];
if (function_exists('curl_init')) {
$postfields = array(
@@ -61,10 +59,10 @@ function save() {
curl_close($cURL);
$result = json_decode($result,true);
- $w_access = $result["access_token"];
- $w_refresh = $result["refresh_token"];
- $w_error = $result["error"];
- $w_error_msg = $result["error_description"];
+ $w_access = $result['access_token'];
+ $w_refresh = $result['refresh_token'];
+ $w_error = $result['error'];
+ $w_error_msg = $result['error_description'];
$this->host->set($this, "wallabag_access_token", $w_access);
$this->host->set($this, "wallabag_access_token_timeout", $aTimeout);
@@ -95,7 +93,7 @@ function save() {
"status" => $status
);
$debug_result = json_encode($result);
- file_put_contents("plugins.local/wallabag_v2/debug.txt", date('Y-m-d H:i:s')."\r\n".$debug_result."\r\n", FILE_APPEND);
+ file_put_contents("plugins.local/wallabag_v2/debug.txt", date('Y-m-d H:i:s')."\r\n".$debug_result."\r\nPREFS\r\n", FILE_APPEND);
print $debug_result;
} else
print "Error Saving Prefs. Try again.";
@@ -122,17 +120,17 @@ function hook_prefs_tab($args) {
print "
";
print "