HOW-TO: Change the default Thematic navigation bar to display categories instead of pages

So, I figured that tweaking the Thematic WordPress theme that I recently selected as the basis for my blog would present no challenge whatsoever. I mean, it’s PHP, right? Well, yeah, but …

The stumbling block

Child themes and the filter system. Period. I don’t think I’ve ever stumbled across a less-intuitive design. (Admittedly, this post is less about filters and more about hooks and actions, but filters bend the mind as soon as the average person encounters them.)

The author(s) of the theme have posted a fairly-useful guide to customization here, but there’s still a bit of grokking and head-scratching required if this is new to you. Of course, once you “get it”, it’s easy — just like most other abstract concepts. So, let’s dive right in assuming you have set up your child theme according to the example that Thematic provides, and you’ve activated it.

One foot in front of the other

First, you’ll need to create a custom function to remove (undo?) the default thematic_access() action in the thematic_header() hook. Add this bit to your child theme’s functions.php file:

// Remove the default page-level nav
function remove_thematic_access($content) {
	remove_action('thematic_header', 'thematic_access', 9);
}
add_action('init', 'remove_thematic_access');

If you were to save now and view your blog, you’d see that the navigation bar is missing entirely. Good. You’re half way there.

Now, it’s a matter of creating a custom action and inserting it into the thematic_header() hook in the same position as the action you just removed (which is what that '9' is all about.) Add this to your functions.php file:

// Create category-level nav
function custom_childtheme_access() { ?>
	<div id="access">
		<div class="skip-link"><a href="#content" title="<?php _e('Skip navigation to the content', 'thematic'); ?>"><?php _e('Skip to content', 'thematic'); ?></a></div>
			<div class="menu">
				<ul class="sf-menu sf-js-enabled"><?php wp_list_categories('title_li='); ?></ul>
			</div>
  		</div><!-- #access -->
<?php }
add_action('thematic_header', 'custom_childtheme_access', 9);

Save and voila. If you’re curious about some of those magick words, the Google machine is your best bet.

The finish line

Granted, there may be a more shorthand way to do this (e.g., the hardcoded CSS styles?), but this seems to work for me.

For more context, following is a tidbit from the authors’ wiki listing the available hooks and actions. As always, I hope this helps someone. Cheers!


The following theme hooks can be used to modify Thematic through your Child Theme functions.php file or even a custom plugin.

Theme Hooks

thematic_before()
Located in header.php just after the opening body tag, before anything else.

thematic_aboveheader()
Located in header.php just before the header div.

thematic_header()
This hook builds the content of the header div and loads the following actions:

Action Position Number
thematic_brandingopen() 1
thematic_blogtitle() 3
thematic_blogdescription() 5
thematic_brandingclose() 7
thematic_access() 9

thematic_belowheader()
Located in header.php just after the header div.

thematic_abovecomments()

thematic_abovecommentslist()

thematic_belowcommentslist()

thematic_abovetrackbackslist()

thematic_belowtrackbackslist()

thematic_abovecommentsform()

thematic_show_subscription_checkbox()

thematic_belowcommentsform()

thematic_show_manual_subscription_form()

thematic_belowcomments()

thematic_abovemainasides()

thematic_betweenmainasides()

thematic_belowmainasides()

thematic_abovefooter()

thematic_after()

  • Share/Bookmark
Posted in Geeky Stuff, The World According to Me | Tagged , | Leave a comment

HOW-TO: Install Apache Tomcat 6 on FreeBSD 8.0

FreeBSDOn a recent whim, I decided to spend a Saturday morning attempting to install Apache Tomcat 6 on FreeBSD 8.0. It turned out that it’s not as straightforward as some GNU/Linux distros*; particularly those that are Debian-based. Through some trial and error, though, I got things working as I liked.

*It also turns out that I still hate non-free software, or software that comes with restrictions, which is probably why I drifted away from java more than 8 years ago.

About the environment

