intertwingly

It’s just data

Wunderbar


W

Clearly if you want to develop a real web application, you need a router, a templating language, ability to separate out your model, view, and controller, scalability, and much more.

However, at times this is both too much, and yet not enough.  I find that I write a lot of scripts that do report generation, execution of shell commands, and the like, and in many cases would like to present a richer output than plain text: things like tables, fonts, and most importantly hypertext links.  I don’t want to worry too much about DOCTYPEs, charsets, and escaping, but instead on structure, style, and content.

I’ve been extracting some of the common logic from these scripts out into a library, and recently have started refactoring that library.  Yesterday, I focused on the HTML generation parts.

What I settled on was to define all methods that start with a low line character will generate a HTML tag.  As with builder on which this library is based, these tags can have text content and attributes.  Tags can also be nested.  Logic can be freely intermixed.

Here’s an example using the library.  The example will personally greet you if you provide your name.  If no name is provided, a form is provided which enables you to provide one.

#!/usr/bin/ruby1.9.1
require 'wunderbar'

Wunderbar.html do
  _head do
    _title 'Greeter'
    _style %{
      input {display: block; margin: 2em}
    }
  end

  _body? do
    if $param.name
      _p "Hello #{$param.name}!"
    else
      _form method: 'post' do
        _p 'Please enter your name:'
        _input name: 'name'
        _input type: 'submit'
      end
    end
  end
end

Here’s example output from that script:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"/>
    <title>Greeter</title>
    <style type="text/css">
      input {display: block; margin: 2em}
    </style>
  </head>
  <body>
    <form method="post">
      <p>Please enter your name:</p>
      <input name="name"/>
      <input type="submit"/>
    </form>
  </body>
</html>

As you can see, by default it takes care of indenting and generation of HTML.  It even knows which tags support explicit close tags and which ones do not.  Not shown in this example, but these default behaviors can be overridden by adding an exclamation mark at the end of the method name.  An example would be something like:

_p! { _ "Hello "; _span $param.name, class: 'name'; _ '!' }

An underbar which is not followed by a name generates text.  Example output:

<p>Hello <span class="name">Sam</span>!</p>

The span can be styled using css.

If your web server is set up to execute CGI scripts, deployment is as easy as copying the script into the appropriate directory.

Port Forwarding


Problem: I’m not always at the machine that is VPN’ed into work.

Solution: place the following into /etc/network/if-up.d/sametime-forwarder:

#!/bin/sh
#
# redirect Sametime's port 1533 to messaging.ibm.com
#
echo 1 > /proc/sys/net/ipv4/ip_forward # turns on forwarding
iptables -F -t nat # Flush existing translation tables
iptables -t nat -A PREROUTING -p tcp --dport 1533 -j DNAT --to 9.17.136.77:1533
iptables -t nat -A POSTROUTING -j MASQUERADE

AWDwR updated for Rails 3.2


P P

David Heinemeier Hansson: there’s a brand new 3.2-compatible version of Agile Web Development with Rails.

This time, the release of Rails 3.2 and the release of the eBook were coordinated.

The President’s challenge


SOPA

Nat Torkington: Don’t wait for the time machine, because we’re never going to invent something that returns you to 1965 when copying was hard and you could treat the customer’s convenience with contempt.

Take action.

Bootstrapping Debian Unstable


It turns out that the following is all it takes to install Debian Unstable in a chroot jail under Ubuntu, and then to log into that jail as root:

apt-get install debootstrap schroot
mkdir /tmp/unstable
debootstrap unstable /tmp/unstable
chroot /tmp/unstable

...

Ubuntu vs Ruby


If Ubuntu 12.04 if a LTS release, and Ruby 1.8.7 goes out of support in June of 2013, then why is the default still 1.8.7?

Ruby 1.9.2 was released in 2010. Ruby 1.9.3 was released in October of this year.

Experience with Git


The git vs svn permathread seems to have reignited at the ASF, and I thought I would describe some of my actual experiences with git in the hopes that it will help anchor the discussion.

...

Building Dart


I wonder how many people who are diss’ing Dart on Twitter and elsewhere have actually tried the building the language?

...

Thunderbird add-ons in Flux


Knowing that Thunderbird was going to be upgraded in Ubuntu 11.10, I took a look at the one extension I use, and found that it was not compatible.  I know I could hack it, but if things went wrong down the line, I would rather understand what I was dealing with.  Particularly, as my needs are meager: I simply wanted to create a button that would invoke fetchmail.

...

No more "XML parsing failed" errors


Andreas Bovens: we’ve decided to stop throwing draconian XML parsing failed error messages, and instead, attempt to reparse the document automatically as HTML.

AWDwR updated for Rails 3.1


P P

Dave Thomas & Andy Hunt: Rails 3.1 introduces many user-facing changes, and this eBook release of Agile Web Development with Rails, 4th Ed. has been updated to match all the latest changes and new best practices.

Released virtually simultaneously with the Rails release.

Snow Leopard


Experiences with a clean install of Snow Leopard on a 2008 vintage mac-mini: sleep/wakeup issues, getting suexec working, RVM, installing and uninstalling MySQL, and playing with Mail app.

...

Upgrade Unavailable?


Sqlite3 3.7.4 doesn’t like Mac OSX 10.5.8.  Rails 3.1 doesn’t like sqlite3-ruby -v 1.2.5.  Neither Best Buy nor Apple will sell me Snow Leopard; not from their Brick and Mortar stores nor online.  Nor is Lion an option as upgrading to Snow Leopard is a prerequisite.

If anybody has any suggestions, please let me know.  Meanwhile, I can say this: while every previous version of Agile Web Development had screenshots of Safari on a Mac, the next update will have screenshots of Chrome on Ubuntu.

...

Thirty


On Monday, July 27th, 1981 I reported for my first day at work at the IBM Federal System Division offices in Gaithersburg Maryland.  Much has changed in those thirty years.  While I have no immediate plans to retire, I must say that it feels rather odd to be in a position where I could chose to do so at any time.

Open Source Ideologies


Ian Skerrett: Some of those people that oppose the move are promoting ideology about open source software that is just wrong.  Luckily I am here to correct them.

Apache OpenOffice


Rob Weir: As you have probably heard, Oracle has followed through with their earlier promise to “move OpenOffice.org to a purely community-based open source project.”  OpenOffice is moving to Apache.  I’d like to offer you my own thoughts on this new opportunity and what it means. I recommend also the insights of my colleagues Ed Brill and Bob Sutor.

+1

Ghostscript Segfault


Håkon A. Hjortland: For people who are just interested in a quick and dirty fix right here and now, here’s the gist

Affects Ubuntu 11.04 (a.k.a., "Natty Narwhal").  Fix works for me.

W3C License Poll


The W3C HTML Working Group recently had a preference poll on which license should be used for the HTML specification.  As directed, the W3C PSIG prepared three non-forkable license options.  Additionally, Mozilla provided two forkable license options.

For better or worse, the W3C is a member organization.  I’ve broken out the results by affiliation.

...

ASF Subpoenaed by Oracle


Sally Khudairi: The Apache Software Foundation (ASF) has received a United States District Court subpoena requiring the production of documents related to the use of Apache Harmony code in the Android software platform, and the unsuccessful attempt by Apache to secure an acceptable license to the Java SE Technology Compatibility Kit.

Sincerest Form Of Flattery


Ryan Dahl: By strongly basing our policy on the one used by the Apache Software Foundation we feel that we’ve created a policy which is liberal enough to allow the open source community to easily make use of the mark in the context of free open source software, but secure enough to protect the community’s work from being misrepresented by other organisations.