<commit_before>angular.module('gut-hub')

.config ($urlRouterProvider)->
  # default to '/home'...
  $urlRouterProvider.otherwise '/home'

.config (flashProvider)->
  # Support bootstrap 3.0 "alert-danger" class with error flash types
  flashProvider.errorClassnames.push 'alert-danger'

.config ($httpProvider)->
  $httpProvider.interceptors.push ($location, $rootScope, $q)->
    request: (config)->
      console.log "interceptor.request: config=%o", config
      config or $q.when config

    requestError: (rejection)->
      console.log "interceptor.requestError: rejection=%o", rejection
      $q.reject rejection

    response: (response)->
      console.log "interceptor.response: response=%o", response
      response or $q.when response

    responseError: (rejection)->
      console.log "interceptor.responseError: rejection=%o", rejection
      $q.reject rejection<commit_msg>get interceptor to change states on 401<commit_after>angular.module('gut-hub')

.config ($urlRouterProvider)->
  # default to '/home'...
  $urlRouterProvider.otherwise '/home'

.config (flashProvider)->
  # Support bootstrap 3.0 "alert-danger" class with error flash types
  flashProvider.errorClassnames.push 'alert-danger'

.config ($httpProvider)->
  $httpProvider.interceptors.push ($rootScope, $q, $injector)->
    request: (config)->
      console.log "interceptor.request: config=%o", config
      config or $q.when config

    requestError: (rejection)->
      console.log "interceptor.requestError: rejection=%o", rejection
      $q.reject rejection

    response: (response)->
      console.log "interceptor.response: response=%o", response
      response or $q.when response

    responseError: (rejection)->
      console.log "interceptor.responseError: rejection=%o", rejection
      if rejection.status is 401
        $rootScope.$broadcast 'event:unauthorized'

        # tlk
        # can't get $state injected directly into interceptor because of cyclical dependency
        # so get $injector and call invoke() asking for $state (madness, i know)...
        # ref: http://stackoverflow.com/a/19954545/2371903
        #
        $injector.invoke ($state)->
          $state.go "about"

      $q.reject rejection
{'fraction_non_alphanumeric': 0.12770758122743683, 'fraction_numerical': 0.01128158844765343, 'mean_word_length': 3.434, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2187098', 'n_tokens_mistral': 662, 'n_tokens_neox': 607, 'n_words': 167}