Rory's Blog
Home
Blog
Projects
Facebook
Google+
Github
RSS

Site Setup Refactor

11/15/15

Nothing should look different, but I am now no longer saving generated files to the site repository I carry around with me.

It used to be that I wrote directly in the html files that I served, and then copy-pasted the blog content into the main blog index area. From there, I would hopefully remember to update my RSS file by hand, and oftentimes make a mistake in the item.

Now, I have a views area where I keep each post's title, date published, blog content, and RSS content saved in their file. The various shared code between posts is now saved in a template file, and I have a script that publishes the posts in proper HTML form to my public area, and properly generates the RSS file of interest.

So, finally, I have a system that doesn't repeat itself too much, and has decoupled what I serve to what I create in. But I was still saving the generated content that I served.

So, I wanted to remove the generated files from the repo. The problem? I don't generate files when I push them from my local setup to the server that is ksionda.me. The solution? Create a script that does do that thing, and call that script in my current site_push.bash script.

So, my push script originally looked like:

#!/bin/bash

git push origin master
git push upstream master

ssh rory@ksionda.me "cd nodeSite && git pull origin master"

This would push my local repo to the server's bare git repo, and then ssh to the server's instance of the repo, and pull from the repo that the local repo just pushed to, thus updating all the HTML I had pushed.

Now, the script looks like this:

#!/bin/bash

git push origin master
git push upstream master

ssh rory@ksionda.me "cd nodeSite && ./site_update.bash"

This is itself a script saved in the repo:

git pull origin master
git submodule update --init --recursive

npm install
node scripts/htmlGenerate.js
node scripts/rssGenerate.js
node scripts/indexGenerate.js

It does the original functionality of pulling from the main bare repo. It then also updates all subrepos in the repository as necessary. It also generated the node_modules (which used to also be saved in the repo).

And then my scripts that generate all the served content are run, so there's no noticable difference that those files are no longer saved in the repo.

Things are really cleaning up nicely now that I'm getting near the end of this site. Hopefully, it means I'll have good reference material for when I start over.