fix(arstechnica): plus a few unrelated tweaks (#3829)

This commit is contained in:
Dag 2023-12-13 21:40:13 +01:00 committed by GitHub
parent 0b67544f86
commit f01729c86f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 17 deletions

View File

@ -31,6 +31,7 @@ final class FrontpageAction implements ActionInterface
}
}
// todo: cache this renderered template
return render(__DIR__ . '/../templates/frontpage.html.php', [
'messages' => $messages,
'admin_email' => Configuration::getConfig('admin', 'email'),

View File

@ -37,7 +37,14 @@ class ArsTechnicaBridge extends FeedExpander
{
$item_html = getSimpleHTMLDOMCached($item['uri'] . '&amp');
$item_html = defaultLinkTo($item_html, self::URI);
$item['content'] = $item_html->find('.amp-wp-article-content', 0);
$item_content = $item_html->find('.article-content.post-page', 0);
if (!$item_content) {
// The dom selector probably broke. Let's just return the item as-is
return $item;
}
$item['content'] = $item_content;
// remove various ars advertising
$item['content']->find('#social-left', 0)->remove();

View File

@ -523,7 +523,7 @@ class VkBridge extends BridgeAbstract
}
if (!preg_match('#^https?://vk.com/#', $uri)) {
returnServerError('Unexpected redirect location');
returnServerError('Unexpected redirect location: ' . $uri);
}
$redirects++;

View File

@ -49,8 +49,8 @@ class FileCache implements CacheInterface
{
$item = [
'key' => $key,
'value' => $value,
'expiration' => $ttl === null ? 0 : time() + $ttl,
'value' => $value,
];
$cacheFile = $this->createCacheFile($key);
$bytes = file_put_contents($cacheFile, serialize($item), LOCK_EX);

View File

@ -6,7 +6,11 @@ if (version_compare(\PHP_VERSION, '7.4.0') === -1) {
require_once __DIR__ . '/lib/bootstrap.php';
Configuration::verifyInstallation();
$errors = Configuration::checkInstallation();
if ($errors) {
die('<pre>' . implode("\n", $errors) . '</pre>');
}
$customConfig = [];
if (file_exists(__DIR__ . '/config.ini.php')) {
$customConfig = parse_ini_file(__DIR__ . '/config.ini.php', true, INI_SCANNER_TYPED);

View File

@ -15,15 +15,7 @@ final class Configuration
{
}
/**
* Verifies the current installation of RSS-Bridge and PHP.
*
* Returns an error message and aborts execution if the installation does
* not satisfy the requirements of RSS-Bridge.
*
* @return void
*/
public static function verifyInstallation()
public static function checkInstallation(): array
{
$errors = [];
@ -57,10 +49,7 @@ final class Configuration
if (!extension_loaded('json')) {
$errors[] = 'json extension not loaded';
}
if ($errors) {
throw new \Exception(sprintf('Configuration error: %s', implode(', ', $errors)));
}
return $errors;
}
public static function loadConfiguration(array $customConfig = [], array $env = [])