1
0
Fork 0

Tag filter system for blog page

This commit is contained in:
will 2023-09-23 17:55:08 -06:00
parent 854136ebff
commit 23d5d6d751

View file

@ -14,7 +14,7 @@
padding-left: 0;
list-style: none;
}
ul#articles li {
.blogentry {
width: 100%;
list-style: none;
display: inline-block;
@ -29,21 +29,22 @@
article img, article video, article iframe {
filter:drop-shadow(var(--stddropshadow));
}
ul#articles li > a {
text-decoration: none;
}
ul#articles li > a > * {
.blogentry > * {
display: block;
margin: 0.1rem 0;
}
ul#articles li a h4 {
text-decoration: underline;
}
ul#articles li a time, ul#articles li a span {
.entrysummary {
font-size: .9em;
color: gainsboro;
}
ul#articles li a time {
.entrytag {
font-size: .9em;
color: #bbbbbb;
font-style: italic;
display: inline-block;
margin-right: 1ch;
}
.entrydate {
font-weight: bold;
}
article:first-of-type h2::before {
@ -83,25 +84,47 @@
echo "<div id='statuscafe'><div id='statuscafe-username'><a href='https://status.cafe/users/$username' target='_blank'>status</a> $face $timeago</div><div id='statuscafe-content'>$content</div></div>";
?>
<?php
$stag = $_GET["tag"];
$nostag = empty($stag);
if(!$nostag) {
echo "<a style='display: block; margin-top: 1rem; margin-bottom: 1rem;' href='.'>All articles</a>";
}
$content = simplexml_load_file("blog.atom");
echo "<ul id='articles'>";
$year = "-69420";
$yc = 0;
foreach($content->entry as $entry) {
$nyr = substr($entry->published, 0, 4);
if($nyr != $year) {
$year = $nyr;
echo "<li><h2 id='$year'>$year</h2></li>";
}
$dt = substr($entry->published, 0, 10);
$ti = $entry->title;
$wn = "";
if(preg_match('/2022-0(5|4)-(21|25|13)/', $dt)) {
$wn = "title=\"This post is on the archived v2 version of the site. It will not load if you don't have Javascript enabled, and expect jank if viewing on mobile. You have been warned.\" ";
}
echo "<li><a ".$wn."href='".$entry->link["href"]."'><time>".$dt."</time><h4>".$ti."</h4><span>".$entry->summary."</span></a></li>";
$pfilt = false;
if(!$nostag) {
foreach($entry->category as $cat) {
$term = $cat["term"];
if($stag == $term) {
$pfilt = true;
}
}
}
if($pfilt or $nostag) {
$nyr = substr($entry->published, 0, 4);
if($nyr != $year) {
$year = $nyr;
echo "<li><h2 id='$year'>$year</h2></li>";
}
$dt = substr($entry->published, 0, 10);
$ti = $entry->title;
$wn = "";
if(preg_match('/2022-0(5|4)-(21|25|13)/', $dt)) {
$wn = "title=\"This post is on the archived v2 version of the site. It will not load if you don't have Javascript enabled, and expect jank if viewing on mobile. You have been warned.\" ";
}
$cats = "";
foreach($entry->category as $cat) {
$term = $cat["term"];
$cats = $cats."<a class='entrytag' href='?tag=".$term."'>".$term."</a>";
}
echo "<li class='blogentry'><time class='entrydate'>".$dt."</time><h4 class='entrytitle'><a ".$wn."href='".$entry->link["href"]."'>".$ti."</h4></a><span class='entrysummary'>".$entry->summary."</span><span>".$cats."</span></li>";
}
}
echo "</ul>";
?>