Clean up trailing whitespace lol

This commit is contained in:
Alexis Marie Wright 2022-04-07 22:50:52 -04:00
parent 9e5b6ed930
commit 386057dfe5
5 changed files with 14 additions and 15 deletions

View File

@ -8,16 +8,16 @@ class Config {
'feedUrl' => 'http://www.inhuman-comic.com/feed.xml', 'feedUrl' => 'http://www.inhuman-comic.com/feed.xml',
'itemDelaySeconds' => 604800, // 1 "week" 'itemDelaySeconds' => 604800, // 1 "week"
]; ];
// where to write the feed file // where to write the feed file
const feedPath = '/tmp/feed.xml'; const feedPath = '/tmp/feed.xml';
// base URL of the site (used for constructing URLs) // base URL of the site (used for constructing URLs)
const baseUrl = "http://www.inhuman-comic.com"; const baseUrl = "http://www.inhuman-comic.com";
// archive page URL (what we actually read for comic page links) // archive page URL (what we actually read for comic page links)
const archiveUrl = 'http://www.inhuman-comic.com/archives.php'; const archiveUrl = 'http://www.inhuman-comic.com/archives.php';
// how the script identifies itself to the server while spidering // how the script identifies itself to the server while spidering
// (this will also be used as the "Generator" value in the feed XML) // (this will also be used as the "Generator" value in the feed XML)
const userAgent = 'Lexie\'s RSS Monster (for Cial) (lexie@alexis-marie-wright.me)'; const userAgent = 'Lexie\'s RSS Monster (for Cial) (lexie@alexis-marie-wright.me)';

View File

@ -11,7 +11,7 @@ class ComicPage {
public string $pageNo = ''; public string $pageNo = '';
public string $title = ''; public string $title = '';
public string $imageUrl = ''; public string $imageUrl = '';
function __construct() {} function __construct() {}
function __toString() { function __toString() {
return "[{$this->href}] [{$this->imageUrl}] {$this->pageNo} // {$this->title}"; return "[{$this->href}] [{$this->imageUrl}] {$this->pageNo} // {$this->title}";
@ -29,7 +29,7 @@ function fetchSiteContent() {
$comicLinks = $arc->find('a'); $comicLinks = $arc->find('a');
foreach ($comicLinks as $el) { foreach ($comicLinks as $el) {
$link = new ComicPage; $link = new ComicPage;
$link->href = Config::baseUrl . "/" . $el->href; $link->href = Config::baseUrl . "/" . $el->href;
$link->pageNo = $el->innerText; $link->pageNo = $el->innerText;
@ -65,9 +65,9 @@ function fetchSiteContent() {
if (!$end) { if (!$end) {
throw new Exception("Failed to find a title endpoint at {$el} ({$el->href})"); throw new Exception("Failed to find a title endpoint at {$el} ({$el->href})");
}; };
$link->title = trim(substr($arcHtml, $start, $end - $start)); $link->title = trim(substr($arcHtml, $start, $end - $start));
$link->imageUrl = Config::baseUrl . '/' . $comicPage->find('div.page img')[0]->src; $link->imageUrl = Config::baseUrl . '/' . $comicPage->find('div.page img')[0]->src;
array_push($comicPages, $link); array_push($comicPages, $link);
@ -79,4 +79,4 @@ function fetchSiteContent() {
Log::info("Finished fetching " . count($comicPages) . " pages"); Log::info("Finished fetching " . count($comicPages) . " pages");
return $comicPages; return $comicPages;
}; };

View File

@ -22,7 +22,7 @@ function fetchUrl(string $url) {
Log::debug($res->getBody()); Log::debug($res->getBody());
$exc = new Exception("Request for $url returned {$res->getStatusCode()}"); $exc = new Exception("Request for $url returned {$res->getStatusCode()}");
$exc->response = $res; $exc->response = $res;
throw $exc; throw $exc;
}; };

View File

@ -11,19 +11,19 @@ function generateFeed($content) {
]); ]);
$ts = time(); $ts = time();
$items = []; $items = [];
foreach ($content as $page) { foreach ($content as $page) {
// artificially enforce ordering on undated historical items // artificially enforce ordering on undated historical items
$ts -= Config::feed['itemDelaySeconds']; $ts -= Config::feed['itemDelaySeconds'];
$now = date('c', $ts); $now = date('c', $ts);
$content = $twig->render('item-content.html', [ $content = $twig->render('item-content.html', [
'url' => $page->href, 'url' => $page->href,
'imageUrl' => $page->imageUrl 'imageUrl' => $page->imageUrl
]); ]);
$items[] = $twig->render('item.xml', [ $items[] = $twig->render('item.xml', [
'title' => $page->title, 'title' => $page->title,
'pageNo' => $page->pageNo, 'pageNo' => $page->pageNo,

View File

@ -4,7 +4,7 @@ include_once('config/default.php');
class Log { class Log {
private static $enabled = Config::logLevels; private static $enabled = Config::logLevels;
private static function emit(string $level, $message) { private static function emit(string $level, $message) {
if (!Log::$enabled[$level]) { if (!Log::$enabled[$level]) {
return; return;
@ -29,4 +29,3 @@ class Log {
Log::emit('warn', $message); Log::emit('warn', $message);
} }
}; };