diff options
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | rss.php | 15 |
2 files changed, 14 insertions, 4 deletions
@@ -15,8 +15,9 @@ displayed. The key of the entry is the name. The following options are supported per-feed: - `$feeds[feed]["url"]`: **REQUIRED**: The URL of the RSS/Atom feed. +- `$feeds[feed]["home"]`: An optional homepage for the feed. Will be linked under every entry from it. - `$feeds[feed]["ttl"]`: How long to cache the feed for, in seconds. Defaults to 1 hour. -- `$feeds[feed]["linkrel"]`: For Atom, which `rel=` value to prefer when getting a link. +- `$feeds[feed]["linkrel"]`: For Atom, which `rel=` value to prefer when getting a link. Defaults to alternate. The remaining config options are set on the `$config` array, and are documented inside the file. @@ -1,9 +1,11 @@ <?php define("VERSION", "0.0.1"); /* --- FEEDS - EDIT AS NEEDED --- */ +$feeds["OTW News"] ["url"] = "https://www.transformativeworks.org/category/announcement/feed/"; +//$feeds["OTW News"] ["home"] = "https://www.transformativeworks.org/"; -$feeds["OTW News"] ["url"] = "https://www.transformativeworks.org/category/announcement/feed/"; -$feeds["Dreamwidth News"]["url"] = "https://dw-news.dreamwidth.org/data/rss"; +$feeds["Dreamwidth News"]["url"] = "https://dw-news.dreamwidth.org/data/rss"; +$feeds["Dreamwidth News"]["home"] = "https://dw-news.dreamwidth.org/"; /* --- CONFIG - EDIT AS NEEDED --- */ @@ -145,6 +147,7 @@ foreach ($feeds as $name => $data) { foreach(load_cached($data["ttl"], $data["url"], $data["linkrel"]) as $entry) { $entry["source"] = $name; + $entry["home"] = @$data["home"]; $combined[] = $entry; } } @@ -196,7 +199,13 @@ $base = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); foreach ($combined as $entry): ?> <article> <h1><a href="<?= htmlentities($entry['link']) ?>"><?= htmlentities($entry['title'] ?? "[[[No Title]]]") ?></a></h1> - <span class="source" data-source="<?= htmlentities($entry['source']) ?>"><?= htmlentities($entry['source']) ?></span> + <span class="source" data-source="<?= htmlentities($entry['source']) ?>"> + <?php if ($entry['home']): ?> + <a href="<?= htmlentities($entry['home']) ?>"><?= htmlentities($entry['source']) ?></a> + <?php else: ?> + <?= htmlentities($entry['source']) ?> + <?php endif; ?> + </span> • <time datetime="<?= htmlentities($entry['date']->format(DateTime::ISO8601)) ?>"> <?= htmlentities($entry['date']->format($config['date_fmt'])) ?> |