Closed sam closed 12 years ago
Bringin' it wayyy back with the petshop ;)
Note: Added boot.rb. This is to give Harbor internals (like server
or console
) a way to load your app (petshop.rb
in this case) without forcing you to have a file called application.rb
that defines class Petshop < Harbor::Application
.
This should be a generated file with a note not to modify.
I couldn't spot a place where we can grab the application root path, should the generated boot.rb
do that job? Where should this variable be located?
I was thinking about something along the lines of Rails.root
, with returns a Pathname
instance that we could use to set up the default view path for example.
We should have a config.root I think. I agree setting it in boot.rb
makes sense.
boot.rb
could be basically:
require "lib/petshop"
config.root = Petshop.root = File.dirname(__FILE__).parent
config.load!(Petshop.root + "env")
# Configuration#views would return a ViewCollection object that handled mapping all the views paths perhaps?
config.views.add(Petshop.root + "views")
# Configuration#controllers would return the Controller Container/Autoloader.
config.controllers.add(Petshop.root + "controllers")
Just an idea.
It doesn't matter that config.root
could be overwritten multiple times with a "last-in-wins" as long as your "root app" is required last. You could bundle
, system-gem
, git-submodule
, or old-school vendor
the other apps. Doesn't matter as long as you require them first then. Their generated boot.rb
will handle the first-pass setup for us.
By having a Harbor::Application::root
method available (and set in boot.rb
), we can still easily get at the relative assets for a "mounted" application.
Also, I know @Bauerpauer is a fan of nesting everything under /lib
, which is mostly how we do it today. In my own projects I tend to maintain a flatter structure with views
, controllers
and public
hanging off the root so that's what I've described above.
Updated example to include /forms
and /helpers
.
I think this works for me. What about a log
directory?
Added log, and layouts. The 3rd level of ul
doesn't appear to format correctly.
Done in d59f245b04d7a64c77440e4bfd9beaf7518109bb.
Given
harbor setup petshop
: