What changes in the new Widgets Tabnav?

Posted by Paolo Mon, 03 Sep 2007 14:14:00 GMT

Hi guys, I just gotten back from my one-week vacation in Egypt and imagine what I found on my email inbox? Wow… a bunch of people are giving us feedback on the new Tabnav widget just a few days after its public release.

So let’s dig some changes between the old version and the new one:

Tabnav didn’t highlight with URLs beginning with a slash

Let’s consider this scenario:

add_tab do |t|
  t.named 'Cat'
  t.links_to :controller => '/cats'
end 

This didn’t correctly highlight on :controller => 'cats' beacuse of the leading slash of the controller parameter. Now thanks to Cédric Deltheil this issue as been solved. I’ve never experienced this problem myself… It’s difficult to fix something if you don’t know it’s broken :-) (Cédric pointed me to an old Peter Salomon comment rearding this issue. I didn’t get notified about that comment… so I apologize. I start hating typo, I promise we’ll move to a new blogging system soon).

Where’s my beloved show_if method?

show_if was a very useful method in the old Tabnav. You could set a condition to show or hide specific tabs (eg Administration tabs). Well, we got rid of that. With the new Widgets version the Tabnav definition is backed up by a partial, no more a specific model. That allows us to use pure ruby conditional code to add tabs whenever we want to. And that’s just because the tabnav definition gets reevaluated for every request.

One example is better that a thousand words: look at the if modifier at the end of the 2nd tab:

<% 
render_tabnav :main, :generate_css => true do
    add_tab do |t|
        t.named 'Home'
        t.links_to :controller => 'home'
    end

    add_tab do |t| 
        t.named 'Users'
        t.links_to :controller => 'users'
    end if current_user.admin?
end
%> 

You can also enclose one or more add_tab inside a if/unless block like this:

if @admin
  add_tab do |t| 
        t.named 'Users'
        t.links_to :controller => 'users'
  end 

  add_tab do |t| 
        t.named 'Customers'
        t.links_to :controller => 'customers'
  end 
end

It’s clear now that the show_if method wasn’t really necessary and was difficult to use because of the procs. Now you can just use your view’s params/variables/helpers as conditions.

True dynamic tabs

The facts that Tabnav is now a helper leads to another big improvement. You can now have true dynamic tabs. The default generated Tabnav now generates something like this:

render_tabnav :main, 
              :generate_css => true do 

  controller_names.each do |name|
    add_tab do |t|
      t.named name.camelize
      t.titled "Go to #{name.camelize}"
      t.links_to :controller => name
    end
  end

end 

What does that mean? It dynamically generates a tab for every controller, just like the scaffold does with column names! Of course you’ve got to customize that, but it shows the power that this version brings to you.

You can now have a tab for every user like 37signals’s Highrise does! Just imagine something like this:

render_tabnav :contacts, 
              :generate_css => true do 

  @contacts.each do |contact|
    add_tab do |t|
      t.named contact.name
      t.links_to :controller => 'contacts', :action => 'show', :id => contact.id
    end
  end

end 

No more start/end

Another little improvement: Tabnav’s content are now specified as a block.

# old version
<%= start_tabnav :main %>
  ...
<%= end_tabnav %>

#new widget version
<% tabnav :main do %>
  ...
<% end %>

It’s just a lot more Rubysh now… Hope you enjoy the improvements. If you experience issues just drop us a line.

A big thank you to Cédric Deltheil, Mark Swinson, Denis Bruléand and Glenn West for their feedback!

Socialize it: Add to del.icio.us Digg it! Technorati: What changes in the new Widgets Tabnav? Add to reddit.com

Posted in  | Tags , , ,  | 5 comments | no trackbacks

Tabnav retires, enter Widgets!

Posted by Paolo Sat, 18 Aug 2007 23:44:00 GMT

03 sep 07 UPDATE: see a few changes we’ve made to the new version reading this post!

Hi guys, I’m working on my RailsConfEurope presentation during these days. I decided to fix a few Tabnav issues and write a few more components we often use.

I ended up writing a new Rails plugin named Widgets. It aims to offer a consistent set of rails helpers which can help you insert nice components in your rails app with no effort at all.

It already contains a more flexible version of the Tabnav and a new Navigation widget (it allows you to define those little links you usually find in the top-right corner of webapps with the same powerful highlighting engine of the Tabnav).

I’m going to add more widgets before my speech in Berlin, so don’t consider this plugin as final. I’d like you to try this out and give me feedback…

just run:

ruby script/plugin install svn://svn.seesaw.it/widgets/trunk

and then run the tabnav generator:

ruby script/generate tabnav

or the navigation one…

ruby script/generate navigation

They should give you all the info you need to get started by yourself. Please send us feedback via email at staff@seesaw.it. We’re currently experiencing issues with the comment spam system, I promise we’ll fix it asap!

Thanks for reading.

Socialize it: Add to del.icio.us Digg it! Technorati: Tabnav retires, enter Widgets! Add to reddit.com

Posted in  | Tags , , , ,  | 8 comments | no trackbacks

Tabnav for Rails 1.2

Posted by Paolo Thu, 01 Feb 2007 06:43:00 GMT

(If you’re looking for tabnav documentation click here!)

Hi guys, we have just released an updated version of the Tabnav. Now it should work well with the brand new Rails 1.2. What have we done then?
  • Refactored the plugin to better match the usual plugin Module/Class structure (inspirated by simply_helpful).
  • Removed the Reloadable support, and fixed the code to make it work with the new Rails dependency mechanism.
  • Added support for restful routes inside tabs definition.
  • Fixed a bug that cached evaluated Proc(s) after the first call in production environment.
  • Moved tabnav design logic out of the generated partial, it now contains only the css (you can of course move it to your stylesheet and delete the partial now)
