From d841acfb37d52d89f5b27610754881e3e9e85932 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Thu, 14 Nov 2024 16:35:27 -0500 Subject: add config --- rss.php | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/rss.php b/rss.php index 783a119..b75640f 100644 --- a/rss.php +++ b/rss.php @@ -1,11 +1,11 @@ -getElementsByTagName("content") ?->item(0) ?->getAttribute("type") === "html" && $allow_html !== FALSE) { - $data["content"] = strip_html($data["content"]) + $data["content"] = strip_html($data["content"]); } else { $data["content"] = htmlentities(html_entity_decode($data["content"])); } @@ -143,13 +143,13 @@ function load_rss(string $uri, string $linkrel = "alternate", bool? $allow_html return $parsed??[]; } -function load_cached(int $ttl, string $uri, string $linkrel = "alternate"): array { +function load_cached(int $ttl, string $uri, string $linkrel = "alternate", ?bool $allow_html = NULL): array { global $config; $path = $config["cache_dir"]."/".md5($uri); // echo $path."\n"; if ((@filemtime($path) ?? 0) + $ttl < time()) { // echo "cache miss, loading over network\n"; - $data = load_rss($uri, $linkrel); + $data = load_rss($uri, $linkrel, $allow_html); file_put_contents($path, serialize($data)); return $data; } else { @@ -213,9 +213,19 @@ foreach ($feeds as $name => $data) { if (!isset($data["ttl"])) $data["ttl"] = 3600; if (!isset($data["linkrel"])) $data["linkrel"] = "alternate"; - foreach(load_cached($data["ttl"], $data["url"], $data["linkrel"]) as $entry) { + $data["render_mode"] ??= "title"; + + foreach(load_cached($data["ttl"], $data["url"], $data["linkrel"], @$data["allow_html"]) as $entry) { $entry["source"] = htmlentities($name); $entry["home"] = htmlentities(@$data["home"]); + + if ($data["render_mode"] == "title") { + unset($entry["content"]); + } + if ($data["render_mode"] == "no_title") { + unset($entry["title"]); + } + $combined[] = $entry; } } @@ -266,7 +276,12 @@ $base = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
+

+ + +
+ @@ -274,6 +289,10 @@ $base = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); + + • + Source +