From e5b3ec85d9d07b2bc06b7561e21eb1358f68e805 Mon Sep 17 00:00:00 2001
From: Joseph
Date: Mon, 26 May 2025 21:46:28 +0100
Subject: [PATCH] Delete CuriousCatBridge.php (#4571)
---
bridges/CuriousCatBridge.php | 113 -----------------------------------
1 file changed, 113 deletions(-)
delete mode 100644 bridges/CuriousCatBridge.php
diff --git a/bridges/CuriousCatBridge.php b/bridges/CuriousCatBridge.php
deleted file mode 100644
index 3d6e87d0..00000000
--- a/bridges/CuriousCatBridge.php
+++ /dev/null
@@ -1,113 +0,0 @@
- [
- 'name' => 'Username',
- 'type' => 'text',
- 'required' => true,
- 'exampleValue' => 'koethekoethe',
- ]
- ]];
-
- const CACHE_TIMEOUT = 3600;
-
- public function collectData()
- {
- $url = self::URI . '/api/v2/profile?username=' . urlencode($this->getInput('username'));
-
- $apiJson = getContents($url);
-
- $apiData = Json::decode($apiJson);
- if (isset($apiData['error'])) {
- throw new \Exception($apiData['error_code']);
- }
-
- foreach ($apiData['posts'] as $post) {
- $item = [];
-
- $item['author'] = 'Anonymous';
-
- if ($post['senderData']['id'] !== false) {
- $item['author'] = $post['senderData']['username'];
- }
-
- $item['uri'] = $this->getURI() . '/post/' . $post['id'];
- $item['title'] = $this->ellipsisTitle($post['comment']);
-
- $item['content'] = $this->processContent($post);
- $item['timestamp'] = $post['timestamp'];
-
- $this->items[] = $item;
- }
- }
-
- public function getURI()
- {
- if (!is_null($this->getInput('username'))) {
- return self::URI . '/' . $this->getInput('username');
- }
-
- return parent::getURI();
- }
-
- public function getName()
- {
- if (!is_null($this->getInput('username'))) {
- return $this->getInput('username') . ' - Curious Cat';
- }
-
- return parent::getName();
- }
-
- private function processContent($post)
- {
- $author = 'Anonymous';
-
- if ($post['senderData']['id'] !== false) {
- $authorUrl = self::URI . '/' . $post['senderData']['username'];
-
- $author = <<{$post['senderData']['username']}
-EOD;
- }
-
- $question = $this->formatUrls($post['comment']);
- $answer = $this->formatUrls($post['reply']);
-
- $content = <<{$author} asked:
-{$question}
-{$post['addresseeData']['username']} answered:
-{$answer}
-EOD;
-
- return $content;
- }
-
- private function ellipsisTitle($text)
- {
- $length = 150;
-
- if (strlen($text) > $length) {
- $text = explode('
', wordwrap($text, $length, '
'));
- return $text[0] . '...';
- }
-
- return $text;
- }
-
- private function formatUrls($content)
- {
- return preg_replace(
- '/(http[s]{0,1}\:\/\/[a-zA-Z0-9.\/\?\&=\-_]{4,})/ims',
- '$1 ',
- $content
- );
- }
-}