Articles tagged with "Backstage"

Testing code

So, RSS is now working, which means I can focus on the important part: code.

# Step 5: RSS
DATE=$(date -R)
cat ${TEMPLATE_DIR}/rss_header.xml | sed "s/^\(.*\)::DATE::\(.*\)$/\1${DATE}\2/" > ${RSSFILE}
# Let's add the articles
sort -nr $SORTEDFILE | head -n 10 | while read post
    FILE=$( echo $post | sed 's/^.*::\(.*\)$/\1/')
    TITLE=$(get_title ${FILE})
    URL=${BASE_URL}/$(echo ${FILE} |
        sed 's/^.*\/\(.*\)$/\1/' |
        sed 's/\.txt$/.html/')
    URL="$( echo ${URL} | normalize)"
    DATE=$( echo $post | sed 's/^\([^:]*\)::.*$/\1/' | normalize )
    TEXT="$(get_text ${FILE})"
    TEXT=$(echo ${TEXT} | normalize)
    cat ${TEMPLATE_DIR}/rss_item.xml |
        sed "s/::TITLE::/${TITLE}/" |
        sed "s/::LINK::/${URL}/" |
        sed "s/::DATE::/$(date -Rd ${DATE})/" |
        sed "s/::DESC::/${TEXT}/" >> ${RSSFILE}

cat ${TEMPLATE_DIR}/rss_footer.xml >> ${RSSFILE}

First time I tried that, it was rather dissapointing. It seems to be working better now.

Almost there!

So, I'm almost one month into this thing, and all around I'm happy about the results. So far, the posting system is up and running, so is the homepage (which you might have already seen) and the archive (which you might have not seen because it's not linked anywhere, but is here.

The categories are still not working, but then again, I'm wondering if anyone actually uses those for anything. The main reason for keeping them around so far is because they add some nice colors to the title. That's all there is to it. We'll see.

Things that really should be working but aren't: the comments, the CSS for writing code, and the RSS feed.

But I can't deny it: it's been fun so far :)

Setting everything up

Ok, so here's the deal: I made my mind about moving to a different blogging platform for a while now. I used to have everything under Wordpress, but that proved to be a constant source of headaches.

The main problem was, I had my installation under shared hosting. That meant that all I got was access via FTP, no custom software installation and, worst of all, auto-updates for Wordpress triggered without warning. This was a problem because updating Wordpress would undo all my customizations, but not updating Wordpress left me open to several security bugs.

This, of course, led to the famed spam problem. I wrote a fairly simple spam detector that would catch around 99% of the spam, but it would break after every update. So as a result, one day I'd log into my control panel, and surprise! 900 spam comments to check. And I've also been kicked out of my own FTP several times, due to a fun IP check implemente by my soon-to-be-former hosting.

So I set myself to have a blog system to my taste.

The system in which I'm currently writing is written in Bash, and I'm typing this on ViM. This works for me because, in no particular order,

  • I can write HTML without Wordpress re-writing it afterwards. Super useful for typing code.
  • No security holes. Given that all the HTML will be static, I can forget about constant updates. Once I write the processing for comments (which will be available, in a process I'll explain in a future post) and I double check that it's secure, I'm done. No cookies, no magic_quotes, no SQL Injection.
  • Easy to backup and migrate. Porting my old blog here will be hell, but porting this one somewhere is as easy as copying a folder, and problem solved.

I guess I'll eventually open source the code, but seriously, is just Bash code (89 lines and counting). It's a shame I couldn't get myself to write it in Haskell, but there was just too much string processing. Maybe next time.

There is a good chance that this post it's completely useless for you. It is useless to me too, but if I don't write posts I can't check whether my code is working correctly or not. In no particular order, the list of bugs I squashed with this:

  • A problem with sed and newlines, solved via the tr utility

First post!

I'm still setting things up. You can peek around, but you won't gain much, I'm afraid.