'use strict';

/**
 * @ngdoc overview
 * @name clientApp
 * @description
 * # clientApp
 *
 * Main module of the application.
 */
angular
  .module('punyioApp', [
    'ngAnimate',
    'ngAria',
    'ngCookies',
    'ngMessages',
    'ngResource',
    'ngRoute',
    'ngSanitize',
    'ngTouch'
  ])
  .config(['$routeProvider', '$locationProvider', '$httpProvider',
           function($routeProvider, $locationProvider, $httpProvider) {
    $httpProvider.defaults.withCredentials = true;

    $routeProvider
      .when('/', {
        templateUrl: 'views/main.tmpl.html',
        controller: 'MainCtrl',
        controllerAs: 'main'
      })
      .when('/howitworks', {
        templateUrl: 'views/howitworks.tmpl.html'
      })
      .when('/manage', {
        templateUrl: 'views/manage.tmpl.html',
        controller: 'ManageCtrl',
        controllerAs: 'manage'
      })
      .when('/:code', {
        templateUrl: 'views/expander.tmpl.html',
        controller: 'ExpanderCtrl',
        controllerAs: 'expander'
      })
      .when('/:namespace/:desc', {
        templateUrl: 'views/expander.tmpl.html',
        controller: 'ExpanderCtrl',
        controllerAs: 'expander'
      })
      .when('/err/or/500', {
        templateUrl: 'views/errors/500.tmpl.html'
      })
      .when('/err/or/auth', {
        templateUrl: 'views/errors/auth.tmpl.html'
      })
      .otherwise({
        redirectTo: '/'
      });

    $locationProvider.html5Mode(true);
  }]);
