pub / tn

Tech News Aggregator
git clone src.jayvii.de/pub/tn.git
Home | Log | Files | Exports | Refs | RSS

commit 29b194ed0d032633d7da459590e0916fe85c3943
parent 6f310c9a29f14b2437c2068bdf702ae1c41a1ed1
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Sat, 24 Oct 2026 11:48:13 +0200

feat: sort and filter via PHP

Diffstat:
M.gitignore | 1+
Massets/css/custom.css | 7-------
Mindex.tt | 72+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
Mperlanetrc.yaml | 26++++++++++++++++----------
4 files changed, 78 insertions(+), 28 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,3 +1,4 @@ index.html +index.php tn.xml tn.opml diff --git a/assets/css/custom.css b/assets/css/custom.css @@ -21,13 +21,6 @@ section { max-width: 100%; text-wrap: nowrap; } -/* Add a counter in front of each post */ -section { - counter-increment: count 1; -} -section > strong::before { - content: counter(count); -} /* footer */ footer { text-align: left !important; diff --git a/index.tt b/index.tt @@ -59,29 +59,79 @@ <main> - <!-- Content Entries --> + <?php + + $news = array(); [% FOREACH entry IN feed.entries %] + array_push( + $news, + array( + "title" => "[%entry.title | html %]", + "url" => "[% entry.link | url %]", + "date" => strtotime("[% entry.issued | html %]") + ) + ); + [% END %] + + // Sort News item by time stamp and remove duplicate entries + function compare(array $a, array $b) { + return $b["date"] - $a["date"]; + } + usort($news, "compare"); + $news = array_intersect_key( + $news, + array_unique( + array_map('serialize', $news) + ) + ); + + ?> + + + <!-- Content Entries --> + <?php + $counter = 0; + foreach ($news as $entry) { + + if ($entry["date"] < strtotime("-24 hours")) { + continue; + } + $counter++; + /* if ($counter > 20) { + * continue; + * } */ + $entry["domain"] = preg_replace( + '/^http(s)*:\/\/([^\/]+)\/.*$/', + '${2}', + $entry["url"] + ); + + ?> + <section> <!-- Headline --> <strong> - <a href="[% entry.link | url | html %]" + <a href="<?php echo $entry["url"]; ?>" target="_blank" rel="nofollow ugc" > - [% entry.title | html %] + <?php echo $counter . ". " . $entry["title"]; ?> </a> </strong> - <!-- Information --> - [% IF entry.issued %] - <em class="info""> - [% entry.issued | html %] + <!-- Information --> + <div style="width:100%;margin-bottom:1em;"> + <em style="margin-left:0.25em;color:var(--border);"> + <?php echo date("Y-m-d, H:i", $entry["date"]); ?> </em> - [% END %] - <em class="url info"> - [% entry.link | url %] + <em style="margin-left:0.25em;color:var(--border);"> + <?php echo $entry["domain"]; ?> </em> + </div> </section> - [% END %] + + <?php + } + ?> </main> diff --git a/perlanetrc.yaml b/perlanetrc.yaml @@ -8,7 +8,7 @@ author: name: JayVii email: jayvii+tn[AT]posteo[DOT]de page: - file: index.html + file: index.php template: index.tt feed: file: /dev/null @@ -35,18 +35,18 @@ feeds: - title: technews[AT]lemmy[DOT]ml url: https://lemmy.ml/feeds/c/technews.xml?sort=TopDay web: https://lemmy.ml/c/technews?sort=TopDay - # - title: kde[AT]lemmy[DOT]kde.social - # url: https://lemmy.kde.social/feeds/c/kde.xml?sort=TopDay - # web: https://lemmy.kde.social/c/kde?sort=TopDay - - title: gnome[AT]discuss[DOT]tchncs.de - url: https://discuss.tchncs.de/feeds/c/gnome.xml?sort=TopDay - web: https://discuss.tchncs.de/c/gnome?sort=TopDay - - title: gnome_dev[AT]programming[DOT]dev - url: https://programming.dev/feeds/c/gnome_dev.xml?sort=TopDay - web: https://programming.dev/c/gnome_dev?sort=TopDay - title: f/Tech url: https://raddle.me/f/Tech/new.atom web: https://raddle.me/f/Tech/new + - title: f/Games + url: https://raddle.me/f/Games/new.atom + web: https://raddle.me/f/Games/new + - title: f/Privacy + url: https://raddle.me/f/Privacy/new.atom + web: https://raddle.me/f/Privacy/new + - title: f/ArtificialIntelligence + url: https://raddle.me/f/ArtificialIntelligence/new.atom + web: https://raddle.me/f/ArtificialIntelligence/new - title: f/hackbloc url: https://raddle.me/f/hackbloc/new.atom web: https://raddle.me/f/hackbloc/new @@ -62,6 +62,12 @@ feeds: - title: This Week in GNOME url: https://thisweek.gnome.org/index.xml web: https://thisweek.gnome.org/ + - title: gnome[AT]discuss[DOT]tchncs.de + url: https://discuss.tchncs.de/feeds/c/gnome.xml?sort=TopDay + web: https://discuss.tchncs.de/c/gnome?sort=TopDay + - title: gnome_dev[AT]programming[DOT]dev + url: https://programming.dev/feeds/c/gnome_dev.xml?sort=TopDay + web: https://programming.dev/c/gnome_dev?sort=TopDay - title: Bits from Debian url: https://bits.debian.org/feeds/feed.rss web: https://bits.debian.org/