Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
dvikan committed Apr 6, 2024
1 parent b3ac1d1 commit c30056d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 27 deletions.
2 changes: 1 addition & 1 deletion bridges/FilterBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function collectData()
{
$url = $this->getInput('url');
if (!Url::validate($url)) {
returnClientError('The url parameter must either refer to http or https protocol.');
throw new \Exception('The url parameter must either refer to http or https protocol.');
}
$this->collectExpandableDatas($this->getURI());
}
Expand Down
34 changes: 10 additions & 24 deletions bridges/TrelloBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,8 @@ class TrelloBridge extends BridgeAbstract

private function queryAPI($path, $params = [])
{
$data = json_decode(getContents('https://trello.com/1/'
. $path
. '?'
. http_build_query($params)));
$url = 'https://trello.com/1/' . $path . '?' . http_build_query($params);
$data = json_decode(getContents($url));
return $data;
}

Expand All @@ -576,33 +574,21 @@ private function renderAction($action, $textOnly = false)
&& !$textOnly
&& isset($entity->originalUrl)
) {
$string = '<p><a href="'
. $entity->originalUrl
. '"><img src="'
. $entity->previewUrl
. '"></a></p>';
$string = sprintf(
'<p><a href="%s"><img src="%s"></a></p>',
$entity->originalUrl,
$entity->previewUrl ?? ''
);
} elseif ($type === 'card' && !$textOnly) {
$string = '<a href="https://trello.com/c/'
. $entity->shortLink
. '">'
. $entity->text
. '</a>';
$string = sprintf('<a href="https://trello.com/c/%s">%s</a>', $entity->shortLink, $entity->text);
} elseif ($type === 'member' && !$textOnly) {
$string = '<a href="https://trello.com/'
. $entity->username
. '">'
. $entity->text
. '</a>';
$string = sprintf('<a href="https://trello.com/%s">%s</a>', $entity->username, $entity->text);
} elseif ($type === 'date') {
$string = gmdate('M j, Y \a\t g:i A T', strtotime($entity->date));
} elseif ($type === 'translatable') {
$string = self::ACTION_TEXTS[$entity->translationKey];
} else {
if (isset($entity->text)) {
$string = $entity->text;
} else {
$string = '';
}
$string = $entity->text ?? '';
}
$strings['{' . $entity_name . '}'] = $string;
}
Expand Down
2 changes: 1 addition & 1 deletion bridges/TwitchBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function collectData()
$user = $data->user;
if ($user->videos === null) {
// twitch regularly does this for unknown reasons
$this->logger->info('Twitch returned empty set of videos', ['data' => $data]);
//$this->logger->info('Twitch returned empty set of videos', ['data' => $data]);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion formats/HtmlFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class HtmlFormat extends FormatAbstract

public function stringify()
{
// This query string comes in already url decoded
// This query string is url encoded
$queryString = $_SERVER['QUERY_STRING'];

$feedArray = $this->getFeed();
Expand Down
9 changes: 9 additions & 0 deletions lib/BridgeAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@ abstract class BridgeAbstract
const URI = '';
const DONATION_URI = '';
const DESCRIPTION = 'No description provided';

/**
* Preferably a github username
*/
const MAINTAINER = 'No maintainer';

/**
* Cache TTL in seconds
*/
const CACHE_TIMEOUT = 3600;

const CONFIGURATION = [];
const PARAMETERS = [];
const TEST_DETECT_PARAMETERS = [];
Expand Down
2 changes: 2 additions & 0 deletions lib/contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function getContents(
$httpClient = RssBridge::getHttpClient();
$cache = RssBridge::getCache();

// TODO: consider url validation at this point

$httpHeadersNormalized = [];
foreach ($httpHeaders as $httpHeader) {
$parts = explode(':', $httpHeader);
Expand Down

0 comments on commit c30056d

Please sign in to comment.