<commit_before>'use strict';

let environment = require('../environment');
let npdcCommon = require('npdc-common');
let AutoConfig = npdcCommon.AutoConfig;

var angular = require('angular');
require('formula');
require('angular-route');
require('angular-npolar');

var npdcPublicationApp = angular.module('npdcPublicationApp', ['ngRoute', 'formula', 'npolarApi', 'npolarUi', 'npdcUi', 'templates']);

npdcPublicationApp.controller('PublicationShowController', require('./show/PublicationShowController'));
npdcPublicationApp.controller('PublicationSearchController', require('./search/PublicationSearchController'));
npdcPublicationApp.controller('PublicationEditController', require('./edit/PublicationEditController'));

// Bootstrap ngResource models using NpolarApiResource
var resources = [
  {'path': '/', 'resource': 'NpolarApi'},
  {'path': '/user', 'resource': 'User'},
  {'path': '/dataset', 'resource': 'Dataset' },
  {'path': '/publication', 'resource': 'Publication' },
  {'path': '/project', 'resource': 'Project' }
];

resources.forEach(service => {
  // Expressive DI syntax is needed here
  npdcPublicationApp.factory(service.resource, ['NpolarApiResource', function (NpolarApiResource) {
  return NpolarApiResource.resource(service);
  }]);
});

// Routing
npdcPublicationApp.config(require('./routes')).config(function($mdThemingProvider) {
  $mdThemingProvider.theme('altTheme');
});

npdcPublicationApp.filter('isodate', function() {
  return function(input) {
  if (/[0-9]{4}[-][0-9]{2}[-][0-9]{2}T/.test(input)) {
    return input.split("T")[0];
  } else {
    return input;
  }
  
  };
});

npdcPublicationApp.filter('t', () => {
  return function(txt) {
    if (txt instanceof String) {
      return 't('+txt+')';
    }
    
  };
});


npdcPublicationApp.filter('published', () => {
  return function(published, fmt) {
    
    if ('%Y' === fmt && (/^[0-9]{4}-/).test(published)) {
      return published.split('-')[0];
    } else if ('%Y-%m' === fmt && (/^[0-9]{4}-[0-9]{2}-/).test(published)) {
      return published.split('-').slice(0,2).join('-');
    } else if ('%Y-%m-%d' === fmt && (/^[0-9]{4}-[0-9]{2}-[0-9]{2}T/).test(published)) {
      return published.split('T')[0];
    } else {
      return '';
    }
    
  };
});

// API HTTP interceptor
npdcPublicationApp.config($httpProvider => {
  $httpProvider.interceptors.push('npolarApiInterceptor');
});

// Inject npolarApiConfig and run
npdcPublicationApp.run((npolarApiConfig, npdcAppConfig) => {
  var autoconfig = new AutoConfig(environment);
  angular.extend(npolarApiConfig, autoconfig, { resources });
  console.debug("npolarApiConfig", npolarApiConfig);
});<commit_msg>set basic app configuration<commit_after>'use strict';

let npdcCommon = require('npdc-common');
let AutoConfig = npdcCommon.AutoConfig;

var angular = require('angular');
require('formula');
require('angular-route');
require('angular-npolar');

var npdcPublicationApp = angular.module('npdcPublicationApp', ['ngRoute', 'formula', 'npolarApi', 'npolarUi', 'npdcUi', 'templates']);

npdcPublicationApp.controller('PublicationShowController', require('./show/PublicationShowController'));
npdcPublicationApp.controller('PublicationSearchController', require('./search/PublicationSearchController'));
npdcPublicationApp.controller('PublicationEditController', require('./edit/PublicationEditController'));

// Bootstrap ngResource models using NpolarApiResource
var resources = [
  {'path': '/', 'resource': 'NpolarApi'},
  {'path': '/user', 'resource': 'User'},
  {'path': '/dataset', 'resource': 'Dataset' },
  {'path': '/publication', 'resource': 'Publication' },
  {'path': '/project', 'resource': 'Project' }
];

resources.forEach(service => {
  // Expressive DI syntax is needed here
  npdcPublicationApp.factory(service.resource, ['NpolarApiResource', function (NpolarApiResource) {
  return NpolarApiResource.resource(service);
  }]);
});

// Routing
npdcPublicationApp.config(require('./routes')).config(function($mdThemingProvider) {
  $mdThemingProvider.theme('altTheme');
});

npdcPublicationApp.filter('isodate', function() {
  return function(input) {
  if (/[0-9]{4}[-][0-9]{2}[-][0-9]{2}T/.test(input)) {
    return input.split("T")[0];
  } else {
    return input;
  }

  };
});

npdcPublicationApp.filter('t', () => {
  return function(txt) {
    if (txt instanceof String) {
      return 't('+txt+')';
    }

  };
});


npdcPublicationApp.filter('published', () => {
  return function(published, fmt) {

    if ('%Y' === fmt && (/^[0-9]{4}-/).test(published)) {
      return published.split('-')[0];
    } else if ('%Y-%m' === fmt && (/^[0-9]{4}-[0-9]{2}-/).test(published)) {
      return published.split('-').slice(0,2).join('-');
    } else if ('%Y-%m-%d' === fmt && (/^[0-9]{4}-[0-9]{2}-[0-9]{2}T/).test(published)) {
      return published.split('T')[0];
    } else {
      return '';
    }

  };
});

// API HTTP interceptor
npdcPublicationApp.config($httpProvider => {
  $httpProvider.interceptors.push('npolarApiInterceptor');
});

// Inject npolarApiConfig and run
npdcPublicationApp.run((npolarApiConfig, npdcAppConfig) => {
  let environment = "production";
  var autoconfig = new AutoConfig(environment);
  angular.extend(npolarApiConfig, autoconfig, { resources });
  npdcAppConfig.cardTitle = '';
  npdcAppConfig.toolbarTitle = "Publications";
  console.debug("npolarApiConfig", npolarApiConfig);
});
{'fraction_non_alphanumeric': 0.20530415430267063, 'fraction_numerical': 0.011869436201780416, 'mean_word_length': 5.052749719416386, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '2671119', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1729, 'n_words': 286}