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 | |
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
-rw-r--r-- | blog/It's-Alive!/index.html (renamed from blog/It's-Alive!.html) | 0 | ||||
-rw-r--r-- | blog/What-is-a-squibid/index.html | 20 | ||||
-rw-r--r-- | blog/index.php (renamed from blog.php) | 15 | ||||
-rw-r--r-- | blog/librex-and-dots/index.html (renamed from blog/librex-and-dots.html) | 0 | ||||
-rwxr-xr-x | blog/newblog | 24 | ||||
-rw-r--r-- | blog/rss.xml | 40 | ||||
-rw-r--r-- | blog/state-of-the-site/index.html (renamed from blog/state-of-the-site.html) | 0 | ||||
-rw-r--r-- | index.php | 19 | ||||
-rw-r--r-- | misc/tools.php | 27 |
9 files changed, 100 insertions, 45 deletions
diff --git a/blog/It's-Alive!.html b/blog/It's-Alive!/index.html index f55f224..f55f224 100644 --- a/blog/It's-Alive!.html +++ b/blog/It's-Alive!/index.html diff --git a/blog/What-is-a-squibid/index.html b/blog/What-is-a-squibid/index.html new file mode 100644 index 0000000..39daa3c --- /dev/null +++ b/blog/What-is-a-squibid/index.html @@ -0,0 +1,20 @@ +<!DOCTYPE HTML> +<html lang="en"> + <meta name="date" content="2023/10/30"> + <title>'What is a squibid?'</title> + <link rel="stylesheet" href="/style.css"> + <link rel="stylesheet" href="/blog/style.css"> + <body style="background-color: #161617;"> + <p> + Recently, a few people have been asking me: "what is a squibid?" or + "where did your name come from?". In this blog post I will answer those + questions. + <br> + <br> + A few years ago I came up with a drawing of an animal + reason to do anything with it, but regardless I chose to name it a + squibid. Eventually, when trying to find a good username I chose squibid + because that would cover both the username and profile picture. + </p> + </body> +</html> diff --git a/blog.php b/blog/index.php index bcf1767..d60a42d 100644 --- a/blog.php +++ b/blog/index.php @@ -20,23 +20,12 @@ <div id="master"> <header> <h1 id="font", style="margin-bottom: 0"> - <a href="https://squi.bid">Squibid's</a> Blog + <a href="/">Squibid's</a> Blog </h1> </header> <hr style="color: #f7f7f7;"> <p id="bloglist"> - <?php - $path = "blog"; - $files = scandir($path."/"); - foreach ($files as $file) { - if (preg_match("/.+?(?=\.html|\.php)/", $file, $matches)) { - $tags = get_meta_tags($path.'/'.$file); - printf('<a href='.$path.'/%s>%s</a><span>%s</span><br>', - $matches[0], str_replace("-", " ", $matches[0]), - $tags["date"] ? $tags["date"] : "¯\_(ツ)_/¯"); - } - } - ?> + <?php include(__DIR__.'/../misc/tools.php'); entries("../blog"); ?> </p> <h2 id="font" style="text-align: center; margin-top: 0;"> <a href="/blog/rss.xml", title="rss">subscribe</a> diff --git a/blog/librex-and-dots.html b/blog/librex-and-dots/index.html index 5bff21f..5bff21f 100644 --- a/blog/librex-and-dots.html +++ b/blog/librex-and-dots/index.html diff --git a/blog/newblog b/blog/newblog index ea69701..4ab27ba 100755 --- a/blog/newblog +++ b/blog/newblog @@ -1,23 +1,29 @@ #!/bin/sh # generate a base blog file -read -p "Enter name of blog: " name -filename="$(echo $name | sed 's/ /-/g').html" +printf "Enter name of blog entry: " +read -r name +filename="$(echo "$name" | sed 's/ /-/g')" -# make sure we don't overwrite an existent file -[ -f $filename ] && - printf "File already exists! Please choose a different filename.\n"; exit 1 +# make sure we don't overwrite an existing file +if [ -f "$filename" ]; then + printf "Blog entry already exists! Please choose a different name.\n" + exit 1 +fi -printf '<!DOCTYPE HTML> +mkdir "$filename" +cat > "$filename/index.html" << EOF +<!DOCTYPE HTML> <html lang="en"> - <meta name="date" content="2023/07/15"><title>'$name'</title> + <title>'$name'</title> + <meta name="date" content="$(date "+%Y/%m/%d")"> <link rel="stylesheet" href="/style.css"> <body style="background-color: #161617;"> <p> </p> </body> </html> -' > $filename -$EDITOR $filename +EOF +[ "$EDITOR" ] && $EDITOR "$filename/index.html" || vim "$filename/index.html" echo "Make sure to run sup to add to rss feed!" diff --git a/blog/rss.xml b/blog/rss.xml index 2dd53ad..3654882 100644 --- a/blog/rss.xml +++ b/blog/rss.xml @@ -12,9 +12,37 @@ <!-- LB --> <item> +<title>What is a squibid?</title> +<guid>https://squi.bid/blog/What-is-a-squibid/index.html</guid> +<link>https://squi.bid/blog/What-is-a-squibid/index.html</link> +<pubDate>Mon, 30 Oct 2023 12:47:05 -0400</pubDate> +<description><![CDATA[<!DOCTYPE HTML> +<html lang="en"> + <meta name="date" content="2023/10/30"> + <title>'What is a squibid?'</title> + <link rel="stylesheet" href="/style.css"> + <link rel="stylesheet" href="/blog/style.css"> + <body style="background-color: #161617;"> + <p> + Recently, a few people have been asking me: "what is a squibid?" or + "where did your name come from?". In this blog post I will answer those + questions. + <br> + <br> + A few years ago I came up with a drawing of an animal + reason to do anything with it, but regardless I chose to name it a + squibid. Eventually, when trying to find a good username I chose squibid + because that would cover both the username and profile picture. + </p> + +]]></description> +</item> + + +<item> <title>librex and dots</title> -<guid>https://squi.bid/blog/librex-and-dots.html</guid> -<link>https://squi.bid/blog/librex-and-dots.html</link> +<guid>https://squi.bid/blog/librex-and-dots</guid> +<link>https://squi.bid/blog/librex-and-dots</link> <pubDate>Tue, 27 Jun 2023 12:17:35 -0400</pubDate> <description><![CDATA[ <p> @@ -43,8 +71,8 @@ feel free to <a href="mailto:me@zacharyscheiman.com">email me</a>. <item> <title>It's Alive!</title> -<guid>https://squi.bid/blog/It's-Alive!.html</guid> -<link>https://squi.bid/blog/It's-Alive!.html</link> +<guid>https://squi.bid/blog/It's-Alive!</guid> +<link>https://squi.bid/blog/It's-Alive!</link> <pubDate>Mon, 17 Apr 2023 13:22:03 +0000</pubDate> <description><![CDATA[ <p> @@ -58,8 +86,8 @@ feel free to <a href="mailto:me@zacharyscheiman.com">email me</a>. <item> <title>state of the site</title> -<guid>https://squi.bid/blog/state-of-the-site.html</guid> -<link>https://squi.bid/blog/state-of-the-site.html</link> +<guid>https://squi.bid/blog/state-of-the-site</guid> +<link>https://squi.bid/blog/state-of-the-site</link> <pubDate>Sat, 11 Mar 2023 15:00:32 -0500</pubDate> <description><![CDATA[ <p> diff --git a/blog/state-of-the-site.html b/blog/state-of-the-site/index.html index 6196a42..6196a42 100644 --- a/blog/state-of-the-site.html +++ b/blog/state-of-the-site/index.html @@ -64,24 +64,9 @@ </p> </hgroup> <p id="blogpreview"> - <?php - $path = "blog"; - $files = scandir($path."/"); - $i = 0; - foreach ($files as $file) { - if (preg_match("/.+?(?=\.html|\.php)/", $file, $matches)) { - if ($i > 4) - break; - $tags = get_meta_tags($path.'/'.$file); - printf('<a href='.$path.'/%s>%s</a><span>%s</span><br>', - $matches[0], str_replace("-", " ", $matches[0]), - $tags["date"] ? $tags["date"] : "¯\_(ツ)_/¯"); - $i++; - } - } - ?> + <?php include('misc/tools.php'); entries("blog", 5); ?> </p> - <a href="/blog.php">more...</a> + <a href="/blog">more...</a> </div> </div> </div> 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 : "¯\_(ツ)_/¯"); + } + } +?> |