<commit_before>import template from './add-blog.html';

class AddBlogCtrl {
    /* @ngInject */
  constructor(blogService, $scope, $timeout, $window, $state, userService) {
      this.blogService = blogService;
      this.$scope = $scope;
      this.$timeout = $timeout;
      this.$window = $window;
      this.$state = $state;
      this.userService = userService;
  }


  $onInit () {
    if (!this.userService.isLoggedIn()) {
      this.$state.go('401');
    }
    this.user = this.userService.user;
    this.blogItems = this.blogService.blogItems;
    this.added = false;
    this.resetForm();
  }

  goBack () {
    this.$window.history.back(); 
    //go back to where user was right before
  }

  resetForm () {
    this.blog = {
      "title": "",
      "views": 0,
      "likes": 0,
      "dislikes": 0,
      "name": this.user.payload.name,
      "date": this.blogService.getDate(),
      "description": "",
      "comments": []<commit_msg>redirects user to login page if user tries to go to a post-add page while not logged in<commit_after>import template from './add-blog.html';

class AddBlogCtrl {
    /* @ngInject */
  constructor(blogService, $scope, $timeout, $window, $state, userService) {
      this.blogService = blogService;
      this.$scope = $scope;
      this.$timeout = $timeout;
      this.$window = $window;
      this.$state = $state;
      this.userService = userService;
  }


  $onInit () {
    if (!this.userService.isLoggedIn()) {
      this.$state.go('login');
    }
    this.user = this.userService.user;
    this.blogItems = this.blogService.blogItems;
    this.added = false;
    this.resetForm();
  }

  goBack () {
    this.$window.history.back(); 
    //go back to where user was right before
  }

  resetForm () {
    this.blog = {
      "title": "",
      "views": 0,
      "likes": 0,
      "dislikes": 0,
      "name": this.user.payload.name,
      "date": this.blogService.getDate(),
      "description": "",
      "comments": []
{'fraction_non_alphanumeric': 0.15941295546558704, 'fraction_numerical': 0.004554655870445344, 'mean_word_length': 2.486772486772487, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 3, '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': '6956616', 'n_tokens_mistral': 653, 'n_tokens_neox': 634, 'n_words': 139}