Railsconf Europe 2006 part 2: UJS, Cap shell and Django
20 Sep 2006 22:35 - (0) comments
Dan Webb did an excellent job at showing the Unobtrusive Javascript plugin. Having 'real links' that work without javascript should be the rule. A link like...
<a href="/product/desc/1" onclick="new Ajax.Request(this.href); return false;">View description</a>
... is much better than...
<a href="#" onclick="new Ajax.Request('/product/desc/1'); return false;">View description</a>
The first link works without javascript, the second doesn't. Note that the return false that should be added with a real URL as href.
Dan also showed how you should add behavior to an application. First build a working application using semantic HTML, than add the separate behavior that 'hijacks' the page elements to enhance the UI. This is not groundbreaking in itself, but it really works well with the way UJS has been implemented.
UJS isn't part of the core but Dan doesn't seem to mind. He thinks all the js stuff shouldn't be part of the core.
All this attention to detail for 'just' a link isn't something I've seen in the Java community. Those unlucky ones using JSF have applications that by default don't even work without javascript.
Capistrano
Jamis showed the new Capistrano shell which allows you to talk to multiple servers with just one shell.
cap -v shell
> !show_tasks
> uptime
> on web2 # execute commands only on this server
> ps -waux | grep | lighttpd
> on all #show commands on all servers
> exit
It's powerful but still experimental so be careful when using it. A lot of people were expecting an introduction to Capistrano (myself included), so Jamis ended with a short introduction.
Django
Simon Willison talks really fast and did a nice demo of some of Django's strong points that Rails could steal.
Django's admin views are really nice. Adding search fields looked super easy. These would be nice for rails if it wasn't for the fact that Django creates tables based on the model instead of creating the model based on the database tables as Rails does. The rails plugion Streamlined seems a more obvious fit for this.
I also liked the power of template inheritance. Just by overwriting the template blocks that need to look different, you can have to completely different looking sites with the exact same content.
For example if you have a template default.html:
{% block header%}
default header
{% endblock%}
{% block content %}
content
{% endblock%}
You can overwrite just the header with a new template:
{% extends "default.html" %}
{% block header%}
new header
{% endblock%}
Comments
No comments allowed.