diff options
author | Squibid <me@zacharyscheiman.com> | 2023-10-30 12:47:55 -0400 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2023-10-30 12:47:55 -0400 |
commit | 1bc1454b9312e4322d486437055408d1ff35fb22 (patch) | |
tree | 98b270badb82304f520414c35ac8d6b25d7ea466 /misc/tools.php | |
parent | 2d90cc615120fcc892c1b22a2d00578b1c486c72 (diff) | |
download | site-1bc1454b9312e4322d486437055408d1ff35fb22.tar.gz site-1bc1454b9312e4322d486437055408d1ff35fb22.tar.bz2 site-1bc1454b9312e4322d486437055408d1ff35fb22.zip |
New blog entry and changes to how blogs are displayed
- blogs are now in subdirs
- blog list is generated through helper function
- full blog list is in blog subdir
Diffstat (limited to '')
-rw-r--r-- | misc/tools.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/misc/tools.php b/misc/tools.php new file mode 100644 index 0000000..e301c55 --- /dev/null +++ b/misc/tools.php @@ -0,0 +1,27 @@ +<?php + function entries($path = "blog", $limit = false) { + $files = scandir($path."/"); + $entries = []; + $i = 0; + + foreach ($files as $file) { + if (is_dir($path.'/'.$file) && $file[0] != ".") { + $tags = get_meta_tags($path.'/'.$file.'/index.html'); + $entries[$i][0] = preg_replace("/\//", "", $tags["date"]); + $entries[$i][1] = $file; + $entries[$i][2] = $tags["date"]; + $i++; + } + } + rsort($entries); + for ($i = 0; $i < count($entries); $i++) { + if ($limit && $i > $limit - 1) + break; + $file = $entries[$i][1]; + $age = $entries[$i][2]; + printf('<a href=/%s/%s>%s</a><span>%s</span><br>', + $path, $file, str_replace("-", " ", $file), + $age ? $age : "¯\_(ツ)_/¯"); + } + } +?> |