Thursday, June 26, 2014

Dancer2 and Yeoman integrating nicely

Dancer2 and Angular changes to
bin/app.pl

Generate the backend components...

  651  dancer2 gen -a CMA 
  652  cd CMA
  652  yo angular cma
Rearranging the public / dancer web directories.

  709  vi bin/app.psgi
    insert
BEGIN {
  $ENV{'DBIC_TRACE'}    = 1;
  $ENV{'RELATIVE'} = 1;
}
  710  cd app
  711  ln -s ../bower_components .
  712  cd ../lib && vi CMA.pm
    edit
use Cwd;
set auto_page => 1;
# set the new views directory to absolute path
set views => getcwd . "/app";


get '/' => sub {
 template 'index';
};

# catch anything that cannot be served html extension 
# with template, else just serve the files requested based on the absolute
# path of the files
any qr{.*} => sub {
  my $name = request->path;
  print "request for end of chain: $name\n";
  #print Dumper( config->{appdir} );
  if ( $name !~ /\.html$/ ) {
    send_file( config->{appdir} . "/app/$name", system_path => 1 );
  }
  else {
    template $name;
  }
};

  
  712  cd ..
  719  plackup -r bin/app.psgi 
After this you could remove the public and views directory since they have no purpose. The 'app' directory generated by Yeoman contains all the application files.

No comments:

Post a Comment