Blog
It's very easy to tell Rails to look for a layout in a different location from default, example...
There's one caveat, the word "layouts" must be in the path. This is probably fine for most cases, but I had a special case. After digging through the Rails source I finally found a solution. This method in the AbstractController is what does the check.
def _normalize_layout(value)
value.is_a?(String) && value !~ /\blayouts/ ? "layouts/#{value}" : value
end
The solution is to simply override that method in your controller. Here's my case.
I'm really excited about this new project I'm working on. LiveOn is a Kansas City based Startup developing a site that helps people capture and share memories with their family today, and preserves them for future generations. Check out the LiveOn Video on the homepage. It's an awesome idea and we're building some great technology behind it. We've already built some cool Flash components to capture webcam video and microphone audio and we're working with an open source video conversion/repository platform.
I'm still cranking on Doodlekit the Free Website Builder as well. We're working on some awesome new features for layout management and doing some ground breaking work with image/color management, dynamic HTML/CSS elements (like menus) and user interface design.
We're using Java as the core language for LiveOn (long story), which has actually been kind of nice. I'm realizing again that Java is a great language, it just needs more attention from pragmatic people, instead of "Architects". My hope is to start with a solid foundation and start to play with some new tech like server side Javascript. I have some ideas around Server Side Dom Manipulation that could revolutionize the view layer (hopefully someone else does it first).
Anyway, sorry for the rambling, I'm really just trying to get the phrase LiveOn with a link to the site in here as much as possible. ;) So yeah, LiveOn!
I've been using Engines for a couple of years and I've found it way to cumbersome for just organizing code. I looked into Namespacing, but I don't want to have the namespaces in the URLs. All I want is to be able to organize code into subdirectories.
Right now I just need one extra subdirectory for Addons. Here's what my directory structure looks like.
app
-- controllers
---- sites_controller.rb
---- ...
---- addons
------ forms_controller.rb
------ ...
-- models
---- site.rb
---- ...
---- addons
------ form.rb
------ ...
-- views
---- sites
---- ...
---- addons
------ forms
------ ....
Just like you would have with namespacing, but I'm not actually namespacing. To get this to work you only need to add a few lines to your environment.rb file.
Rails::Initializer.run do |config|
....
config.load_paths += %W(
#{RAILS_ROOT}/app/controllers/addons
#{RAILS_ROOT}/app/models/addons
#{RAILS_ROOT}/app/helpers/addons
)
config.controller_paths += %W(
#{RAILS_ROOT}/app/controllers/addons
);
.....
end
ActionController::Base.view_paths.insert(1, "app/views/addons")
We're working on some cool new image management tools for Doodlekit and one small feature we wanted to add was number re-ordering, like you can do in your Netflix queue.Maybe I'm dense but it took me quite a while to get the logic down for this and I went through a number of different revisions before I nailed it. I thought I'd post it here just incase anyone is looking for it, and for feedback
The algorithm I settled on is very simple. Get the elements that you want to change, remove all of them from the array, reinsert them at their new positions in the array (in ascending order), and reindex the entire array. This is all done before saving anything and you should only save what changed.
The example is from a Ruby on Rails controller, but it's simple enough that sans some Ruby magic it should easily translate to other languages.
Once you add the code you can call it like so...
$('my_div').centerVertically();
$('my_div').centerHorizontally();The code is paste below and also on Gist.

