Major Streamlined::UI Refactoring

Posted by Stu Fri, 27 Jul 2007 22:35:22 GMT

In the course of fixing a bug, I bit off of significant refactoring I have wanted to do for a while. Instead of saying this:

# old way 
class PoetUI < Streamlined::UI
  # declarative settings
end

You can now say this:

# new way
Streamlined.ui_for(Poet) do
  # declarative settings
end

The new syntax is more testable, since it does not rely on singleton methods and inheritance. It also makes it much easier to break the default 1-1 relationship between models and ui instances. The old syntax is still supported, via a bit of method_missing trickery. But I am sure there are some breakages, and I would like to deprecate the old syntax over time. Kick the tires and let me know if you have any problems.

Posted in ,  | no comments | no trackbacks

How to customize the look of the list view

Posted by Luis Sat, 21 Jul 2007 05:13:01 GMT

Whenever I talk to someone about Streamlined, they usually ask about how they can customize the look. I’m going to cover how to change the look of the list / index view as of the state of the edge before the 0.9 release comes out.

You can do this by creating a UI class for your model by executing “rake streamlined:model MODEL=your_model_name”. This will create a ModelUI class in app/streamlined and affects the views for that model.

If you’ve tried Streamlined before, then you’ll know that when you’re viewing the list view for a model, then you’ll see a paginated table that contains all the instances of the model. Each row has one instance, along with three buttons: one to go to the show view of the instance, the second to go to the edit view of the instance and a third to delete the instance. Below the table, there’s a few more buttons with the most important one being the one to create a new model instance.

There’s already pretty good documentation on how to modify which columns show up, so I’m going to focus on the other options.

First, you can add custom headers and/or custom footers by adding the lines
header_partials :list => 'shared/my_custom_header'
footer_partials :list => 'shared/my_custom_footer'
and then of course creating the header / footer partial and putting it in the place you specified. Second, you can turn off the delete button for each row. Perhaps you want to ensure that users delete from the show view or perhaps users should not delete instances of your model at all. Do this with
quick_delete_button false
Third, you can turn off the edit button for each row.
quick_edit_button false
Fourth, if your model is read only, then you can turn off the new and edit buttons by adding the line
read_only true
Note that you can still delete, so you’ll have to specify quick_delete_button false like above if you want that. I’m not sure if that’s the right behavior. Any thoughts on that? Fifth, you can turn off all the buttons that link to show/edit/delete by adding the line
table_row_buttons false
Sixth, you can turn off pagination via
pagination false
Seventh, you can turn off filtering via
table_filter false
Eighth, you can add custom CSS styles via
style_classes :list => {:row => 'person_row'}
which means that each row will have a CSS class person_row which you can then specify in a stylesheet.

That’s it for customizing the list view declaratively. I’ll make sure all of this gets into the wiki. Please let me know if I missed anything. If there’s another way you’d like to customize the list view, please add a ticket in Trac or leave a comment here.

Posted in ,  | Tags , ,  | 1 comment | no trackbacks

Streamlined no longer auto-registers AAA filter

Posted by Stu Fri, 20 Jul 2007 03:38:48 GMT

The following lines have been removed from acts_as_streamlined for the upcoming 0.9 release:

if defined? AuthenticatedSystem
  include AuthenticatedSystem
  before_filter :login_required  
end

The team discussed it, and we (mostly) agreed that developer should choose to add AAA’s filter themselves—Streamlined shouldn’t automatically choose it for them.

If you are using Streamlined with AAA and you want to require login, you will need to add the before_filter to your own controllers.

Posted in  | no comments | 1 trackback

Using %% when calling Connection.quote?

Posted by Stu Fri, 20 Jul 2007 02:11:16 GMT

I have committed a fix for Trac 43 as svn 565. It seems that some code paths through Rails Connection.quote use sprintf internally, while others do not. So we now pass %% which either acts as an escape, or doesn’t.

Is passing the unnecessary % on to the database is innocuous? It feels dirty. Is this a bug in ActiveRecord?

Posted in  | no comments | no trackbacks

Due to a rash of Trac Spam...

Posted by jgehtland Thu, 19 Jul 2007 20:57:05 GMT

Due to a rash of Trac spam, we’ve had to turn off anonymous ability to modify pages or tickets on the Trac install. To do so, you simply have to create an account, which is easy and free and we don’t use your information for anything. Ever.

Sorry for the inconvenience, but it will help keep the Trac instance clean.

Posted in  | no comments | no trackbacks