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
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:
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.
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.
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.
Andreas Bovens: we’ve decided to stop throwing draconian XML parsing failed error messages, and instead, attempt to reparse the document automatically as HTML.
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.
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.
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.
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.
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.
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.
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.