summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-10-22 13:25:43 +0300
committerAndrew Dolgov <[email protected]>2021-10-22 13:25:43 +0300
commit2a5c2be6cdd9ba9217a0661805b62aeec1de90c3 (patch)
treeb6d0305d40d49acc2336f2692a201184f65e444c /plugins
parent41245da8a65dc8701eb0f2df0bc614d14822ff87 (diff)
af_redditimgur: allow subscribing to teddit.net subreddits directly (rewriting to reddit.com)
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/af_redditimgur/init.php27
1 files changed, 26 insertions, 1 deletions
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php
index bb9973c9e..dd8fbf651 100755
--- a/plugins/af_redditimgur/init.php
+++ b/plugins/af_redditimgur/init.php
@@ -28,11 +28,24 @@ class Af_RedditImgur extends Plugin {
$host->add_hook($host::HOOK_RENDER_ARTICLE, $this);
$host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this);
$host->add_hook($host::HOOK_RENDER_ARTICLE_API, $this);
+
+ $host->add_hook($host::HOOK_PRE_SUBSCRIBE, $this);
+ }
+
+ function hook_pre_subscribe(&$url, $auth_login, $auth_pass) {
+ $reddit_to_teddit = $this->host->get($this, "reddit_to_teddit");
+
+ if ($reddit_to_teddit) {
+ $url = $this->rewrite_to_reddit($url);
+
+ return true;
+ }
+
+ return false;
}
function hook_prefs_tab($args) {
if ($args != "prefFeeds") return;
-
$enable_readability = $this->host->get($this, "enable_readability");
$enable_content_dupcheck = $this->host->get($this, "enable_content_dupcheck");
$reddit_to_teddit = $this->host->get($this, "reddit_to_teddit");
@@ -874,6 +887,18 @@ class Af_RedditImgur extends Plugin {
return $str;
}
+ private function rewrite_to_reddit($str) {
+ if (strpos($str, "teddit.net") !== false) {
+ $str = preg_replace("/https?:\/\/teddit.net/", "https://reddit.com", $str);
+
+ if (strpos($str, "/.rss") === false)
+ $str .= "/.rss";
+ }
+
+ return $str;
+ }
+
+
function hook_render_article_cdm($article) {
if ($this->host->get($this, "reddit_to_teddit")) {
$need_saving = false;