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',
'itemDelaySeconds' => 604800, // 1 "week"
];
// where to write the feed file
const feedPath = '/tmp/feed.xml';
// base URL of the site (used for constructing URLs)
const baseUrl = "http://www.inhuman-comic.com";
// archive page URL (what we actually read for comic page links)
const archiveUrl = 'http://www.inhuman-comic.com/archives.php';
// how the script identifies itself to the server while spidering
// (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)';

View File

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

View File

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

View File

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

View File

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