generate services.js and push couchdb database and version to app
[angular-drzb] / angular-server.pl
index d76b11e..29db13a 100755 (executable)
@@ -6,13 +6,16 @@ use Time::HiRes;
 use Clone qw(clone);
 use Mojo::UserAgent;
 
+our $VERSION = '0.3';
+
 sub new_uuid { Time::HiRes::time * 100000 }
 
 #push @{app->static->paths}, 'app'; # default angular-seed app directory
 
 
 my $couchdb = $ENV{COUCHDB} || 'http://localhost:5984';
-my $couchdb_view = 'http://10.60.0.92:5984/_utils/document.html?drzb2013v2/';
+my $couchdb_database = 'drzb2013v2';
+my $couchdb_view = "http://10.60.0.92:5984/_utils/document.html?$couchdb_database";
 my $client = Mojo::UserAgent->new;
 
 sub _couchdb_put {
@@ -65,6 +68,13 @@ helper locale => sub {
        return $locale{ $lang } || "MISSING $lang $_[1]";
 };
 
+get '/js/services.js' => sub {
+       my $self = shift;
+       $self->stash( VERSION => $VERSION );
+       $self->stash( couchdb_database => $couchdb_database );
+       $self->render( 'js/services', format => 'js' );
+};
+
 # short public URLs
 get '/hr' => sub { shift->redirect_to('/lang/hr/drzb2013') };
 get '/en' => sub { shift->redirect_to('/lang/en/drzb2013') };