Just had an idea of how to solve a problem I had a while ago: the
problem of wanting to re-use a single couchapp on multiple sites by
allowing templates, JSON settings and even views to be overridden for
each site.
A simple solution would be to add a "search_path" setting, which is an
ordered list of directories to search when pushing the couchapp. The
directories would be effectively merged before pushing. For example:
My re-usable forum application:
forum/
views/
by_slug/
map.js
lists/
index.js
templates/
default.html
settings.json
Then for my first custom site I would override the default.html
template and settings.json:
site1_forum/
templates/
default.html
settings.json
In the .couchapprc for site/ I would add the path to the forum/
directory to "search_path". Anything that is in forum/ but NOT in
site1_forum/ will also get pushed allowing site1 to override
default.html and settings.json and retain the main functionality of
the forum app.
The only thing I don't like about this is having to put a hard-coded
path into .couchapprc. Similar to Benoit's similar suggestion some
time ago, we could perhaps allow some kind of _plugins/ directory
where anything in there is merged into the main couchapp when needed.
The main point of this idea is that it allows parts of other couchapps
to be overridden, which can be quite powerful I think.
Comments welcome, I think this would be very simple to implement so I
will do it myself when I get time unless Benoit beats me to it ;-)
--
Jason Davies
http://github.com/couchapp/couchapp/issues/#issue/6
Feel free to complete it. I could work on it next weekend, so let me know asap.
- benoît