aboutsummaryrefslogtreecommitdiffstats
path: root/rss.php
diff options
context:
space:
mode:
Diffstat (limited to 'rss.php')
-rw-r--r--rss.php46
1 files changed, 41 insertions, 5 deletions
diff --git a/rss.php b/rss.php
index 2669085..63fa73e 100644
--- a/rss.php
+++ b/rss.php
@@ -94,6 +94,16 @@ function load_rss(string $uri, string $linkrel = "alternate", ?bool $allow_html
$data["content"] = htmlentities(html_entity_decode($data["content"]));
}
+ foreach($node->getElementsByTagNameNS("http://search.yahoo.com/mrss/", "content")
+ ->getIterator() as $media) {
+ $type = $media->getAttribute("type");
+ if (str_starts_with($type, "image/")) {
+ $data["images"][] = htmlentities($media->getAttribute("url"));
+ } elseif (str_starts_with($type, "video/")) {
+ $data["videos"][] = htmlentities($media->getAttribute("url"));
+ }
+ }
+
$data["date"] = new DateTime($node->getElementsByTagName("pubDate")
?->item(0)?->textContent ?? '@0');
$data["date"]->setTimezone($config["timezone"]);
@@ -244,6 +254,9 @@ foreach ($feeds as $name => $data) {
if ($data["mode"] == "no_title") {
unset($entry["title"]);
}
+ if (@$data["media"]) {
+ unset($entry["media"]);
+ }
$combined[] = $entry;
}
@@ -262,6 +275,7 @@ $base = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
<html lang="<?= $config['lang'] ?>">
<head>
<meta charset="UTF-8">
+ <style> object, img, video { max-width: 60vw; } </style>
<style><?= $config['custom_css'] ?></style>
</head>
<body>
@@ -273,16 +287,17 @@ $base = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
$query["disabled"][] = $name;
$uri = $base."?".http_build_query($query);
?>
- <span class="source" data-source="<?= htmlentities($name) ?>">
+ <span class="rss-source" data-source="<?= htmlentities($name) ?>">
<a href="<?= htmlentities($uri) ?>"><?= htmlentities($name) ?></a>
</span>
<?php endforeach; ?>
+
<?php foreach ($off_feeds??[] as $name => $data):
$query = $_GET;
$query["disabled"] = array_filter($query["disabled"], fn($x) => $x !== $name);
$uri = $base."?".http_build_query($query);
?>
- <span class="source disabled" data-source="<?= htmlentities($name) ?>">
+ <span class="rss-source disabled" data-source="<?= htmlentities($name) ?>">
<a href="<?= htmlentities($uri) ?>"><?= htmlentities($name) ?></a>
</span>
<?php endforeach; ?>
@@ -293,27 +308,48 @@ $base = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
<h1>Looks like you filtered out everything...</h1>
<p>Try unfiltering some feeds!</p>
<?php endif;
+
foreach ($combined as $entry): ?>
<article data-source="<?= $entry['source'] ?>">
- <div class="content">
+ <div class="rss-content">
<?php if(isset($entry['title'])): ?>
- <h1 class="title"><a target="<?= $config['link_target'] ?>" href="<?= $entry['link'] ?>"><?= $entry['title'] ?></a></h1>
+ <h1 class="rss-title"><a target="<?= $config['link_target'] ?>" href="<?= $entry['link'] ?>"><?= $entry['title'] ?></a></h1>
<?php endif; ?>
+
<?php if(isset($entry['content'])): ?>
<div><?= $entry['content'] ?></div>
<?php endif; ?>
+
+ <?php if(count($entry['images']??[])): ?>
+ <div class="rss-images">
+ <?php foreach($entry['images'] as $media): ?>
+ <img loading="lazy" src="<?= $media ?>"></object>
+ <?php endforeach; ?>
+ </div>
+ <?php endif; ?>
+
+ <?php if(count($entry['videos']??[])): ?>
+ <div class="rss-videos">
+ <?php foreach($entry['videos'] as $media): ?>
+ <video controls src="<?= $media ?>"></video>
+ <?php endforeach; ?>
+ </div>
+ <?php endif; ?>
</div>
- <span class="source">
+
+ <span class="rss-source">
<?php if ($entry['home']): ?>
<a target="<?= $config['link_target'] ?>" href="<?= $entry['home'] ?>"><?= $entry['source'] ?></a>
<?php else: ?>
<?= $entry['source'] ?>
<?php endif; ?>
</span>
+
<?php if(!isset($entry['title'])): ?>
&bullet;
<a href="<?= $entry['link'] ?>">Source</a>
<?php endif; ?>
+
&bullet;
<time datetime="<?= $entry['date']->format(DateTime::ISO8601) ?>">
<?= htmlentities($entry['date']->format($config['date_fmt'])) ?>