Since this was an experiment, I simply spun up a VirtualBox VM on my Debian workstation, and allocated 1 CPU, 512MB RAM, and 8GB of hard drive space — FreeBSD is famously small, light, secure, and fast. You can download the latest FreeBSD here.

Installing Diablo JDK 1.6 on FreeBSD 8.0

Before you get started, make sure you have root access and an up-to-date ports collection.

Install some prereqs:

# pkg_add -r libXi libXp libXt libXtst

Or … if you’re a purist, compile them (but there’s not much need for libs like this … the packages are perfectly fine, IMO):

# cd /usr/ports/x11/libXi/ && make install clean
# cd /usr/ports/x11/libXp/ && make install clean
# cd /usr/ports/x11-toolkits/libXt/ && make install clean
# cd /usr/ports/x11/libXtst/ && make install clean

At this point, you’ll need to do a little legwork. Namely: accept the Sun license to download the binaries. One could do this from the FreeBSD box, but it being a headless VM, things are easier with the browser on the host workstation. Go to The FreeBSD Foundation and download the appropriate package for your architecture. In my case, it’s diablo-jdk-freebsd7.i386.1.6.0.07.02.tbz. (Yes, I know it’s for FreeBSD 7, but it works just fine on 8.0 …)

OPTIONAL: if you intend to config the JDK to update the timezone data (enabled by default) you’ll also need the tzupdater from Sun. Go here to download.

Now, to get the files into the FreeBSD VM and put them where the port expects them. Using SFTP:

# sftp [your username]@[IP of machine where you downloaded the files]
sftp> get diablo-jdk-freebsd7.i386.1.6.0.07.02.tbz
sftp> get tzupdater-1_3_18-2009k.zip
sftp> quit
# mv diablo-jdk-freebsd7.i386.1.6.0.07.02.tbz /usr/ports/distfiles
# mv tzupdater-1_3_18-2009k.zip /usr/ports/distfiles

If anything in the preceding steps was unclear, the make tool will quickly tell you what is missing and clarify for you. Compile the Diablo JDK:

# cd /usr/ports/java/diablo-jdk16/ && make install clean

If make complains about files needing to be in /usr/ports/distfiles, retrace the instructions it gives you. They will look very familiar …

If all goes well, test the JDK install. Log out and then back in again (relog), and check the java version:

# java -version
java version "1.6.0_07"
Diablo Java(TM) SE Runtime Environment (build 1.6.0_07-b02)
Diablo Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

Installing Apache Tomcat 6 on FreeBSD 8.0

It couldn’t get much easier.

# cd /usr/ports/www/tomcat6/ && make install clean

It’s a short install and you should notice that all of the dependencies are automatically discovered for you, most notably /usr/local/diablo-jdk1.6.0. To test that things are working:

# /usr/local/apache-tomcat-6.0/bin/startup.sh

Finally, point a browser at http://[Tomcat Server IP]:8180/, in my case, it’s http://192.168.0.153:8180/.

Of course, if you want to create a startup script in rc.d, I suspect you already know how :) I hope this helps. Cheers!

  • Share/Bookmark
Posted in Geeky Stuff | Tagged , , , | 1 Comment

HOW-TO: Fix your Atlassian Confluence database schema

Looking for the default database schemas? Download them for versions 2.6 through 3.3 here. (MySQL format.)

NOTE: Much of this content is relevant only to MySQL users. Other database users may find some semblance of an elucidation, but they’ll have to hack their own scripts!

