use Clone qw(clone);
use Mojo::UserAgent;
+our $VERSION = `git describe`;
+chomp $VERSION;
+
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_database = 'drzb2013v2';
+my $couchdb_view = "http://10.60.0.92:5984/_utils/document.html?$couchdb_database";
my $client = Mojo::UserAgent->new;
sub _couchdb_put {
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') };
+
get '/lang/:lang/:template' => sub {
my $self = shift;
$self->render( $self->stash('template') , lang => $self->stash('lang') );
get '/lang/:lang/partials/:template' => sub {
my $self = shift;
+ $self->stash( couchdb_view => $couchdb_view );
$self->render( 'partials/' . $self->stash('template') , lang => $self->stash('lang') );
};
organizations => {
map => q| function(doc) {
if ( doc.user.organization != '' ) {
- emit(doc.user.organization, 1);
+ if ( doc.user.organization )
+ emit(doc.user.organization, 1);
if ( doc.user.persons ) {
doc.user.persons.forEach( function(person) {
- emit(person.organization, 1);
+ if ( person.organization )
+ emit(person.organization, 1);
});
}
}
return if $self->res->headers->header('ETag');
- my $our_etag = Mojo::ByteStream->new($body)->md5_sum;
+ my $our_etag = Mojo::ByteStream->new($body . $VERSION)->md5_sum;
$self->res->headers->header('ETag' => $our_etag);
my $browser_etag = $self->req->headers->header('If-None-Match');