Commit e11b2145 authored by Randall Leeds's avatar Randall Leeds

Split the app configuration function

For readability, especially in light of the injection annotations,
split the app configuration functions in ``app.coffee``.
parent dbe42025
...@@ -23,38 +23,57 @@ resolve = ...@@ -23,38 +23,57 @@ resolve =
store: ['store', (store) -> store.$promise] store: ['store', (store) -> store.$promise]
configure = [ configureLocation = ['$locationProvider', ($locationProvider) ->
'$locationProvider', '$routeProvider', '$sceDelegateProvider', # Use HTML5 history
($locationProvider, $routeProvider, $sceDelegateProvider) -> $locationProvider.html5Mode(true)
$locationProvider.html5Mode(true) ]
$routeProvider.when '/a/:id',
controller: 'AnnotationViewerController' configureHttp = ['$httpProvider', ($httpProvider) ->
templateUrl: 'viewer.html' # Inject the authorization token on HTTP requests
resolve: resolve $httpProvider.interceptors.push('jwtInterceptor')
$routeProvider.when '/viewer', ]
controller: 'ViewerController'
templateUrl: 'viewer.html'
reloadOnSearch: false configureRoutes = ['$routeProvider', ($routeProvider) ->
resolve: resolve $routeProvider.when '/a/:id',
$routeProvider.when '/stream', controller: 'AnnotationViewerController'
controller: 'StreamSearchController' templateUrl: 'viewer.html'
templateUrl: 'viewer.html' resolve: resolve
resolve: resolve $routeProvider.when '/viewer',
$routeProvider.otherwise controller: 'ViewerController'
redirectTo: '/viewer' templateUrl: 'viewer.html'
reloadOnSearch: false
# Configure CSP for templates resolve: resolve
# XXX: IE workaround for the lack of document.baseURI property $routeProvider.when '/stream',
baseURI = document.baseURI controller: 'StreamSearchController'
if not baseURI templateUrl: 'viewer.html'
baseTags = document.getElementsByTagName "base" resolve: resolve
baseURI = if baseTags.length then baseTags[0].href else document.URL $routeProvider.otherwise
redirectTo: '/viewer'
# Explicitly whitelist '.html' paths adjacent to application base URI ]
# TODO: move all front-end templates into their own directory for safety
basePattern = baseURI.replace /\/[^\/]*$/, '/**.html'
$sceDelegateProvider.resourceUrlWhitelist ['self', basePattern] configureTemplates = ['$sceDelegateProvider', ($sceDelegateProvider) ->
# Configure CSP for templates
# XXX: IE workaround for the lack of document.baseURI property
baseURI = document.baseURI
if not baseURI
baseTags = document.getElementsByTagName "base"
baseURI = if baseTags.length then baseTags[0].href else document.URL
# Explicitly whitelist '.html' paths adjacent to application base URI
# TODO: move all front-end templates into their own directory for safety
basePattern = baseURI.replace /\/[^\/]*$/, '/**.html'
$sceDelegateProvider.resourceUrlWhitelist ['self', basePattern]
]
configure = ['$injector', ($injector) ->
$injector.invoke(configureHttp)
$injector.invoke(configureLocation)
$injector.invoke(configureRoutes)
$injector.invoke(configureTemplates)
] ]
angular.module('h', imports, configure) angular.module('h', imports, configure)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment