2008.04.15

There's a good excellent Ethics Bites interview with Richard Posner on copyright and plagiarism. 2008-04-15T19:06:49ZUntitled entry permalink

The DataPortability.org folks are trying to figure out their new logo. Public voting is now open. I voted for the logos titled with "ics2626" and "phil.franks46". Strangely, after I voted, I didn't seem to get any feedback telling me that I had. If it were a parliamentary election rather than a logo contest on the Web, it'd be time to get concerned. 2008-04-15T18:07:55ZUntitled entry permalink

Just watching Richard Dawkins and Lawrence Krauss discussing evolution, quantum mechanics, science education, religion and tactics in the war against intellectual ineptitude. 2008-04-15T14:04:12ZUntitled entry permalink

Londonist is reporting that God botherers will now be on London buses. Great. Now we have two problems. 2008-04-15T13:52:51ZUntitled entry permalink

Interarchy, my favourite FTP client, has been updated. I really didn't like Interarchy 9, since it seemed to want me to open everything in TextEdit. It's been updated so it works properly. 2008-04-15T11:48:48ZUntitled entry permalink

What, you want consistency from right-wing culture warriors? They are too busy fighting off Hegel and confusing nineteenth-century Russian novelists for communists and lying for Jesus. Then there's that Expelled rubbish still rolling on. Just remember, God's will is not discernible to science, but perfectly understandable if you are a Professor of Theology. Time to bang one's head against a desk in frustration? Yeah, getting close. 2008-04-15T11:24:14ZUntitled entry permalink

Publishing XHTML with Webby, Rake and Apache 2008-04-15T10:30:27ZTitled entry permalink

I've been rewriting my static site in Webby, a Ruby static website management system. Hopefully, if it all works, you won't notice. The only way you'll notice is if you peek under the hood. I'm using "Options +MultiViews" in Apache to do URL rewriting, and there'll be more about that later.

Using Webby is pretty easy: webby site-name makes a new folder. Inside, there’s a content/ folder where you can put your content. These are .txt files which contain some YAML to include the title, what filters it runs through (ERb and Textile for instance) and what layout it uses.

It comes with Rake tasks to build and deploy. Here’s how I’m using mine. The basic procedure is rake build and then rake deploy to SCP or rsync it to your server (I use SCP). I’ve introduced another step - rake validate.

What does the validate task do? Well, the validation I’m doing is using oNVDL, which is a Java tool to validate XML. I’m using James Clark’s XHTML modular schema, specifically xhtml-strict.rng. There is a downside with this approach, and one I’ll probably fix soon - that is, if you use a mixture of HTML 4 and XHTML, or you use different types of XHTML - either 1.0 and 1.1, or Strict and Transitional, or even the new modular DTDs that the W3C have put out for SVG and RDFa. The reason I used the RELAX NG schema is because I had it there and was in a hurry, I knew how to use oNVDL and I’d used the modular RNG schemas before.

The Rake task is quite simple:

desc 'validate XHTML'
task :validate do
  Dir.glob('output/**/*.html').each do |f|
    print "validating " + f + "\n"
    sh "java -jar /Applications/oxygen/lib/onvdl.jar /Users/tommorris/bin/xhtmlrng/xhtml-strict.rng " + f
    print "\n"
  end
end

This will iterate through your output folder (the place where built markup goes) and validates each one against the schema. It should also print the result to your screen. You’ll see nothing if it’s all good, but you’ll get errors like this otherwise: /Users/tommorris/code/HTML/test/output/profiles/nsfw.html:3:71: error: attribute “lang” not allowed at this point; ignored

The nice thing is that the Java process exits with status 1 if there are problems, meaning the rake task itself is aborted. You can then fix one error at a time. And you can also make your deployment (or repository commit) dependent on the whole site validating. Hey, it’s compile-time error checking for XHTML! I’m sure some people are now furious since HTML is Not A Programming Language, but for me, this is important. I want my computer to tell me when things go wrong, and prevent me from sending invalid markup out on to the web. I’m sure one could even replace the validator with a stricter one that does some basic accessibility tests - and it’d be neat if we could add similar tests for CSS and so on.

Once you validate all the markup as XHTML, you probably want to then get Apache to serve the files as application/xhtml+xml, but not do so when Internet Explorer comes knocking on your door, since Internet Explorer is so utterly shite that it can’t read XHTML properly. Adding the following to your .htaccess file does exactly that:

RewriteEngine on
AddType application/xhtml+xml html
RewriteCond %{HTTP_USER_AGENT} ((.*MSIE.*)|(Lynx.*))
RewriteRule .* - [T=text/html]

This will serve all your .html files as XHTML, unless Internet Explorer or Lynx is being used, in which case it should get text/html instead. XHTML 1.0 can be served as application/xhtml+xml or text/html - but if you are using XHTML 1.1, or maybe the custom XHTML+RDFa DTD, then the validator and specification says you should be serving it as application/xhtml+xml. It’s probably okay if you still allow people using retarded browsers like Internet Explorer get your XHTML as text/html though.

By the way, one last thing - I mentioned earlier in passing ‘repository commit’. If you are using Git to manage your Webby sites (and frankly, you should be, since Git is made of win), you should not check your output directory in. Just add output/* to .gitignore. I’d highly recommend keeping your static site in version control. It’s very useful to be able to roll your site back, or get a list of all the changes you made to the template or the CSS

Links from del.icio.us

 

Login with your OpenID:
No. 792
Tom Morris
Currently in: East Sussex, England
Usually in: East Sussex, United Kingdom
AIM: tommorris
YIM: tom.morris

I am a , an , like to code in and noodle about with and the . I also have a BA in philosophy from London, and am studying for an MA. My philosophical interests are in Victorian-era German philosophy, Kierkegaard, Robert Nozick, hermeneutics and current approaches to the demarcation problem in the philosophy of science. Musically, I like jazz fusion, soul and P-Funk. My musical nirvana would be a mixture of Beethoven, Miles Davis and George Clinton topped with a side-serving of Erykah, Jill and Angie.

I also write for the Citizendium, an online encyclopedia project. If you know about stuff, you should join in.

Elsewhere:

  • GPG Key
  • del.icio.us
  • Flickr
  • Twitter
  • digg
  • Jaiku
  • LinkedIn
  • ma.gnolia
  • blip.tv
  • upcoming.org
  • MetaFilter
  • LiveJournal
  • CiteULike
  • Technorati Profile

RSS Feed Subscribe:

RDF

« April 2008 »
SuMoTuWeThFrSa
 12345
6789101112
13141516171819
20212223242526
27282930 

View in month context

On this day in: 2004 2006 2007