Coffee|Code tweaks

I use Serendipity for my blog software. Other
Serendipity users will note that I'm pretty much using the default
template for the site. Boring! For the most part, that's because I'm
more focused on generating content (slim pickings though they may be)
versus putting time into design. Substance versus style, you know? Not
to mention that my sense of style is, well, rather questionable. Ask
Lynn about the sessions we've had trying to pick paint schemes for the
rooms in our new house...

Anyways, last night I finally hit my limits of design frustration with
Serendipity's defaults in a couple of areas:

Default markup: I found that Serendipity accepted a mix of XHTML plus
whitespace, which led to either jamming<tags> <together> <all> <on>
<the> <same> <line> to avoid linefeeds turning into extraneous <br />
tags or leaving off the closing tags and using linefeeds so that I
could make sense of the blog entry source. The result of the former
was a hard-to-edit blob of text, albeit with valid XHTML; the result
of the latter was XHTML that was rather horrendously formed. Until
now, I had sucked up the invalid XHTML (despite all of my objections
to propagating such horrors on the Web) because...

Default style: the default style.css file for Serendipity, for some
reason, removes all of the normal whitespace before and after
elements like <p> and <h3>. This meant that going the well-formed
XHTML route resulted in blog entries in which the paragraphs were
smashed together. I love standards, but I love legibility even more,
and I didn't have time to delve into Serendipity to figure out what
was going on, so I imposed this mess of broken XHTML on the Web for 8
months. Oh the shame!

Sidebar template: I had wanted to add a link to my book (and token
Zend certification) to the sidebar for a while, but had been
modifying the sidebar.tpl template to add the required HTML directly
to the template. Use the source, right? Well, no... while reading the
source was enjoyable, despite my best efforts all I was able to do
was to add the entries to the right-hand side of the page, which was
getting cumberously long.

As it turned out, the solutions to these problems were pretty trivial:

The culprit for the mix of XHTML and significant whitespace turned
out the be the NL2BR markup plugin that is enabled in the default
Serendipity configuration. Turning this plugin off through the very
convenient plugin interface stopped Serendipity from adding <br />
for every linefeed and meant that I could have cleanly formatted
XHTML source for my blog entries.

As a quick-fix for the missing whitespace around <p> tags, I
customized style.css by adding

p { margin-top: 1em; padding-top: 1em;}

. This reintroduced the whitespace I needed; the right fix would be
to go back to the CSS and figure out why it was gone in the first
place, but this works well enough for my needs now.

Going to the source to add XHTML to the sidebar was a red herring, in
this case. In fact, in the default sidebar plugins for Serendipity,
there's something called the HTML Nugget plug-in that enables you
to add arbitrary HTML to your sidebar. You can add multiple HTML
Nugget entries, and, most importantly, you can select which side of
the page you want each sidebar plug-in to appear on. Serendipity
stores the side and order metadata for the plug-ins in the database,
so there is no need to customize the source templates. Very cool. I
love database-driven applications.

Anyways, I hope you enjoy the changes. As a result of the modified
markup conventions, I had to go back and clean up the markup for all of
my previous entries -- but I'm happy to say that at least the first page
of entries now satisfies the W3C standards for
XHTML. I certainly feel better about that...