<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BigSmoke &#187; HTML</title>
	<atom:link href="http://blog.bigsmoke.us/tag/html/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.bigsmoke.us</link>
	<description>Smokes your problems, coughs fresh air.</description>
	<lastBuildDate>Sat, 04 Feb 2012 18:03:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>www.stichting-ecosafe.org</title>
		<link>http://blog.bigsmoke.us/2009/09/16/www.stichting-ecosafe.org</link>
		<comments>http://blog.bigsmoke.us/2009/09/16/www.stichting-ecosafe.org#comments</comments>
		<pubDate>Wed, 16 Sep 2009 10:19:56 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[406]]></category>
		<category><![CDATA[AHAH]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[mod_include]]></category>
		<category><![CDATA[mod_negotiation]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[WWW]]></category>
		<category><![CDATA[www.stichting-ecosafe.org]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=683</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>Stichting EcoSafe is a Dutch foundation for the safe-keeping of the funds that are necessary for the maintenance of hardwood plantations. In July of 2006, together with Johan Ockels, I created a website for the Foundation. Johan was responsible for the organization of the whole process. This went very smooth and the website ended up being an emblem of simplicity and clarity. That&#8217;s why I wanted to blog a bit about it now, even though there are a few things that I&#8217;d probably end up doing different if I were to start from scratch. [There's actually a disturbing number of things for which this is true, I'm coming to notice.]</p>

<table class="invisible" style="border: none;"><tr><td valign="top">
<div id="attachment_708" class="wp-caption alignnone" style="width: 310px"><a rel="lightbox-screen" href="http://blog.bigsmoke.us/uploads/2009/07/ecosafe-index-en.png"><img src="http://blog.bigsmoke.us/uploads/2009/07/ecosafe-index-en-300x206.png" alt="The Welcome page of the EcoSafe website" title="www.stichting-ecosafe.org/index.en" width="300" height="206" class="size-medium wp-image-708" /></a><p class="wp-caption-text">The Welcome page of the EcoSafe website</p></div>
</td><td valign="top">
<div id="attachment_794" class="wp-caption alignnone" style="width: 310px"><a rel="lightbox-screen" href="http://blog.bigsmoke.us/uploads/2009/09/ecosafe-plantations-en.png"><img src="http://blog.bigsmoke.us/uploads/2009/09/ecosafe-plantations-en-300x206.png" alt="EcoSafe page for plantations" title="www.stichting-ecosafe.org/plantations.en" width="300" height="206" class="size-medium wp-image-794" /></a><p class="wp-caption-text">EcoSafe page for plantations</p></div>
</td><td valign="top">
<div id="attachment_810" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.bigsmoke.us/uploads/2009/09/ecosafe-cost-structure-en.png"><img src="http://blog.bigsmoke.us/wp-factory/../uploads/2009/09/ecosafe-cost-structure-en-300x205.png" alt="EcoSafe cost structure" title="www.stichting-ecosafe.org/cost-structure.en" width="300" height="205" class="size-medium wp-image-810" /></a><p class="wp-caption-text">EcoSafe cost structure</p></div>
</td></tr></table>

<h2 id="file-structure">File structure</h2>

<p>Like with most websites, I started with creating an SVN repo so that I wouldn&#8217;t have to be afraid of ever losing anything.</p>

<p>The file structure was pretty standard:</p>

<ul>
<li>a <tt>css</tt> dir for stylesheets;</li>
<li><tt>img</tt> for images;</li>
<li><tt>inc</tt> for shared PHP and mod_include stuff and for AJAX partials;</li>
<li><tt>jot</tt> for to-do&#8217;s and other notes;</li>
<li>and <tt>js</tt> for JavaScript files and libraries.</li>
</ul>

<h3>Possible file structure improvements</h3>

<p>If I were to redesign this file structure, I&#8217;d collapse <tt>css</tt>, <tt>img</tt> and <tt>js</tt> into one directory called <tt>layout</tt>, because these are typically things that require the same <tt>robots.txt</tt> and caching policy. Also, it is meaningless to organize things by file extension. If you want to sort something by file extension, use <q><tt>ls -X</tt></q> (or <q><tt>ls --sort=extension</tt></q> if you&#8217;re on GNU).</p>


<h2 id="ssi">Server-side includes</h2>

<p>The site would be so simple that I felt that any type of CMS or content transformation would be completely unnecessary. Instead, I decided to rely on Apache&#8217;s <a href="http://httpd.apache.org/docs/1.3/mod/mod_include.html">mod_include</a> and just use a few partials for repeating page elements such as the left sidebar containing the logo and the menu.</p>

<p>Also, because I didn&#8217;t need to transform the HTML files, I decided I could use good ol&#8217; HTML 4 instead of XHTML 1 (which I&#8217;d have to send to the browser with the wrong mime-type anyway).</p>

<p>This is the HTML for <tt>contact.nl.shtml</tt>:</p>

<pre class="php">&lt;!DOCTYPE html PUBLIC <span style="color: #ff0000;">&quot;-//W3C//DTD HTML 4.01//EN&quot;</span> <span style="color: #ff0000;">&quot;http://www.w3.org/TR/html4/loose.dtd&quot;</span>&gt;
&nbsp;
&lt;html lang=<span style="color: #ff0000;">&quot;en&quot;</span>&gt;
  &lt;head&gt;
    &lt;title&gt;Contact EcoSafe&lt;/title&gt;
&nbsp;
    &lt;meta http-equiv=<span style="color: #ff0000;">&quot;Content-Type&quot;</span> content=<span style="color: #ff0000;">&quot;text/html; charset=UTF-8&quot;</span> /&gt;
&nbsp;
    &lt;link rel=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> type=<span style="color: #ff0000;">&quot;text/css&quot;</span> href=<span style="color: #ff0000;">&quot;/css/style.css&quot;</span>&gt;&lt;/link&gt;
  &lt;/head&gt;
&nbsp;
  &lt;body&gt;
    &lt;!--<span style="color: #808080; font-style: italic;">#include virtual=&quot;/inc/left-side.en.html&quot;--&gt;</span>
&nbsp;
    &lt;!--<span style="color: #808080; font-style: italic;">#include virtual=&quot;/inc/alt-lang.phtml&quot;--&gt;</span>
&nbsp;
    &lt;div id=<span style="color: #ff0000;">&quot;content&quot;</span>&gt;
      &lt;h1&gt;Contact&lt;/h1&gt;
&nbsp;
      &lt;p&gt;Your email to EcoSafe kan be sent to the following address:
      &lt;a href=<span style="color: #ff0000;">&quot;mailto:service@stichting-ecosafe.org&quot;</span>&gt;service@stichting-ecosafe.org&lt;/a&gt;.
      Or, alternatively, you can fax us at <span style="color: #cc66cc;">+31</span> <span style="color: #cc66cc;">50</span> - <span style="color: #cc66cc;">309</span> <span style="color: #cc66cc;">66</span> <span style="color: #cc66cc;">58</span>.&lt;/p&gt;
&nbsp;
      &lt;h2&gt;About this website&lt;/h2&gt;
&nbsp;
      &lt;p&gt;For comments and/or suggestions concerning this website,
      you can direct an email message at:
      &lt;a href=<span style="color: #ff0000;">&quot;mailto:webmaster@stichting-ecosafe.org&quot;</span>&gt;webmaster@stichting-ecosafe.org&lt;/a&gt;.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>

<div id="attachment_788" class="wp-caption alignright" style="width: 197px"><img src="http://blog.bigsmoke.us/uploads/2009/09/ecosafe-alt-language.png" alt="Alternative language selection" title="www.stichting-ecosafe.org alternative language selection" width="187" height="38" class="size-full wp-image-788" /><p class="wp-caption-text">Alternative language selection</p></div>

<p>I use <tt>&lt;!--#include virtual--&gt;</tt> to include the repeating parts. <tt>&lt;!--#include virtual--&gt;</tt> has several advantages over <tt>&lt;!--#include file--&gt;</tt> in that it allows for content-negotiation, execution of dynamic content etc., but here the only place were it holds an advantage is in the inclusion of <tt>/inc/alt-lang.phtml</tt>. <tt>alt-lang.phtml</tt> is a messy PHP script that figures out which language variants of a page are available and displays a selection of alternative language versions (variants with a language different from the current).</p>

<h3>SSI and caching</h3>

<p>Without the <A href="http://httpd.apache.org/docs/1.3/mod/mod_include.html#xbithack">XBitHack directive</a> set to <tt>full</tt>, all content handled by <tt>mod_include</tt> is sent without a <tt>Last-Modified</tt> header. However, I don&#8217;t want to use <tt>XBitHack</tt> at all, because I don&#8217;t want just any executable file to be handled by <tt>mod_include</tt>; that just too much of a … hack.</p>

<p>If I were to do something similar now, I&#8217;d use some kind of (sed) substitution to pre-process the includes locally so that more of what I end up uploading is simple static content. The dynamic part of the included PHP script, I would simply replace with JavaScript.</p>

<h2 id="visual">Visual design</h2>

<p>As you can see in the HTML example, there&#8217;s hardly anything layout oriented in the HTML source. This is good, and means that I have to touch only the CSS for most minor and major lay-out modifications. (It is a pipe-dream to think that you only need to change the CSS to make the same HTML page look however you want as long as that HTML is rich enough in meaning, but for a site with pages of such simple structure, it&#8217;s a dream that comes pretty close to reality.)</p>

<p>I&#8217;m not much of a designer, but I think design is overrated anyway. Actually, I think that most website suffer from too much design.</p>

<div id="attachment_692" class="wp-caption alignright" style="width: 275px"><img src="http://blog.bigsmoke.us/uploads/2009/07/ecosafe-logo.jpg" alt="The EcoSafe logo" title="EcoSafe logo" width="265" height="217" class="size-full wp-image-692" /><p class="wp-caption-text">The EcoSafe logo</p></div>

<p>To start the design, I got a logo made by <a href="http://wiki.hardwood-investments.net/Huite_Zijlstra">Huite Zijlstra</a>. Because the logo was pretty big and didn&#8217;t look good scaled down, I decided to put it at the left of the content area instead of at the top. This would still leave enough room for the menu (which actually takes less space horizontally than the logo).</p>

<h3 id="colors">Colors</h3>

<p>For the color scheme, I just picked a few colors from the logo. As always, the base of the scheme would be black text on a white background for maximum readability. The print version hardly uses any colors.</p>

<pre class="css"><span style="color: #a1a100;">@media screen {</span>
body            <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span>: <span style="color: #993333;">white</span>;  <span style="color: #66cc66;">&#125;</span>
*               <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #000000; font-weight: bold;">black</span>;             <span style="color: #66cc66;">&#125;</span>
a<span style="color: #3333ff;">:link </span>         <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span>: #<span style="color: #cc66cc;">585</span>;              <span style="color: #66cc66;">&#125;</span>
h1              <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span>: #<span style="color: #cc66cc;">880</span>;              <span style="color: #66cc66;">&#125;</span>
h2              <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span>: #<span style="color: #cc66cc;">888</span>;              <span style="color: #66cc66;">&#125;</span>
strong          <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span>: #a62;              <span style="color: #66cc66;">&#125;</span>
#menu li a      <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span>: #<span style="color: #cc66cc;">660</span>;              <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>

<h3 id="underlines">Underlines</h3>

<p>I wanted an underline below the level 1 and 2 headings. Because I didn&#8217;t like the effect of <tt>text-decoration:underline</tt> (too thick for <tt>&lt;h2&gt;</tt>s, too dark for <tt>&lt;h1&gt;</tt>s and different from browser to browser) and because <tt>border-bottom</tt> was set too far from the text, I made two simple PNG images that I could <tt>repeat-x</tt> along the bottom edge.</p>

<pre class="css"><span style="color: #a1a100;">@media screen {</span>
h1 <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span>: <span style="color: #993333;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/img/h1-border-bottom.png'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">bottom</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #993333;">repeat-x</span>; <span style="color: #66cc66;">&#125;</span>
h2 <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span>: <span style="color: #993333;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/img/hx-border-bottom.png'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">bottom</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #993333;">repeat-x</span>; <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>

<h3 id="menu">Menu</h3>

<p>The menu is very simple. The markup is part of <tt>inc/left-side.en.html</tt> for the English version and <tt>inc/left-side.nl.html</tt> for the Dutch version:</p>

<pre class="bash">cat inc/left-side.en.html</pre>
<pre class="php">&lt;div id=<span style="color: #ff0000;">&quot;left&quot;</span> lang=<span style="color: #ff0000;">&quot;en&quot;</span>&gt;
  &lt;a <span style="color: #000000; font-weight: bold;">class</span>=<span style="color: #ff0000;">&quot;logo&quot;</span> href=<span style="color: #ff0000;">&quot;/index.en&quot;</span>&gt;&lt;img <span style="color: #000000; font-weight: bold;">class</span>=<span style="color: #ff0000;">&quot;logo&quot;</span> alt=<span style="color: #ff0000;">&quot;[Logo]&quot;</span> src=<span style="color: #ff0000;">&quot;/img/logo.jpg&quot;</span>&gt;&lt;/img&gt;&lt;/a&gt;
&nbsp;
  &lt;ul id=<span style="color: #ff0000;">&quot;menu&quot;</span> <span style="color: #000000; font-weight: bold;">class</span>=<span style="color: #ff0000;">&quot;menu&quot;</span>&gt;
    &lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;/index.en&quot;</span> rel=<span style="color: #ff0000;">&quot;start&quot;</span>&gt;Start page&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;/plantations.en&quot;</span>&gt;For plantations&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;/investors.en&quot;</span>&gt;For investors&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;/history.en&quot;</span>&gt;History&lt;/a&gt;&lt;/li&gt;
    &lt;!--&lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;/goals&quot;</span>&gt;Goals&lt;/a&gt;&lt;/li&gt;--&gt;
    &lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;/methods.en&quot;</span>&gt;How it works&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;/cost-structure.en&quot;</span>&gt;Cost structure&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;/cost-calculator.en&quot;</span>&gt;Cost calculator&lt;/a&gt;&lt;/li&gt;
    &lt;!--&lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;/clients.en&quot;</span>&gt;Clients&lt;/a&gt;&lt;/li&gt;--&gt;
    &lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;/contact.en&quot;</span>&gt;Contact&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
&nbsp;
&lt;script type=<span style="color: #ff0000;">&quot;text/javascript&quot;</span> src=<span style="color: #ff0000;">&quot;/js/menu.js&quot;</span>&gt;&lt;/script&gt;</pre>

<div id="attachment_710" class="wp-caption alignright" style="width: 270px"><img src="http://blog.bigsmoke.us/uploads/2009/07/ecosafe-menu-en.png" alt="The EcoSafe menu (in English)" title="EcoSafe menu EN" width="260" height="438" class="size-full wp-image-710" /><p class="wp-caption-text">The EcoSafe menu (in English)</p></div>

<p>As is customary, I started by removing all the default list styles and made the anchors behave as block-level elements. I used the big O from the logo for bullets in the list (using <tt>background-image</tt> instead of <tt>list-style-image</tt> because the latter gives unpredictable cross-browser results and doesn&#8217;t make the bullet clickable).</p>

<pre class="css"><span style="color: #cc00cc;">#menu <span style="color: #66cc66;">&#123;</span></span>
  <span style="color: #000000; font-weight: bold;">margin-top</span>: 2em;
  <span style="color: #000000; font-weight: bold;">margin-left</span>: 2em;
  <span style="color: #000000; font-weight: bold;">list-style-type</span>: <span style="color: #993333;">none</span>;
  <span style="color: #000000; font-weight: bold;">padding</span>: <span style="color: #cc66cc;">0</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
#menu li <span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">margin</span>: <span style="color: #cc66cc;">0</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
#menu li a <span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span>: <span style="color: #993333;">block</span>;
  <span style="color: #000000; font-weight: bold;">background-image</span>: <span style="color: #993333;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/img/o-21x16.png'</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">background-position</span>: <span style="color: #000000; font-weight: bold;">top</span> <span style="color: #000000; font-weight: bold;">left</span>;
  <span style="color: #000000; font-weight: bold;">background-repeat</span>: <span style="color: #993333;">no-repeat</span>;
  <span style="color: #000000; font-weight: bold;">padding-left</span>: 30px;
  <span style="color: #000000; font-weight: bold;">text-decoration</span>: <span style="color: #993333;">none</span>;
  <span style="color: #000000; font-weight: bold;">font-family</span>: <span style="color: #993333;">sans-serif</span>;
  <span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #993333;">bold</span>;
  <span style="color: #000000; font-weight: bold;">color</span>: #<span style="color: #cc66cc;">660</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
#menu li a:hover,
#menu li<span style="color: #6666ff;">.active </span>a <span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background-image</span>: <span style="color: #993333;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/img/oSafe-21x16.png'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
#menu a<span style="color: #3333ff;">:hover </span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span>: #<span style="color: #cc66cc;">787800</span>;
<span style="color: #66cc66;">&#125;</span></pre>

<h4>JavaScript menu item activation</h4>

<p>To add the <tt>active</tt> class to the currently active list item (<tt>&lt;li&gt;</tt>), I used a client-side solution using JavaScript. After all, it&#8217;s proper use of JavaScript to enhance your user interface with it (as long as, as many would say, it isn&#8217;t <em>required</em> for the UI to function (as it is in the Cost Calculator)).</p>

<pre class="javascript"><span style="color: #009900; font-style: italic;">// menu.js</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> menu = document.<span style="color: #006600;">getElementById</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'menu'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #003366; font-weight: bold;">var</span> anchors = menu.<span style="color: #006600;">getElementsByTagName</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #003366; font-weight: bold;">var</span> locationHref = window.<span style="color: #006600;">location</span>.<span style="color: #006600;">pathname</span>.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span>i = anchors.<span style="color: #006600;">length</span> - <span style="color: #CC0000;">1</span>; i &gt;= <span style="color: #CC0000;">0</span>; i--<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  a = anchors<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
  aHref = a.<span style="color: #006600;">href</span>;
    
  <span style="color: #009900; font-style: italic;">// Does this menu item link to the current page?</span>
  <span style="color: #009900; font-style: italic;">// We find out by looking if the window location contains the URL in the anchor</span>
  <span style="color: #009900; font-style: italic;">// or the other way arround. The reason to look at both is content-negotiation.</span>
  <span style="color: #009900; font-style: italic;">// It's also true if the location is just '/' and we're looking at the anchor of</span>
  <span style="color: #009900; font-style: italic;">// the 'start' page.</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>locationHref === <span style="color: #3366CC;">'/'</span> &amp;&amp; a.<span style="color: #006600;">rel</span> === <span style="color: #3366CC;">'start'</span><span style="color: #66cc66;">&#41;</span> ||
       <span style="color: #66cc66;">&#40;</span>locationHref !== <span style="color: #3366CC;">'/'</span> &amp;&amp; <span style="color: #66cc66;">&#40;</span> locationHref.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span>aHref<span style="color: #66cc66;">&#41;</span> !== <span style="color: #CC0000;">-1</span> ||
                                  aHref.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span>locationHref<span style="color: #66cc66;">&#41;</span> !== <span style="color: #CC0000;">-1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    a.<span style="color: #006600;">parentNode</span>.<span style="color: #006600;">className</span> = <span style="color: #3366CC;">'active'</span>;
    <span style="color: #000066; font-weight: bold;">break</span>;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>

<p>I actually just fixed a long-standing bug that was caused by me not being able to fully rely on HTTP language negotiation for the selection of the appropriate language variant, which made me change all links from being language-neutral to including the language in the link target (e.g.: <tt>http:///history</tt> became <tt>http:///history.en</tt> and <tt>http:///history.nl</tt>), the problem with this being that, instead of being able to link to link to <tt>http:///</tt> (<tt>http://www.stichting-ecosafe.org/</tt>), I had to link to <tt>http:///index.en</tt> or <tt>http:///index.nl</tt>, making it more difficult to detect the active anchor if we&#8217;re requesting the home page through <tt>http:///</tt> instead of on of its language-specific URLs.</p>

<p>The JavaScript rested on the assumption that by reverse iterating through all the anchors in the menu and thus processing the link to <tt>http:///</tt> as last, I&#8217;d know that I had struck the home page and wouldn&#8217;t need to worry that <em>any of the links</em> contain a slash. (I don&#8217;t know if I intended it to work this way, but it sure seems to me now that the only way this could ever have worked was as an apparent side-effect of the looping order; the SVN logs seem to agree.)</p>

<p>I could have solved this by redirecting all requests for <tt>http:///</tt> to the appropriate variant. Maybe I should have (to avoid duplicate content). Instead I chose to add a <tt>rel="start"</tt> attribute to the links to the home page, as can be deduced from the JavaScript above. (To resolve the duplicate content issue, I could also add a <a href="http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html">canonical link</a> to the header of the two language variants.)</p>

<p>Anyway, all this brings me to the messy subject of content negotiation.</p>

<h2 id="content-negotiation">Content and language negotiation</h2>

<p>The EcoSafe website would be bi-lingual (English and Dutch) from the onset. Initially, I wanted to use language negotiation to the extend of having completely language-neutral URLs. For example: <q><tt>http:///cost-calculator</tt></q> instead of <q><tt>http:///cost-calculator.en</tt></q> and <q><tt>http:///cost-calculator.nl</tt></q>. In the end, you can make this work properly in the browser with the help of a cookie, but it&#8217;s still a pipe-dream because nothing else will work if you do not also offer another navigational path to the different variants. Maybe, we&#8217;ll revisit this topic for a later experiment.</p>

<p>Content-type negotiation is almost effortless with Apache thanks to <tt><a href="http://httpd.apache.org/docs/1.3/mod/mod_negotiation.html">mod_negotiation</a></tt>. If, like me, you despise to have <tt>.html</tt>, <tt>.htm</tt>, <tt>.xhtml</tt>, <tt>.phtml</tt>, <tt>.pxhtml</tt>. <tt>.sxhtml</tt>, <tt>.php</tt>, <tt>.xml</tt> in your URL (I actually used all of these at some time or other), you only have to make sure that <tt>MultiViews</tt> is in your options.</p>

<p>I&#8217;ve configured SSI by means of the following instead of a “magic mime-type”:</p>

<pre class="apache"><span style="color: #00007f;">AddType</span>         text/html       .shtml
<span style="color: #00007f;">AddHandler</span>      server-parsed   .shtml
<span style="color: #00007f;">AddCharset</span>      UTF<span style="color: #ff0000;">-8</span>           .shtml
AddOutputFilter <span style="color: #0000ff;">Includes</span>        .shtml</pre>

<p>For PHP I couldn&#8217;t do the same because my web host was still at Apache 1.3. Otherwise, the following should have worked equally well for PHP:</p>

<pre class="apache"><span style="color: #adadad; font-style: italic;"># This doesn't work with Apache 1.3</span>
<span style="color: #00007f;">AddType</span>        text/html       .phtml
<span style="color: #00007f;">AddHandler</span>     php-<span style="color: #00007f;">script</span>      .phtml
<span style="color: #00007f;">AddCharset</span>     UTF<span style="color: #ff0000;">-8</span>           .phtml</pre>

<p>Configuring language priority is easy with Apache:</p>

<h3>Integrating PHP and SSI</h3>

<p>The integration of PHP with all the weirdness that I had configured and created around SSI took some figuring out. Luckily, PHP offers a <a href="http://www.php.net/virtual"><tt>virtual()</tt></a> function that works roughly the same as <tt>mod_include's</tt> <tt>&lt;!--#include virtual--&gt;</tt>. Here&#8217;s an example:</p>

<pre class="php">&lt;body&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <a href="http://www.php.net/virtual"><span style="color: #000066;">virtual</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/inc/left-side.en.html'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span>
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #0000ff;">$uri</span> = <span style="color: #ff0000;">'/cost-calculator.en.phtml'</span>; <span style="color: #b1b100;">include</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'inc/alt-lang.phtml'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span></pre>

<p>In retrospect, it&#8217;s pretty much bullshit to use it. I could have just as well <tt>require()</tt>d the partials (which I actually did for the alternate language selection), but I probably started out using virtual on a more generic URL without language and content-type selection in it.</p>

<h3>406 handling</h3>

<p>Because I deployed on Apache 1.3 and the <tt><a href="http://httpd.apache.org/docs/2.0/mod/mod_negotiation.html#forcelanguagepriority">ForceLanguagePriority</a></tt> directive was only introduced with Apache 2.0.30, I had to write an ugly hack to avoid visitors getting 406 errors. To that end, I added a 406 handler to my <tt>.htaccess</tt> file:</p>

<pre class="apache"><span style="color: #00007f;">LanguagePriority</span> en nl
ForceLanguagePriority Prefer Fallback <span style="color: #adadad; font-style: italic;"># This doesn't work with 1.3</span>
&nbsp;
<span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">406</span> /error<span style="color: #ff0000;">-406</span>.php <span style="color: #adadad; font-style: italic;"># Luckily, this does </span></pre>

<p><tt>error-406.php</tt> is a PHP file that figures out the available variants based on <tt>$_SERVER['REQUEST_URI']</tt>. Then, it simply picks the first one (which works because, accidentally, that&#8217;s the one I&#8217;ve given priority using the <tt><a href="http://httpd.apache.org/docs/1.3/mod/mod_negotiation.html#languagepriority">LanguagePriority</a></tt> directive as well), outputs a 200 OK header instead of the 406, and <tt>virtual()</tt>s the file of the variant. The code looks somewhat like this:</p>

<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<a href="http://www.php.net/chdir"><span style="color: #000066;">chdir</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_SERVER</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'DOCUMENT_ROOT'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$filenames</span> = <a href="http://www.php.net/glob"><span style="color: #000066;">glob</span></a><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/basename"><span style="color: #000066;">basename</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_SERVER</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'REQUEST_URI'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">&quot;.*&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$filename</span> = <span style="color: #0000ff;">$filenames</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
<a href="http://www.php.net/apache_setenv"><span style="color: #000066;">apache_setenv</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'DOCUMENT_URI'</span>, <span style="color: #ff0000;">&quot;/$filename&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<a href="http://www.php.net/header"><span style="color: #000066;">header</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'HTTP/1.1 200 OK'</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/virtual"><span style="color: #000066;">virtual</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;$filename&quot;</span><span style="color: #66cc66;">&#41;</span>;</pre>

<div id="attachment_807" class="wp-caption alignright" style="width: 310px"><a rel="lightbox-ecosafe" href="http://blog.bigsmoke.us/uploads/2009/09/ecosafe-cost-calculator.png"><img src="http://blog.bigsmoke.us/uploads/2009/09/ecosafe-cost-calculator-300x137.png" alt="EcoSafe Cost Calculator" title="www.stichting-ecosafe.org/cost-calculator" width="300" height="137" class="size-medium wp-image-807" /></a><p class="wp-caption-text">EcoSafe Cost Calculator</p></div>

<div id="attachment_808" class="wp-caption alignright" style="width: 194px"><a href="http://blog.bigsmoke.us/uploads/2009/09/ecosafe-cost-calculation.png"><img src="http://blog.bigsmoke.us/uploads/2009/09/ecosafe-cost-calculation-184x300.png" alt="EcoSafe Cost Calculator results" title="EcoSafe cost calculation" width="184" height="300" class="size-medium wp-image-808" /></a><p class="wp-caption-text">EcoSafe Cost Calculator results</p></div>

<h2>The Cost Calculator</h2>

<p>The EcoSafe Cost Calculator is some of the least neatly contained and most procedurally oriented PHP code I&#8217;ve ever produced while knowing full well what I was doing. It does almost everything it does in global scope. Yet, it does it well.</p>

<p>The thing is designed as a dynamic web page rather than a web application. What I mean by this is that it&#8217;s simply two pages (one for English and one for Dutch) using PHP among a number of pages using SSI. In an application, it&#8217;s usual to have just one ‘view’ that is the same for all languages, but here I chose to put the different language versions in different language pages and then include everything reusable (and language-neutral) from within these files.</p>

<p>Most of the actual processing and calculating is done in <tt>inc/costs-functions.php</tt>.  (The part about gotos is a joke. (Labeled blocks would have been quite sufficient. <img src='http://blog.bigsmoke.us/wp-factory/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ))</p>

<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #808080; font-style: italic;"># costs-functions.php - Stuff that's includes by cost-calculator.{nl,en}.phtml</span>
<span style="color: #808080; font-style: italic;">/**
 * Just remember that this code was never meant to be general purpose or anything.
 * So, relaxeeee and keep your OO-axe burried where it belongs.
 * Oh, if only PHP would support GOTO's ... Sigh ...
 */</span></pre>

<p>The rest of the file is just a whole lot of processing of form data and turning it into something that can be easily traversed for display to the user. There are even the function calls without arguments doing all their work on globals. These are actually only added to make it clearer <em>em</em> a piece of code is doing. And—I must say—after a few years it&#8217;s still remarkably clear to me what each part of the code is doing. There&#8217;s no deep, confusing nesting structures or anything. There&#8217;s just a whole lot of very simple code.</p>

<h3>Some simple AHAH increases form interactivity</h3>

<p>Users of the calculator can add any number of plantings and locations. When the user decides to add a planting or a location, the <tt>onClick</tt> event triggers the execution of <tt>addExtraPlanting()</tt> or <tt>addExtraLocation()</tt>. Here&#8217;s how <tt>addExtraPlanting()</tt> looks:</p>

<pre class="javascript"><span style="color: #003366; font-weight: bold;">function</span> addExtraPlanting<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  lang = document.<span style="color: #006600;">documentElement</span>.<span style="color: #006600;">lang</span>;
&nbsp;
  <span style="color: #003366; font-weight: bold;">new</span> Ajax.<span style="color: #006600;">Updater</span><span style="color: #66cc66;">&#40;</span>
    <span style="color: #3366CC;">'plantings'</span>, <span style="color: #3366CC;">'/inc/planting.'</span> + lang, <span style="color: #66cc66;">&#123;</span>
      method: <span style="color: #3366CC;">'get'</span>,
      insertion: Insertion.<span style="color: #006600;">Bottom</span>
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre>

<p><a href="http://api.prototypejs.org/ajax/ajax/updater.html"><tt>Ajax.Updater</tt></a> comes from the <a href="http://www.prototypejs.org/">Prototype JavaScript framework</a>.</p>

<p>Here&#8217;s what <tt>inc/planting.en.phtml</tt> looks like. The same file is also included in a loop to rebuild the form&#8217;s state after submitting.</p>

<pre class="php">&lt;li&gt;
  &lt;input name=<span style="color: #ff0000;">&quot;num_hectares[]&quot;</span> type=<span style="color: #ff0000;">&quot;text&quot;</span> size=<span style="color: #ff0000;">&quot;5&quot;</span> value=<span style="color: #ff0000;">&quot;&lt;?php echo $num_hectares ?&gt;&quot;</span> /&gt;
&nbsp;
  hectares have been planted in
&nbsp;
  &lt;select name=<span style="color: #ff0000;">&quot;plant_years[]&quot;</span>&gt;&lt;?php <span style="color: #b1b100;">require</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'planting_options.php'</span><span style="color: #66cc66;">&#41;</span> ?&gt;&lt;/select&gt;
&nbsp;
  <span style="color: #66cc66;">&#40;</span>&lt;a title=<span style="color: #ff0000;">&quot;Remove this planting&quot;</span> href=<span style="color: #ff0000;">&quot;#&quot;</span> onclick=<span style="color: #ff0000;">&quot;removePlanting(this); return false;&quot;</span>&gt;x&lt;/a&gt;<span style="color: #66cc66;">&#41;</span>
&lt;/li&gt;</pre>

<p>I think that I&#8217;ve gone into small enough detail by now to get to the conclusion. Also showing the contents of <tt>planting_options.php</tt> would be pushing it. Ah, well…</p>

<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> !<a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this_year</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">$this_year</span> = <a href="http://www.php.net/intval"><span style="color: #000066;">intval</span></a><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/date"><span style="color: #000066;">date</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Y'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> !<a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$plant_year</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">$plant_year</span> = <span style="color: #0000ff;">$this_year</span>;
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$i</span> = <span style="color: #0000ff;">$this_year</span>; <span style="color: #0000ff;">$i</span> &gt;= <span style="color: #0000ff;">$this_year</span> - <span style="color: #cc66cc;">20</span>; <span style="color: #0000ff;">$i</span>--<span style="color: #66cc66;">&#41;</span>
  <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;&lt;option&quot;</span> . <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$i</span> == <span style="color: #0000ff;">$plant_year</span> ? <span style="color: #ff0000;">&quot; selected='1'&quot;</span> : <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">&quot;&gt;$i&lt;/option&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;</pre>

<p>(Yesterday, I couldn&#8217;t resist the temptation of turning this into a simple file to <tt>require()</tt> instead of the function definition it was. I think it&#8217;s funny to refactor something to <em>remove</em> encapsulation.)</p>

<h2>Conclusion</h2>

<p>As is usual when looking at old code, I see many things that I&#8217;d do (even just a little) different today, but I saw a surprising number of solutions that I actually still like now that I see them back after three years. Removing some of the remaining warts probably won&#8217;t do much good besides the masturbatory satisfaction it could give me. (It&#8217;s likely that the website won&#8217;t live much longer, making such extra attention very undeserved.) But, nevertheless, I&#8217;ve enjoyed blogging about it now to recoup the whole experience and to at least <em>look</em> at what I&#8217;d do different now and what I learned in the meantime.</p>

<h2>Some links</h2>

<ul>
  <li><a href="http://www.w3.org/TR/html401/types.html#type-links">The HTML spec. on <cite>Link types</cite></a></li>
  <li><a href="http://www.stichting-ecosafe.org/">The EcoSafe website</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2009/09/16/www.stichting-ecosafe.org/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VIM tips for editing prose</title>
		<link>http://blog.bigsmoke.us/2009/09/07/vim-tips-for-editing-prose</link>
		<comments>http://blog.bigsmoke.us/2009/09/07/vim-tips-for-editing-prose#comments</comments>
		<pubDate>Mon, 07 Sep 2009 10:20:47 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[tex]]></category>
		<category><![CDATA[VIM]]></category>
		<category><![CDATA[X]]></category>
		<category><![CDATA[XKB]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=764</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>I was transcribing a draft for a manuscript. Using VIM, of course. But, I found my VIM skills to be lacking somewhat, enough to become sufficiently annoyed to investigate the holes.</p>

<h2>Word wrapping</h2>

<p>The first thing that I wanted to learn to remember was how to control word wrapping and, especially, how to <em>rewrap</em> text.</p>

<p>I had noticed already that on my current machine, VIM enables word wrapping by default for <tt>.txt</tt> files. I liked this, except I had forgotten long ago (or never properly remembered) how to rewrap lines. This can be done with <kbd>gq</kdb>. <kbd>gq</kbd> operates on the current selection or on the argument (a number of words/characters/sentences/paragraphs/etc).</p>

<p>Soon, I decided to turn my <tt>.txt</tt> into a simple TeX file (to be able to add annotations using TeX comments). This disabled the word wrapping, so I had to find the setting to control this. There's actually two settings:</p>

<ul>
  <li><tt>wrapmargin</tt> defines how close the text may approach the right edge of the VIM window before it starts wrapping,</li>
  <li>whereas <tt>textwidth</tt> tells VIM to start wrapping when a fixed number of characters is approached.</li>
</ul>

<p>Because VIM doesn't do wrapping by default for <tt>.tex</tt> files, I added the following <a href="http://blog.bigsmoke.us/2008/08/21/per-file-vim-configuration-with-modeline">modeline</a> to the bottom of my draft:</p>

<pre class="php">% vim: set textwidth=<span style="color: #cc66cc;">80</span> spelllang=nl:</pre>

<p>Note that I find 80 characters way too small for most programming tasks, but very convenient as a width for reading prose from a screen. On occasion, I've even used <tt>width: 80ex;</tt> in the CSS of a website.</p>

<h2>Sentences and paragraphs</h2>

<p>A few movement commands that I've never used enough to remember well are <kbd>{</kbd>/<kbd>}</kbd> and <kbd>(</kbd>/<kbd>)</kbd>. <kbd>}</kbd> and <kbd>{</kbd> are used to move a paragraph forward or backward, respectively;<kbd>)</kbd> and </kbd>(</kbd> are used to move a whole sentence forward or backward. This is particularly useful while editing prose.</p>

<p>To quickly select a paragraph, for example, you can easily move to the beginning of the paragraph using <kbd>{</kbd>, press <kbd>v</kbd> to start a selection and go to the end of the paragraph with <kbd>}</kbd> (or type <kbd>2}</kbd> to also select the next).</p>

<p>If you want to delete a sentence, go to the start of the sentence (using either <kbd>(</kbd> or <kbd>)</kbd>) and type <kbd>d)</kbd>. It's as easy as that.</p>

<p>If deleting the sentence fucked up the formatting of your paragraph, reformat by going to the beginning of the paragraph and typing <kbd>gq}</kbd>.</p>

<h2>Proper punctuation and other special characters</h2>

<p>TeX offers a method to construct special characters using plain ASCII source files. In the past, in my inability to properly configure everything for UTF-8, I've often made use of this. In TeX, <tt>\'e</tt> will be turned into <tt>é</tt>, <tt>\"i</tt> into <tt>ï</tt>, etc. This can be convenient, but it's much more convenient to have an environment that's properly configured for UTF-8. To enter special characters on my US keyboard layout (standard in The Netherlands), I've added <tt>compose:ralt</tt> to my XKB options. Using this option I can press <kbd>Right Alt</kbd> followed by a punctuation character, followed by a character to combine it with.</p>

<p>Clearly, constructing special characters on the level of X holds many advantages over having to do this differently for each and every application. This way I can also type in <kbd>ë</kbd> in this HTML <tt>&lt;textarea&gt;</tt> instead of having to type <kbd>&amp;euml;</kbd>. (In HTML, it's actually better to use a numeric character reference, such as <kbd>&amp;#235;</kbd> instead of <kbd>&amp;euml;</kbd>, because that doesn't require the loading of the DTD, but that's another rant altogether.)</p>

<p>If you don't have an accommodating XKB configuration, it's still possible to enter the characters directly at the VIM level. In VIM, <kbd>:help digraph</kbd> (see also the <a href="http://www.vim.org/htmldoc/digraph.html">on-line HTML version</a>) tells you everything about it. In short, use <kbd>Control+K</kbd> followed by a punctuation character, followed by a character to compose special characters in a way similar to X.</p>

<p>What's very nice about VIM's default setup is that it allows you to also easily create proper opening and closing single and double quotes. In TeX these are traditionally done using combinations of back-ticks (<kbd>`</kbd>) and apostrophes (<kbd>'</kbd>). TeX's default behavior can be <a href="http://randomdeterminism.wordpress.com/2009/05/15/quote-backtick-and-unicode-engine/">problematic</a>, a good reason to switch to Unicode.</p>

<table>
<tr><th>char.</th><th>VIM digraph</th><th>TeX</th></tr>
<tr><td><kbd>“</kbd></td><td><kbd>Ctrl+K, ", 6</kbd></td><td><kbd>``</kbd></td></tr>
<tr><td><kbd>”</kbd></td><td><kbd>Ctrl+K, ", 9</kbd></td><td><kbd>''</kbd></td></tr>
<tr><td><kbd>‘</kbd></td><td><kbd>Ctrl+K, ', 6</kbd></td><td><kbd>`</kbd></td></tr>
<tr><td><kbd>’</kbd></td><td><kbd>Ctrl+K, ', 9</kbd></td><td><kbd>'</kbd></td></tr>
</table>

<p>Something else that becomes very easy with VIM's digraphs is entering proper punctuation characters, such as em/en dashes. These are done by following <kbd>Ctrl+K</kbd> with a hyphen and a capital N or M. In TeX these could already be done by simply entering two or three hyphens, but if you prefer it that way, you're probably better of with the <a href="http://henry.precheur.org/2008/9/22/Unicycle,_a_Vim_plugin_for_typography_junkies.html">UniCycle plugin for VIM</a>, which I personally don't dig. Anyway, you're <a href="http://bemusement.org/diary/2007/January/15/em-dash">running out of excuses</a> to let <kbd>--</kbd> appear in your production documents.</p>

<table>
<tr><th>char.</th><th>VIM digraph</th><th>TeX</th></tr>
<tr><td>–</td><td><kbd>Ctrl+K, -, N</kbd></td><td><kbd>--</kbd></td></tr>
<tr><td>—</td><td><kbd>Ctrl+K, -, M</kbd></td><td><kbd>---</kbd></td></tr>
</table>

<p>I have to admit that I've waited an awful long time before finding this out. I'm ashamed to tell you that I've often gone to <a href="http://www.alanwood.net/unicode/">Alan Wood's Unicode resources</a> to look up a character and copy/paste it into an application. <img src='http://blog.bigsmoke.us/wp-factory/wp-includes/images/smilies/icon_redface.gif' alt=':oops:' class='wp-smiley' />  Now, at least I don't have to further embarrass myself when I'm using VIM.</p>

<p>What remains is to configure XKB in such a way that I don't need to use VIM digraphs for punctuation. Then I will no longer need to use character references for punctuation at times like these, when I'm typing HTML/XML outside of VIM (or, worse, using copy/paste from VIM into this <tt>&lt;textarea&gt;</tt>, which I just did <img src='http://blog.bigsmoke.us/wp-factory/wp-includes/images/smilies/icon_redface.gif' alt=':oops:' class='wp-smiley' /> ). Let's see if I can get XKB to compose these using the same combinations as VIM. That is <a href="http://madduck.net/docs/extending-xkb/">where</a> I'll continue my quest next time.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2009/09/07/vim-tips-for-editing-prose/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customizing Google AdSense alternate ads</title>
		<link>http://blog.bigsmoke.us/2009/06/10/adsense-alternate-ads</link>
		<comments>http://blog.bigsmoke.us/2009/06/10/adsense-alternate-ads#comments</comments>
		<pubDate>Wed, 10 Jun 2009 14:46:44 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[AdSense]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Schuilplaats]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=597</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>When AdSense runs out of inspiration (i.e.: no targeted ads are available), it displays public service ads by default. You can choose to replace this with a custom ad of your own choosing. To do this, you have to put a HTML page somewhere and change the alternate ads settings for the appropriate ad unit:</p>

<div id="attachment_600" class="wp-caption alignnone" style="width: 631px"><img src="http://blog.bigsmoke.us/uploads/2009/06/adsense-unit-alternate-ads-settings-for-hardhoutwiki-leaderboard.jpeg" alt="AdSense unit: alternate ads settings for HardhoutWiki leaderboard" title="AdSense unit: alternate ads settings for HardhoutWiki leaderboard" width="621" height="128" class="size-full wp-image-600" /><p class="wp-caption-text">Alternate ads settings for HardhoutWiki leaderboard AdSense unit</p></div>

<p>Instead of the public service ads, I wanted to serve a banner ad to promote our beautiful family vacation home. I created this image a few years ago for an AdWords campaign started by my uncle because he wanted to reach more potential vacation goers.</p>

<div id="attachment_598" class="wp-caption alignnone" style="width: 738px"><img src="http://blog.bigsmoke.us/uploads/2009/06/schuilplaats-banner-ad.jpg" alt="Schuilplaats banner ad" title="Schuilplaats banner ad" width="728" height="79" class="size-full wp-image-598" /><p class="wp-caption-text">The 728x79 banner image</p></div>

<p>I put put up a page with the image at <tt>http://www.bigsmoke.us/schuilplaats-banner-ad/</tt>. The HTML is very simple:</p>

<pre class="php">&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
    &lt;a href=<span style="color: #ff0000;">&quot;http://www.hugovandermolen.nl/schuilplaats/startpagina.php&quot;</span>&gt;&lt;img src=<span style="color: #ff0000;">&quot;schuilplaats-banner-ad.jpg&quot;</span> /&gt;&lt;/a&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>

<p>If anyone wants to promote our vacation home for free, all they have to do is to change <i>Alternate ads or colors</i> to <q>Show non-Google ads from another URL</q> and fill in <q><tt>http://www.bigsmoke.us/schuilplaats-banner-ad/</tt></q>.</p>

<p>Although I put the alternate ad up over a year ago, I was prompted to blog about it because two months ago, for the first time, I suddenly saw the ad actually being serviced on my Dutch HardwoodWiki:</p>

<div id="attachment_608" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.bigsmoke.us/uploads/2009/06/hardhout-wiki-met-schuilplaats-ad.jpeg" title="The alternate ad in action" rel="lightbox"><img src="http://blog.bigsmoke.us/uploads/2009/06/hardhout-wiki-met-schuilplaats-ad-300x200.jpg" alt="The alternate ad in action" title="Dutch HardwoodWiki with Schuilplaats ad" width="300" height="200" class="size-medium wp-image-608" /></a><p class="wp-caption-text">The alternate ad in action</p></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2009/06/10/adsense-alternate-ads/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Finding a decent GeSHi plugin for WordPress</title>
		<link>http://blog.bigsmoke.us/2009/04/13/wordpress-geshi-plugin</link>
		<comments>http://blog.bigsmoke.us/2009/04/13/wordpress-geshi-plugin#comments</comments>
		<pubDate>Mon, 13 Apr 2009 14:03:59 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[BigSmoke.US]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[BBCode]]></category>
		<category><![CDATA[GeSHi]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=310</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>I like <a href="http://qbnz.com/highlighter/">GeSHi</a> (enough even to have written a <a href="http://geshi.svn.sourceforge.net/viewvc/geshi/trunk/geshi-1.0.X/src/geshi/bnf.php">language file</a> for it). For ages now, I&#8217;ve used a WordPress plugin by Dan Peverill. But for as long as I&#8217;ve been using the plugin, I&#8217;ve been looking to get rid of it.</p>

<p>Dan Peverill&#8217;s GeSHI plugin sucks for two reasons:</p>
<ol>
  <li>It&#8217;s no longer being maintained. It doesn&#8217;t even seem to justify a page on Dan&#8217;s website anymore (for which reason I&#8217;m not going to give him any link-juice).</li>
  <li>It breaks HTML. With the plugin enabled I can no longer use the <tt>&lt;code&gt;</tt> tag to mark in-line elements as being <em>code</em>. Frankly, this is annoying and I find myself typing <tt>&lt;tt&gt;</tt> often when I mean <tt>&lt;code&gt;</tt>.</li>
</ol>

<p>A search for <a href="http://wordpress.org/extend/plugins/tags/geshi">WordPress plugins tagged <q>GeSHi</q></a> reveals a number of results:  <a href="http://wordpress.org/extend/plugins/sniplets/">Sniplets</a>, <a href="http://wordpress.org/extend/plugins/codecolorer/">CodeColorer</a>, <a href="http://wordpress.org/extend/plugins/devformatter/">Developer Formatter</a>, and <a href="http://wordpress.org/extend/plugins/wp-synhighlight/">WP-SynHighlight</a>. <a href="http://wordpress.org/extend/plugins/wp-syntax/">WP-Syntax</a> is a plugin that is missing from the tag search.</p>

<p><strong>Sniplets</strong> seems much too generic to my taste. I just want a GeSHi highlighter, period.</p>

<p><strong>CodeColorer</strong> says it does what I want, but if I ever want to use the TinyMCE editor again, I won&#8217;t be able to with this plugin. Shouldn&#8217;t be too much of a problem, but still&#8230;</p>

<p><strong>Developer Formatter</strong> is very thoroughly written and even sports a TinyMCE plug-in for copying/pasting the code. It is pretty big, though, and, as a rule, I tend to avoid plug-ins that complicate the database schema. I also don&#8217;t really see how these extra tables are an advantage feature-wise.</p>

<p><strong>WP-SynHighlight</strong> uses a custom BBCode-style tag, <tt>&#x5B;codesyntax]</tt> I like this (if you&#8217;re going to use pointy brackets, at least keep out of the HTML namespace), though I don&#8217;t like the attempt at a generic name; what&#8217;s wrong with calling the tag <tt>[geshi]</tt>? Seriously&#8230; I&#8217;m sure I&#8217;m going to forget this name billions of times if I&#8217;ll use this plug-in.</p>

<p><strong>WP-Syntax</strong> uses the <tt>&lt;pre&gt;</tt> tag with a few custom attributes. This at least is better than the <strong>officially inline</strong> <tt>&lt;code&gt;</tt> tag that my current plugin uses, because most of the time that I&#8217;d use a <tt>&lt;pre&gt;</tt> tag I really do want syntax highlighting. Just wondering: will it also allow my to use it normally for that other rare occasion? Sadly, the plugin <em>will</em> doubtlessly wreak havoc with the visual (TinyMCE) editor.</p>

<p>So, which plugin will I choose? I am somehow inclined to want a plugin that <em>can</em> play nice with the visual editor because I keep telling myself how much nicer it would be to switch to the visual editor for all my posting. (That this will be difficult because I disabled WP&#8217;s &#8216;<tt>wpautop</tt>&#8216; filter to rid myself of its eagerness is a story for some later time.) This requirement rules out CodeColorer and WP-Syntax.</p>

<p>That leaves Developer Formatter and WP-SynHighlight. Both seem to fit my purpose. Developer Formatter sports a nice TinyMCE plugin for inserting code, but I don&#8217;t think that switching to TinyMCE will suddenly and unexpectedly make me afraid of typing. Besides, I really don&#8217;t want the extra tables in my database without a very good reason, so, for now, I will try <a href="http://wordpress.org/extend/plugins/wp-synhighlight/">WP-SynHighlight</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2009/04/13/wordpress-geshi-plugin/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New theme</title>
		<link>http://blog.bigsmoke.us/2008/07/13/new-theme</link>
		<comments>http://blog.bigsmoke.us/2008/07/13/new-theme#comments</comments>
		<pubDate>Sun, 13 Jul 2008 15:26:45 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[BigSmoke.US]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Gravatar]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=87</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>
After upgrading to WordPress 2.5.x, I had to fall back on a stock theme because my old customization of the <a href="http://www.plaintxt.org/themes/sandbox/">Sandbox</a> theme no longer worked with the upgrade. But, then, it was time to redo my theme anyway. So here you&#8217;re looking at the first version of my new theme. I might have let it stabilize some more before putting it on-line, but who cares? My reader maybe? Let&#8217;s just hope he or she doesn&#8217;t use IE. <img src='http://blog.bigsmoke.us/wp-factory/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<a title="The header with a single post below" href='http://blog.bigsmoke.us/uploads/2008/07/new-theme-cap1.jpg' rel='lightbox[theme]'><img src="http://blog.bigsmoke.us/uploads/2008/07/new-theme-cap1-300x193.jpg" alt="Screencap of my new WP theme" title="New WordPress theme for BigSmoke" width="300" height="193" class="alignright size-medium wp-image-89" /></a>

<a title="The oversized footer with all the site-wide navigation" href='http://blog.bigsmoke.us/uploads/2008/07/new-theme-cap4.jpg' rel='lightbox[theme]'><img src="http://blog.bigsmoke.us/uploads/2008/07/new-theme-cap4-300x201.jpg" alt="Screencap of my new WP theme" title="New WordPress theme for BigSmoke" width="300" height="201" class="alignright size-medium wp-image-92" /></a>

<a title="The box of relations below a single post with links to all kinds of lists at the left and some direct links to chronologically related posts" rel='lightbox[theme]' href='http://blog.bigsmoke.us/uploads/2008/07/new-theme-cap3.jpg'><img src="http://blog.bigsmoke.us/uploads/2008/07/new-theme-cap3-300x112.jpg" alt="Screencap of my new WP theme" title="New WordPress theme for BigSmoke" width="300" height="112" class="alignright size-medium wp-image-91" /></a>

<a title="This is how lists of posts look" href='http://blog.bigsmoke.us/uploads/2008/07/new-theme-cap5.jpg' rel='lightbox[theme]'><img src="http://blog.bigsmoke.us/uploads/2008/07/new-theme-cap5-300x207.jpg" alt="Screencap of my new WP theme" title="New WordPress theme for BigSmoke" width="300" height="207" class="alignright size-medium wp-image-93" /></a>

<a title="The bottom part of a single post with some comments below" href='http://blog.bigsmoke.us/uploads/2008/07/new-theme-cap2.jpg' rel='lightbox[theme]'><img src="http://blog.bigsmoke.us/uploads/2008/07/new-theme-cap2-300x193.jpg" alt="Screencap of my new WP theme" title="New WordPress theme for BigSmoke" width="300" height="193" class="alignright size-medium wp-image-90" /></a>

<h2>Vertical navigation</h2>

<p>Ever since the first time that I saw a blog which featured vertical navigation instead of the typical columns, I&#8217;ve wanted to implement this for myself. Well, finally&#8230;</p>

<p>Site-wide elements use the complete width of the page. The page content is centered in the middle at 87.5%.  The identity stuff in the header and the navigation in the footer sits against a back blackground while the content area has the proven black on white for easy reading. I hope that the strong color-contrast as well as the clear difference in with between site-wide elements and page content makes it easy to keep focused on either reading or navigating without distractions.</p>

<h2>&#8230; and a talkative footer</h2>

<p>With this theme, I didn&#8217;t want another footer which consist of the odd logo and some loose copyright statements. I wanted a footer which you can actually read, even understand. And who cares if it takes up a little space? It&#8217;s at the bottom of the page.</p>

<h2>Related posts</h2>

<p>I&#8217;ve written an (unpublished, unpolished) plug-in which can generate a list of posts that are chronologically related. Traditionally, most blogs have a next/previous post link at the top and bottom of each post. This works very well if you limit your blog to one subject (which is really a very good idea anyway), but if, like mine, your blog is a little bit messy, you could say that someone who stumbled here searching for an article about <a href="/tag/subversion">Subversion</a> is not necessarily interested in the next post if this is a <a href="http://blog.bigsmoke.us/2007/07/29/linde-smiling-the-most-amazing-smile">photo of my baby niece</a>.</p>


<p>Hence the chronologically related posts plugin. With this plugin I can say wether I want a link to the first, previous and next post in the blog, within the same category, or matching a given number of tags. (The tag matching isn&#8217;t implemented yet, though. Also, matching on meta fields would be a kick-ass ass way to support explicit sequences.)</p>

<p>I put the list generated by this plug-in on top of a blue background besides the various context links of the post.</p>

<h2>Issues left</h2>

<p>I hope to have the first major revision of my theme ready soon. Here&#8217;s a list of some issues that I might address:</p>

<ul>
<li>The CSS renders a bit psychedelically in MSIE 6 (only version I tested) at the moment. Sigh&#8230; Let&#8217;s just hope that IE 7 will give better results. Then I&#8217;ll gladly drop the IE 6 support.</li>
<li>When viewing a category, the tag cloud in the navigation panel at the bottom only shows tags for that category. This has to do with the use with me calling the <tt>st_tag_cloud()</tt> from within the category template.</li>
<li>Some of the elements that I just showed to you don&#8217;t really look that good and most elements that I <em>didn&#8217;t</em> can be said to be &#8230; hideously ugly. <img src='http://blog.bigsmoke.us/wp-factory/wp-includes/images/smilies/icon_confused.gif' alt=':-?' class='wp-smiley' />  Some highlights: the header (should really be a few cool images), the comment form, and the Next/Previous Page links.</li>
</ul>

<h2>Comment!</h2>

<p>I&#8217;d almost forget all about the clean, new look of the comment list. And, if you register a <a href="http://www.gravatar.com/">Gravatar</a>, your comments will be accompanied by your avatar. Try it. Please!</p>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2008/07/13/new-theme/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Jeroen Dekker (photography) on-line</title>
		<link>http://blog.bigsmoke.us/2007/05/30/jeroen-dekker.com</link>
		<comments>http://blog.bigsmoke.us/2007/05/30/jeroen-dekker.com#comments</comments>
		<pubDate>Tue, 29 May 2007 23:02:19 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[Familiars]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[WWW]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/2007/05/30/jeroen-dekker.com</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a href="http://jeroen-dekker.com/">Jeroen Dekker</a>, a friend and photographer, has recently, on May the 5th, put his website on <a href="http://jeroen-dekker.com/">concert photography</a> on-line. (Go check it out! He has some great pictures there.)</p>

<p>I was very flattered when I was asked by Jeroen to give some <abbr title="Search Engine Optimization">SEO</abbr> advice in the test stage of his website. I was even happier when I saw how well he had implemented my suggestions. In his concert photography section, he now has links consisting of the event name and the band name and the number of the photo. An example URL: <a href="http://jeroen-dekker.com/concerts/noordschok-2007/prey-band/1/">http://jeroen-dekker.com/concerts/noordschok-2007/prey-band/1/</a>. Also his page titles follow the same structure. As is often the case with <abbr title="Search Engine Optimization">SEO</abbr>, the best results are acquired by remembering that good URLs are URLs which are cool enough that you won&#8217;t want to change the in the future and that good titles are titles which look good anywhere, be it in a bookmark or a search result.</p>

<p>
<a rel='lightbox[jeroen-dekker]' href='http://blog.bigsmoke.us/uploads/2007/05/jeroen-dekker-concerts.jpg' title='Jeroen Dekker concert photography'><img src='http://blog.bigsmoke.us/uploads/2007/05/jeroen-dekker-concerts.thumbnail.jpg' alt='Jeroen Dekker concert photography' /></a>

<a rel='lightbox[jeroen-dekker]' href='http://blog.bigsmoke.us/uploads/2007/05/jeroen-dekker-news.jpg' title='Jeroen Dekker news'><img src='http://blog.bigsmoke.us/uploads/2007/05/jeroen-dekker-news.thumbnail.jpg' alt='Jeroen Dekker news' /></a>
</p>

<p>I also noticed that, following some evangelizing on semantics and CSS from me, he had greatly cleaned up the HTML markup. Some pages could still profit from some <del>better</del><ins>more pedantic</ins> markup though. An example from the news section (cleaned up for readability):</p>

<pre class="php">&lt;p&gt; The following bands played:&lt;br&gt;
 - &lt;a href=<span style="color: #ff0000;">&quot;http://jeroen-dekker.com/concerts/fear-dark-festival-hedon-12-mei-2007/eluveitie-band/&quot;</span>&gt;Eluveitie&lt;/a&gt;&lt;br&gt;
 - &lt;a href=<span style="color: #ff0000;">&quot;http://jeroen-dekker.com/concerts/fear-dark-festival-hedon-12-mei-2007/thy-majestie-band/&quot;</span>&gt;Thy  Majestie&lt;/a&gt;&lt;br&gt;
 - &lt;a href=<span style="color: #ff0000;">&quot;http://jeroen-dekker.com/concerts/fear-dark-festival-hedon-12-mei-2007/drottnar-band/&quot;</span>&gt;Drottnar&lt;/a&gt;&lt;br&gt;
&nbsp;
 - &lt;a href=<span style="color: #ff0000;">&quot;http://jeroen-dekker.com/concerts/fear-dark-festival-hedon-12-mei-2007/whispering-gallery-band/&quot;</span>&gt;Whispering Gallery&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;</pre>

<p>In my opinion, the above is a <em>very</em> awkward way to define what is really an unordered list:</p>

<pre class="php">&lt;p&gt;The following bands played:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;http://jeroen-dekker.com/concerts/fear-dark-festival-hedon-12-mei-2007/eluveitie-band/&quot;</span>&gt;Eluveitie&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;http://jeroen-dekker.com/concerts/fear-dark-festival-hedon-12-mei-2007/thy-majestie-band/&quot;</span>&gt;Thy  Majestie&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;http://jeroen-dekker.com/concerts/fear-dark-festival-hedon-12-mei-2007/drottnar-band/&quot;</span>&gt;Drottnar&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;http://jeroen-dekker.com/concerts/fear-dark-festival-hedon-12-mei-2007/whispering-gallery-band/&quot;</span>&gt;Whispering Gallery&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>

<p>Finally, a nice touch that I noticed on his site is that he doesn&#8217;t have explicit pagination. By this I mean that clicking on the page 2 link simply takes you to the first photo on that page, so that he needs only an URL for each photo and not an URL for each page or even photoset.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2007/05/30/jeroen-dekker.com/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Automatic resizing of an HTML &lt;textarea&gt; element</title>
		<link>http://blog.bigsmoke.us/2007/02/18/automatic-html-textarea-resizing</link>
		<comments>http://blog.bigsmoke.us/2007/02/18/automatic-html-textarea-resizing#comments</comments>
		<pubDate>Sun, 18 Feb 2007 19:44:55 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[behaviour]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/2007/02/18/automatic-html-textarea-resizing</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>Today, while improving the Rails GUI for the Sicirec database, I was struck once again by how annoyingly small <tt>&lt;textarea&gt;</tt>s can be when having the user type lots of text.</p>

<p>I had already seen the ideal solution when commenting on <a href="http://laurelin.waarbenjij.nu/">Laurelin&#8217;s waarbenjij.nu weblog</a>. Although their response box is much too narrow, the height of the box auto-adjusts to the amount of text typed. I decided to <q>borrow</q> their code and amend it slightly for our own use. Differences are:</p>

<ul>
  <li>My code works with Opera, but is untested in IE because we don&#8217;t feel the need to support IE for an internal application.</li>
  <li>In our DB, notes will often be shortened, so my code also shrinks the <tt>textarea</tt> when the text shrinks. The function remembers the original number of rows set in the source and will never shrink past that number.</li>
</ul>

<pre class="javascript">userAgentLowerCase = navigator.<span style="color: #006600;">userAgent</span>.<span style="color: #006600;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> resizeTextarea<span style="color: #66cc66;">&#40;</span>t<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span> !t.<span style="color: #006600;">initialRows</span> <span style="color: #66cc66;">&#41;</span> t.<span style="color: #006600;">initialRows</span> = t.<span style="color: #006600;">rows</span>;
&nbsp;
  a = t.<span style="color: #006600;">value</span>.<span style="color: #006600;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #66cc66;">&#41;</span>;
  b=<span style="color: #CC0000;">0</span>;
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span>x=<span style="color: #CC0000;">0</span>; x &lt; a.<span style="color: #006600;">length</span>; x++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>a<span style="color: #66cc66;">&#91;</span>x<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">length</span> &gt;= t.<span style="color: #006600;">cols</span><span style="color: #66cc66;">&#41;</span> b+= Math.<span style="color: #006600;">floor</span><span style="color: #66cc66;">&#40;</span>a<span style="color: #66cc66;">&#91;</span>x<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">length</span> / t.<span style="color: #006600;">cols</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  b += a.<span style="color: #006600;">length</span>;
&nbsp;
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>userAgentLowerCase.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'opera'</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #CC0000;">-1</span><span style="color: #66cc66;">&#41;</span> b += <span style="color: #CC0000;">2</span>;
&nbsp;
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>b &gt; t.<span style="color: #006600;">rows</span> || b &lt; t.<span style="color: #006600;">rows</span><span style="color: #66cc66;">&#41;</span>
    t.<span style="color: #006600;">rows</span> = <span style="color: #66cc66;">&#40;</span>b &lt; t.<span style="color: #006600;">initialRows</span> ? t.<span style="color: #006600;">initialRows</span> : b<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre>

<p>The function can easily be added to the <tt>onkeyup</tt> and <tt>onmouseup</tt> event handlers of a <tt>&lt;textarea&gt;</tt> element as in:</p>

<pre class="php">&lt;textarea cols=<span style="color: #ff0000;">&quot;60&quot;</span> rows=<span style="color: #ff0000;">&quot;4&quot;</span>
          onkeyup=<span style="color: #ff0000;">&quot;resizeTextarea(this)&quot;</span>
          onmouseup=<span style="color: #ff0000;">&quot;resizeTextarea(this)&quot;</span>&gt;&lt;/textarea&gt;</pre>

<p>I didn&#8217;t add it inline as in the example, though. I used Ben Nolan&#8217;s <a href="http://www.bennolan.com/behaviour/">Behaviour Javascript library</a> to tie things together a little more cleanly.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2007/02/18/automatic-html-textarea-resizing/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using the standard HTML link colors</title>
		<link>http://blog.bigsmoke.us/2007/02/02/default-html-link-colors</link>
		<comments>http://blog.bigsmoke.us/2007/02/02/default-html-link-colors#comments</comments>
		<pubDate>Fri, 02 Feb 2007 22:48:42 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[WWW]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/2007/02/02/default-html-link-colors</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>Occasionally, I have to foray into web design. From the look of this blog you can deduce that I&#8217;m not really into the <q>design</q> part of web design. First and foremostly this is because I  suck at graphics and colors. But another reason is that I assume that people visit my blog to read some text and not to look at the fancy graphical borders and background of that text.</p>

<p>Recently I&#8217;ve gotten into the habit of simply using the default HTML link colors instead of trying to come up with a comprehensible color scheme for each design. This means that my links are <strong style="color: blue">blue</strong>, my visited links are <strong style="color: purple">purple</strong> and my active links are <strong style="color: red">red</strong> as in the example CSS snippet below.</p>

<pre class="css">a<span style="color: #3333ff;">:link </span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #000000; font-weight: bold;">blue</span>;     <span style="color: #808080; font-style: italic;">/* #00f */</span>
<span style="color: #66cc66;">&#125;</span>
a<span style="color: #3333ff;">:visited </span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">purple</span>;   <span style="color: #808080; font-style: italic;">/* #800080 */</span>
<span style="color: #66cc66;">&#125;</span>
a<span style="color: #3333ff;">:active </span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">red</span>;      <span style="color: #808080; font-style: italic;">/* #f00 */</span>
<span style="color: #66cc66;">&#125;</span></pre>

<h3>Related links</h3>

<ul>
  <li><cite><a href="http://www.bohmann.dk/articles/against_non_standard_link_colors.html">Against Non-Standard Link Colors</a></cite> by <a href="http://www.bohmann.dk/kristoffer/">Kristoffer Bohmann</a></li>
  <li><cite><a href="http://www.useit.com/alertbox/20040510.html">Guidelines for Visualizing Links</a></cite> by <a href="http://www.useit.com/">Jacob Nielsen</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2007/02/02/default-html-link-colors/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

