This could be something very simple, or it could be impossible, but I surely can't figure out. How do I create a multi-folder Dancer app? As is, I get the following when I boostrap a new app with `dancer` -- app/ environments/ view/ lib/ public/ t/ The above works well for a relatively simple application, but if I have several groups of relatively complicated functions, I would like to group them by, well, by functions. Here is what I would like -- app/ function1/ function2/ function1 and function2 would be like mini dancer apps in their own right, but would share common resources such as top menu, login capabilities, logos, images (common to the both of them), master style sheet, etc. They would likely also share a fair bit of common Perl code, and also some data tables from a db. What is a suggested pattern for that? -- Puneet Kishor http://www.punkish.org Carbon Model http://carbonmodel.org Charter Member, Open Source Geospatial Foundation http://www.osgeo.org Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor Nelson Institute, UW-Madison http://www.nelson.wisc.edu ----------------------------------------------------------------------- Assertions are politics; backing up assertions with evidence is science =======================================================================
On Fri, 20 Aug 2010 06:32:54 -0500, P Kishor <punk.kish@gmail.com> wrote: [...]
app/ environments/ view/ lib/ public/ t/
The above works well for a relatively simple application, but if I have several groups of relatively complicated functions, I would like to group them by, well, by functions. Here is what I would like --
app/ function1/ function2/
function1 and function2 would be like mini dancer apps in their own right, but would share common resources such as top menu, login capabilities, logos, images (common to the both of them), master style sheet, etc. They would likely also share a fair bit of common Perl code, and also some data tables from a db.
What is a suggested pattern for that?
This is where you really should upgrade to 1.1806_02, in order to benefit from the 'load_app' feature. You'll be able to do the following: appdir/ yourapp.pl lib/ yourapp.pm yourapp/ function1.pm function2.pm views/ function1/ function2/ in yourapp.pm, you mount your subapps like that package yourapp; use Dancer ':syntax'; load_app 'yourapp::function1', prefix => '/function1'; load_app 'yourapp::function2', prefix => '/function2'; ... and in your subapps: package yourapp::function1; use Dancer ':syntax'; get '/' => sub { "root of function1" }; ...
On Sat, Aug 21, 2010 at 6:21 AM, sukria <sukria@sukria.net> wrote:
On Fri, 20 Aug 2010 06:32:54 -0500, P Kishor <punk.kish@gmail.com> wrote: [...]
app/ environments/ view/ lib/ public/ t/
The above works well for a relatively simple application, but if I have several groups of relatively complicated functions, I would like to group them by, well, by functions. Here is what I would like --
app/ function1/ function2/
function1 and function2 would be like mini dancer apps in their own right, but would share common resources such as top menu, login capabilities, logos, images (common to the both of them), master style sheet, etc. They would likely also share a fair bit of common Perl code, and also some data tables from a db.
What is a suggested pattern for that?
This is where you really should upgrade to 1.1806_02, in order to benefit from the 'load_app' feature.
You'll be able to do the following:
appdir/ yourapp.pl lib/ yourapp.pm yourapp/ function1.pm function2.pm views/ function1/ function2/
in yourapp.pm, you mount your subapps like that
package yourapp; use Dancer ':syntax';
load_app 'yourapp::function1', prefix => '/function1'; load_app 'yourapp::function2', prefix => '/function2'; ...
and in your subapps:
package yourapp::function1; use Dancer ':syntax';
get '/' => sub { "root of function1" };
...
Very nice. Just what I want. However, any ETA on when 1.1806 will become stable? I am loathe ot jump with my moving train on another moving train.
-- Puneet Kishor http://www.punkish.org Carbon Model http://carbonmodel.org Charter Member, Open Source Geospatial Foundation http://www.osgeo.org Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor Nelson Institute, UW-Madison http://www.nelson.wisc.edu ----------------------------------------------------------------------- Assertions are politics; backing up assertions with evidence is science =======================================================================
participants (2)
-
P Kishor -
sukria