A sample of the new code you can write is:
class PostsTabnav < Tabnav::Base          
    add_tab do 
      named 'Posts list'
      links_to proc { hash_for_posts_path }
    end

    add_tab do 
      named 'New post'
      links_to proc { hash_for_new_post_path }
    end

    add_tab do 
      named proc{ "Show: " + @post.title }
      links_to proc{ hash_for_post_path(:id => @post.id) }
      show_if proc{ !@post.nil? && !@post.id.nil? }
    end

    add_tab do 
      named proc{"Edit: " + @post.title }
      links_to proc{hash_for_edit_post_path(:id => @post.id)}
      show_if proc{ !@post.nil? && !@post.id.nil? }
    end
end

This version is still young so please report any problem you encounter with it. You can install this version with ruby script/plugin install svn://svn.seesaw.it/tabnav/trunk. If you’re still using Rails 1.1.X please download the old version with ruby script/plugin install svn://svn.seesaw.it/tabnav/tags/0.2.

Note: previously generated Tabnav models are still compatible, just remember to remove the include Reloadable line. Unluckily the new generated partials are different so, you have to regenerate them :-(.

If you want to dig more you can download a lousy sample app here: svn://svn.seesaw.it/tabnav_testapp/trunk.

Other new features are on the way so stay tuned! btw feedback is very appreciated, as usual.

Socialize it: Add to del.icio.us Digg it! Technorati: Tabnav for Rails 1.2 Add to reddit.com

Posted in  | Tags , , , , , ,  | 33 comments | no trackbacks

What do bloggers say about you pages?

Posted by Paolo Sat, 23 Sep 2006 21:43:00 GMT

I should check the Google Labs page more often. Sometimes I get the feeling of missing something from that great company so I just subscribed to their feed.

What I discovered today while surfing the lab is a great Google Firefox Plugin: Blogger Web Comments.

It lets you see what bloggers are saying about the page you’re surfing. It’s cool when you want to see opinions about something new (at least for you) or if you wanna see comments related to your own pages.

This is what I’m seeing for our SeeSaw Homepage after enabling the plugin inside my Fox:

You can download the plugin here. Good (opinionated) surfing!

Socialize it: Add to del.icio.us Digg it! Technorati: What do bloggers say about you pages? Add to reddit.com

Posted in  | Tags , , , , , ,  | no comments | no trackbacks

The easiest way to add tabbed navigation to your Rails app!

Posted by Paolo Mon, 24 Jul 2006 01:09:00 GMT

UPDATE Feb 01, 2007: the Tabnav has been updated in order to work wit Rails 1.2, read this post fom more info.

Hi guys, during our development efforts we needed tabbed navigations. Well, after struggling with the acts_as_wizard plugin (you can find it in the toolbox) we decided to implement yet another rails plugin, and we think this time it’s even easier to use and someway plain cool.

Tabnav it’s so far the easiest way to build tabbed navigation like this:

A basic Tabnav...

The Tabnav Rails plugin provides nice tabbed navigation out of the box

All this magic it’s done by this fragment of code put inside my layout:

<%= start_tabnav :main %>
<%= @content_for_layout %>
<%= end_tabnav %>

Sounds cool? keep reading…

Socialize it: Add to del.icio.us Digg it! Technorati: The easiest way to add tabbed navigation to your Rails app! Add to reddit.com

Read more...

Posted in , ,  | Tags , , ,  | 107 comments | no trackbacks

acts_as_wizard refactored!

Posted by Paolo Tue, 18 Jul 2006 04:58:00 GMT

Our acts_as_wizard plugin needed improvements to address a few needs of an application we’re currently working on. I promised improvements to a bunch of early adopters too so finally I took my time and have done this dirty work.

If you don’t know acts_as_wizard yet, you just need to know it’s a rails plugin to help you build clean and simple web wizards.

You can find acts_as_wizard articles, installation instructions, tutorials and previous posts in the SeeSaw’s toolbox.

A Wizard can be simply defined this way:

class CreateCatAndDogWizard < Wizard::Base     
    add_step do 
      named 'Insert your cat'
      controlled_by :cats
      enable_actions :new, :create
      add_rewrite({:action => 'list'}, 
                  {:controller => 'dogs', :action => 'new'})
    end 

    add_step do
      named 'Insert your dog'
      controlled_by :dogs
      enable_actions :new, :create
      add_rewrite({:action => 'list'}, 
                  {:controller => 'main', :action => 'finished'})
    end 

    add_step do 
      named 'Finished!'
      controlled_by :main
      enable_actions :finished 
    end     
end

The main areas our refactoring focused on are:

  1. get rid of every controller contamination: we wanted controllers to be totally unaware of being part of a wizard.
  2. multi wizard support: the same controller must be able to take part of different wizards.
  3. general code cleanup: well, we just were ashamed of some dirty code..

If you’ve never uses acts_as_wizard, you don’t need to read what follows, just remember it has gotten better :)

If you were an early adopter instead, keep reading an I’ll show you what technically has changed…

Socialize it: Add to del.icio.us Digg it! Technorati: acts_as_wizard refactored! Add to reddit.com

Read more...

Posted in , ,  | Tags , , , ,  | 6 comments | no trackbacks

Older posts: 1 2


SeeSaw srl - Via Monte Pasubio, 8 37126 Verona - tel +39 045 4857457 fax 045 4851151 P.Iva 03609790237