diff options
author | Aleteoryx <alyx@aleteoryx.me> | 2024-11-14 19:54:26 -0500 |
---|---|---|
committer | Aleteoryx <alyx@aleteoryx.me> | 2024-11-14 19:54:26 -0500 |
commit | 357998add708431088a02a03a7bd2d00f7549d9b (patch) | |
tree | 405f084e07f8de0560b93973d6b7c08fbc70e059 /rss.php | |
parent | 10f26c2ae98dd1414e3b84fea400478f28d742a6 (diff) | |
download | rss_dot_php-357998add708431088a02a03a7bd2d00f7549d9b.tar.gz rss_dot_php-357998add708431088a02a03a7bd2d00f7549d9b.tar.bz2 rss_dot_php-357998add708431088a02a03a7bd2d00f7549d9b.zip |
yahoo mrss media
Diffstat (limited to 'rss.php')
-rw-r--r-- | rss.php | 46 |
1 files changed, 41 insertions, 5 deletions
@@ -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'])): ?> • <a href="<?= $entry['link'] ?>">Source</a> <?php endif; ?> + • <time datetime="<?= $entry['date']->format(DateTime::ISO8601) ?>"> <?= htmlentities($entry['date']->format($config['date_fmt'])) ?> |