Over time and multiple version upgrades of Atlassian Confluence, its database can get a bit “dirty” for various reasons and may cause an upgrade to fail or lead to confusion when contacting Atlassian support (see note). A few examples:

  • Prior to version 2.10, the upgrade process wasn’t very “tidy”, shall we say? For example, if the newer version of Confluence didn’t need a data column that the previous version did, the upgrade would just leave the column in place — with all of the newly-unnecessary data intact — and continue on silently and successfully. (Candidly, this behavior may still exist; I haven’t verified.)
  • Also prior to version 2.10, there was a fair amount of content on Atlassian’s documentation wiki that espoused user-submitted “performance tips” for the database. Generally speaking, these tweaks were additional indexes, like those documented here: Improving Database Performance (2.8), Improving Database Performance (2.9), and Improving Database Performance (2.10). Unfortunately, some of these were later reviewed by the Atlassian developers and are not included in Confluence 2.10+, but others were included and the upgrade process attempts to apply them. So, if you applied all of these (and maybe some special sauce of your own), your schema may be unsupported and a later upgrade may fail, or you may end up with multiple identical indexes with different names, or a correctly-named indexes with the wrong definitions.
  • May Steve Yzerman help you if you’ve previously moved your database from a GNU/Linux to a Windows platform, or from a MSSQL to a MySQL platform (or vice versa either combo), using a tool like the MySQL Migration Toolkit or DBConvert (non-free). A side effect of this technique is that the datatypes on certain columns can be changed in a way that leaves Confluence operational after the migration, but could plague an upgrade at a later date.

All is not lost

Luckily, the procedure to fix this problem is fairly straightforward. At the highest level:

  1. Create a new confluence database using the “out of the box” schema DDL for the currently installed Confluence version.
  2. Migrate *only* the data from your old “dirty” database to the new “clean” one.
  3. Repoint your Confluence installation at the new database in confluence.cfg.xml.
  4. Grin a big grin, have a pint of beer, and know your Confluence database schema is shiny and happy, and/or …
  5. Continue on with your upgrade.

Creating an “out of the box” schema

Download the Default Confluence database schemas. I’ve included the major versions from 2.6.3 to 3.3. Before using one of these scripts, create a blank schema in MySQL — I recommend the command line client and the examples below assume that’s your choice. Assuming you started the mysql client from the directory where the SQL file is located, execute:

CREATE DATABASE 'my_clean_database';
USE 'my_clean_database';
SOURCE confluence_2.10.4.sql;

OPTIONAL: To do all of this in one step, you could modify the appropriate SQL script (matching your current Confluence version) to create the database for you; just add the necessary statements immediately before the first CREATE TABLE statement and then execute the SOURCE command.

CREATE DATABASE 'my_clean_database';
USE 'my_clean_database';

--
-- Table structure for table `ATTACHMENTDATA`
--

