aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Tone <66808319+Tone866@users.noreply.github.com> 2024-02-08 20:05:24 +0100
committerGravatar GitHub <noreply@github.com> 2024-02-08 20:05:24 +0100
commitae2eb2f1d1af63a3068e18e9d85f92f360b60a34 (patch)
tree94920d110fe7f68a1520001a375577937b647e0c
parentcfef482366e296f2ab1526a97408114b4c1ef9a3 (diff)
downloadrss-bridge-ae2eb2f1d1af63a3068e18e9d85f92f360b60a34.tar.gz
rss-bridge-ae2eb2f1d1af63a3068e18e9d85f92f360b60a34.tar.zst
rss-bridge-ae2eb2f1d1af63a3068e18e9d85f92f360b60a34.zip
feat(Reddit): add parameter for web UI frontend
-rw-r--r--bridges/RedditBridge.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/bridges/RedditBridge.php b/bridges/RedditBridge.php
index 618463a6..9c72f996 100644
--- a/bridges/RedditBridge.php
+++ b/bridges/RedditBridge.php
@@ -38,6 +38,16 @@ class RedditBridge extends BridgeAbstract
'required' => false,
'exampleValue' => 'cats, dogs',
'title' => 'Keyword search, separated by commas'
+ ],
+ 'frontend' => [
+ 'type' => 'list',
+ 'name' => 'frontend',
+ 'title' => 'choose frontend for reddit',
+ 'values' => [
+ 'old.reddit.com' => 'https://old.reddit.com',
+ 'reddit.com' => 'https://reddit.com',
+ 'libreddit.kavin.rocks' => 'https://libreddit.kavin.rocks',
+ ]
]
],
'single' => [
@@ -109,6 +119,10 @@ class RedditBridge extends BridgeAbstract
{
$user = false;
$comments = false;
+ $frontend = $this->getInput('frontend');
+ if ($frontend == '') {
+ $frontend = 'https://old.reddit.com';
+ }
$section = $this->getInput('d');
switch ($this->queriedContext) {
@@ -175,6 +189,10 @@ class RedditBridge extends BridgeAbstract
$item['timestamp'] = $data->created_utc;
$item['uri'] = $this->urlEncodePathParts($data->permalink);
+ if ($frontend != 'https://old.reddit.com') {
+ $item['uri'] = preg_replace('#^https://old\.reddit\.com#', $frontend, $item['uri']);
+ }
+
$item['categories'] = [];
if ($post->kind == 't1') {