'use strict';

// Declare app level module which depends on filters, and services
angular.module('bluelatex', [
  'localization',
  'ngRoute',
  'myApp.filters',
  'myApp.services',
  'myApp.directives',
  'bluelatex.User',
  'bluelatex.controller',
  'bluelatex.menu',
  'ui.ace'
]).config(['$routeProvider', function($routeProvider) {
  $routeProvider.when('/login', {templateUrl: 'partials/login.html', controller: 'LoginController', name: 'login', private: false});
  $routeProvider.when('/logout', {templateUrl: 'partials/partial2.html', controller: 'MyCtrl2', name: 'logout', private: false});
  $routeProvider.when('/register', {templateUrl: 'partials/register.html', controller: 'RegisterController', name: 'register', private: false});
  $routeProvider.when('/reset/?', {templateUrl: 'partials/reset.html', controller: 'ResetController', name: 'reset', private: false});
  $routeProvider.when('/:username/reset/:token/?', {templateUrl: 'partials/resetPassword.html', controller: 'ResetController', name: 'resetPassword', private: false});
  $routeProvider.when('/profile', {templateUrl: 'partials/partial2.html', controller: 'MyCtrl2', name: 'profile', private: true});
  $routeProvider.when('/papers', {templateUrl: 'partials/partial1.html', controller: 'MyCtrl1', name: 'papers', private: true});
  $routeProvider.when('/paper/:id/?', {templateUrl: 'partials/paper.html', controller: 'PaperController', name: 'paper', private: false});
  $routeProvider.otherwise({redirectTo: '/papers'});
}]).run( function($rootScope, $location) {
    // register listener to watch route changes
    $rootScope.$on( "$routeChangeStart", function(event, next, current) {
      if ( $rootScope.loggedUser == null && next.$$route.private == true) {
        // no logged user, we should be going to #login
        if ( next.$$route.name == "login" ) {
          // already going to #login, no redirect needed
        } else {
          // not going to #login, we should redirect now
          $location.path( "/login" );
        }
      } else if ( next.$$route.private == false && $rootScope.loggedUser != null) {
        $location.path( "/" );
      }
    });
});
@@ -239,24 +239,45 @@
 ontroller',%0A
+  'bluelatex.paper',%0A
   'bluelatex
@@ -284,16 +284,16 @@
 .menu',%0A
-
   'ui.ac
@@ -438,16 +438,22 @@
 : 'Login
+Logout
 Controll
@@ -448,32 +448,46 @@
 goutController',
+ options:%7B%0A   
  name: 'login', 
@@ -485,16 +485,20 @@
 'login',
+%0A   
  private
@@ -496,32 +496,56 @@
   private: false
+,%0A    title: 'Login'%0A  %7D
 %7D);%0A  $routeProv
@@ -570,69 +570,57 @@
 ', %7B
-templateUrl: 'partials/partial2.html', controller: 'MyCtrl2',
+controller: 'LoginLogoutController',options:%7B%0A   
  nam
@@ -638,32 +638,53 @@
 , private: false
+, title: 'Logout'%0A  %7D
 %7D);%0A  $routeProv
@@ -771,32 +771,45 @@
 sterController',
+options:%7B%0A   
  name: 'register
@@ -817,32 +817,55 @@
 , private: false
+, title: 'Register'%0A  %7D
 %7D);%0A  $routeProv
@@ -945,32 +945,45 @@
 esetController',
+options:%7B%0A   
  name: 'reset', 
@@ -988,32 +988,52 @@
 , private: false
+, title: 'Login'%0A  %7D
 %7D);%0A  $routeProv
@@ -1138,32 +1138,46 @@
 esetController',
+options:%7B%0A    
  name: 'resetPas
@@ -1190,32 +1190,60 @@
 , private: false
+, title: 'Rset password'%0A  %7D
 %7D);%0A  $routeProv
@@ -1260,17 +1260,16 @@
 '/profil
-e
 ', %7Btemp
@@ -1325,16 +1325,29 @@
 yCtrl2',
+options:%7B%0A   
  name: '
@@ -1361,32 +1361,53 @@
 ', private: true
+, title: 'Profil'%0A  %7D
 %7D);%0A  $routeProv
@@ -1484,17 +1484,39 @@
 r: '
-MyCtrl1',
+papersController',options:%7B%0A   
  nam
@@ -1541,16 +1541,37 @@
 te: true
+, title: 'Papers'%0A  %7D
 %7D);%0A  $r
@@ -1671,16 +1671,29 @@
 roller',
+options:%7B%0A   
  name: '
@@ -1714,16 +1714,36 @@
 e: false
+, title: 'Paper'%0A  %7D
 %7D);%0A  $r
@@ -2016,23 +2016,47 @@
 oute
-.private == tru
+ != null && next.$$route.options.privat
 e) %7B
@@ -2138,16 +2138,24 @@
 $$route.
+options.
 name == 
@@ -2341,24 +2341,24 @@
 ;%0A        %7D%0A
-
       %7D else
@@ -2375,16 +2375,47 @@
 .$$route
+!= null && next.$$route.options
 .private

Improve user navigation