/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `ATTACHMENTDATA` (
  `ATTACHMENTDATAID` bigint(20) NOT NULL,
[...]

Migrate your data from the “dirty” schema to the “clean” one

Again, we’ll use some mysql command line tools. Extract the data from your current installation:

$ mysqldump -h YOUR_HOSTNAME -u YOUR_UID -pYOUR_PWD -c -B YOUR_CURRENT_DB -K -e -n -t -y -q --single-transaction > confluence_data.sql

NOTE: Of course, substitute real values for any values above that begin with “YOUR_“. And if you’re curious about all the options, refer to the mysqldump documentation.

Now insert the data into your new, clean schema:

$ mysql -h YOUR_HOSTNAME -u YOUR_UID -pYOUR_PWD my_clean_database < confluence_data.sql

Admittedly, any number of things could go wrong at this point. One of the most likely is that the new, clean schema has fewer data columns than a source table (SPACEKEY column in the CONTENT_LABEL table, anyone?) An easy way around this is to manually add the column to the clean schema, import the data, then later remove the column you manually added. Google that for more info.

At this point, it’s a decent idea to check and analyze your new database.

$ mysqlcheck -h YOUR_HOSTNAME -u YOUR_UID -pYOUR_PWD -c --analyze my_clean_database

Repoint your Confluence installation at the new database

Hopefully, this is self-explanatory. Shutdown Confluence and edit your confluence.cfg.xml file to point at your new database. Start Confluence again, and everything should be just fine.

Other thoughts …

Or, more accurately: Why I had to figure this out in the first place.

The company I work for had a particularly finicky Confluence installation that suffered the consequences of all three bullets I listed at the outset of this post: we had an infestation of extra columns, rogue indexes, and incorrect datatypes in our production database. The problem, in combination with 15GB of attachment data being in our database (bad idea, I know) was significant enough that two different Atlassian partners — one listed here and the other here — failed to migrate and upgrade our Confluence installation after charges of many thousands of dollars. (If you’re interested as to who they were, drop me an email.)

So, even though my buddy, Dave, asserts that there’s a capitalistic opportunity in all of this, I’ll freely share a script that I hacked together to automate everything in this post, with a little sed magick bonus for GNU/Linux fanatics.

Those who see the world as an opportunity to get rich, charge for their knowledge. Those who see the world as an opportunity to make the world rich, share their knowledge.
        – I just made that up … after 5 beers

If you’re reasonably handy with bash shell scripts, I am certain that you can expound and embellish this to suit your own needs. Download the script here. Note that some of the variables in this script are different from those used in the examples in this post and, in general, it performs a slightly different set of tasks. From the comments:

# * Dumps only the data from whatever host/database at which you point it.
#   NOTE: can be configured to ignore attachments (DO_IGNORE_ATTACHMENTS
#   setting) and every performance-enhancing option available is hardwired.
#
# * Renames the schema to 'confluence' and fixes some casing issues that
#   arise when going from GNU/Linux > windows.
#
# * Creates the "clean" 2.10.2 schema wherever you tell it, and applies
#   the delta from our PROD Confluence installation.
#
# * Inserts the data into the new "clean" schema.
#
# * Checks and analyzes the new DB and updates statistics.

I hope this helps someone. As always, please post a comment here or drop an email if you have any questions while taking on your own adventures. Cheers.

A story about Atlassian support

Now, I really shouldn’t post this, because Sarah Maddox may get upset with me :) Hallo, Sarah! She happens to be one of the best Tech Writers at Atlassian, by the way …

However, a year or so ago while attempting to performance tune our Confluence 2.10.2 installation, Dave and I contacted Atlassian support. This is when a vexing mayhem ensued. Our office is in Boston, MA. Atlassian’s US support center is on the west/left coast of the US. Sydney is on the other side of the world.

So, after a long and protracted game of phone tag (on the order of a week or more), we eventually got on the line with the US west coast database Guru. In a nutshell, he adeptly drilled down to the fact that we were running with all of the performance tweaks that the Atlassian Confluence wiki documentation suggested. At which point, he said, “We don’t support those tweaks, so I won’t support your installation.” The ticket was then closed.

True story. Fix yer database schema.

  • Share/Bookmark
Posted in Geeky Stuff, The World According to Me | Tagged , , , , | 3 Comments

Zach’s Audition

Oprah is giving away a television show on her network. If Zach doesn’t win, I’ll be crushed and astonished. Vote for this guy, or else. My favorite quote: “This isn’t yoga, I’m just putting my pants on.”

View Zach’s Audition and send this link on to your entire address book.

  • Share/Bookmark
Posted in Geeky Stuff, The World According to Me | Tagged , | 1 Comment

Back to Photoblogging

Calebs Creek | flimflam

Calebs Creek | flimflam

About 6 months ago, I crap-canned the whole idea of multiple sites — one for dis-congruous ramblings, one for semi-serious photography, and one for personal photoblogging — in favor of a single blog that contained all of these things. Well, that was a stupid idea. I have since relaunched my portfolio site and last night I relaunched my photoblog, flimflam.

Hopefully, this compels me to shoot more. But it probably won’t. If you’re interested: Calebs Creek | flimflam.

Cheers.

UPDATE: Two things, really.

1.) I used the word “launch” in this post like people were actually excited and waiting for this to happen.
2.) My screenshot shows that the last web search I did was “pruning rhododendrons.” Garden dork.

  • Share/Bookmark
Posted in Photography and Art | Tagged | Leave a comment
  • Your Ad Here
  • Join the FSF