gatherer:~#

//Post 1: Hello World! I Made A Website//

Back ../
21.11.03
Debian, Nginx, Certbot, Bash

Ahoy!

I finally caved and started my own website. After dabbling in web hosting for a few years (I host my band website at home!), I thought it would be a good idea to catalogue this somehow. It may be of interest to empolyers! Maybe! Another reason for wanting to have my own site was to set up my own mail server, so I can get a juicy adam@gatherer.tech e-mail address. Looks a little more professional, might give the aforementioned job-givers an idea of the sorts of projects I get up to in my spare time.

The site itself is hosted on Vultr, using Debian and Nginx with an SSL certificate generated by certbot. I followed a guide by Luke Smith on becoming an "internet landchad". I'm still working on the mail server, as for some reason it's not worked as well.† It was installed and configured with a script from Mr Smith, but currently Outlook cannot reach the IMAP server. We shall see...‡

Rather than a content management system, I have opted to write each page manually (see: bloat). There's something charming about the simplicity of a nice, Web1.0 looking page. To aid in my creation of these blog posts, I use a couple of Bash scripts. One to create a new post and one to rebuild the main blog page. I'll explain them below.

newpage.sh is as follows:

        #!/usr/bin/bash
        # makes the directory named after the date, for ease of management, may change
        DATE1=$(date +%Y-%m-%d)
        echo Creating directory "$DATE1"
        mkdir "$DATE1"

	# gestt he second date formate for top of post
	DATE2=$(date +y.%m.%d)

        # fetches the post number from the linklist file
        POSTNO=$(wc -l linklist | cut -f1 -d' ')

        # reads in the name for the post
        echo 'Enter a post suject:'
        read SUBJECT
	
	# reads in the topics for the tl;dr
	echo 'Enter post topics:'
	read TOPICS

        # creates the post's index.html, inserts $SUBJECT as the title, adds $DATE2 and $TOPICS
        cat temptop > "$DATE1"/index.html
	echo '<h2>//Post '"$POSTNO"': '"$SUBJECT"'//</h2>' >> "$DATE1"/index.html
        echo '<a href="../">Back ../</a>' >> "$DATE1"/index.html
	echo '<br><span class="comment">'"$DATE2" >> "$DATE1"/index.html
	echo '<br>'"$TOPICS"'</span> >> "$DATE2"/index.html
        cat tempbottom >> "$DATE1"/index.html

        # re-creates the blog index.html page and adds a link to the new post to the end of it
        cat blogtop > index.html
        echo '<li><a href="'"$DATE"'/post.html">//Post '"$POSTNO"': '"$SUBJECT"'//</li></p>' >> linklist
        cat linklist >> index.html
        cat blogbottom >> index.html
      

The script makes use of a couple of ____top and ____bottom files. These are the html code up until the 'dynamic' content is inserted, and from after where the content is entered. So for example, blogtop is the top of the main blog page up until the entries are listed. The script then inserts the contents of the linklist file into the page, then blogbottom is inserted beneath. The same thing happens with temptop and tempbottom (template) and the topic of the blog post.

As you may have guessed (either through reading the script or from the paragraph above), the linklist is a list of links from the blog's index.html page to the post entries. It's a little jank, it's a little rough and ready, but it was a lot of fun to make!

rebuild.sh is far simpler:

        # takes the edited blogtop file, reloads it to the start of index.html, then takes
        # the linklist (as is), loads it to the middle of the file, then takes blogbottom
        # and adds it to the bottom of the html file.
        cat blogtop > index.html
        cat linklist >> index.html
        cat blogbottom >> index.html
      

This just allows for manual editing of the blog's index.html page without having to remake the whole thing. It's a bit more of a pain in the behind to adjust the linklist, but I'll just take it one step at a time for now. Not the most flexible, not the efficient, but hey! I made it all on my own!

- Adam

† - As of 21.11.06 the mail sever is operational, though e-mails often land in the junk folder :^(
‡ - Indeed we did see, Outlook and Thunderbird have no qualms with the server now.