Wednesday, November 3, 2010

Blogger Double Post Bug

Decided to witch back to the default Blogger templates today. I'd stripped out all of the inline management tools when I created the old layout because I never needed them back then. I just started to miss them too much these days though, they make a lot of things easier.

In any event, I'd been putting this off for awhile because when I went to use the blogger template designer, I was getting a double post bug where my posts would show on the page twice whether I was on the index or just a single post page.

I couldn't seem to find an easy way to remove the extra posts widget so I just said screw it. Today though I got tired of putting it off, and decided to dig into the HTML of the template and hunt down the obviously present second posts widget.

From the looks of things, it just wasn't recognizing my posts template when it reverted to the default templates. It was looking at my posts widget as if it were a HTML widget or something other than posts, so it was adding a new posts widget. Though, the editor for my widget was still that of a posts widget, so there was no remove this widget button.

So, I singled out my own posts widget, the one with an id of "blog2", and removed the entire widget wrapper and all of the includables. Worked like a charm.

Tuesday, October 19, 2010

RSS Feed for SVN Changelog

I wanted to create an RSS feed for the SVN logs of a wallpaper site script lately. I've been keeping track of my progress on the feeds over at Ozzu in this thread.

So far I have the feed and an archive of the revisions being automatically generated and uploaded to the remote server daily.

Having an RSS feed for the SVN commit history presented an interesting problem where I couldn't really update the script_version field in the scripts schema.sql file without clogging up my revision history with worthless updates about the version number being updated.

So, I wrote a small script that exports a copy of the script, retrieves the SVN revision number from the repo, then updates schema.sql with the correct version number before finally packaging script for me.

In case anyone's curious, here's the code for that. This little script lives in my working copy on my workstation, not under version control.

#!/bin/bash

echo "Exporting HEAD revision..."
svn -q export http://192.168.1.102/svn/wallpaper-script

echo "Updating working copy..."
svn -q update

php -r '
$properties = `svn info -r HEAD`;
if(preg_match("#^revision:\s*(\d+)\s*$#im", $properties, $revision))
{
echo "Updating script version in schema.sql to 2.{$revision[1]}...", PHP_EOL;
$schema = file_get_contents("wallpaper-script/install/schema.sql");
$schema = str_replace("script_version'\'', '\''2.0'\'')", "script_version'\'', '\''2.{$revision[1]}'\'')", $schema);
file_put_contents("wallpaper-script/install/schema.sql", $schema);

echo "Compressing package...", PHP_EOL;
shell_exec("tar zcf wallpaper-site-script_2.{$revision[1]}.tar.gz wallpaper-script");
}
'

echo "Cleaning Up..."
rm -rf wallpaper-script

echo "Done."