<commit_before>'use strict';

function PostController($scope, Tag, Post) {
  $scope.tags = Tag.query();
  $scope.posts = Post.query();

  $scope.delete = function(id) {
    Post.delete({postId: id}, function() {
      $scope.posts = Post.query();
    })
  }
}

function CreatePostController($scope, $location, Tag, Post, Category) {
  $scope.tags = Tag.query();
  $scope.posts = Post.query();
  $scope.categories = Category.query();
  $scope.post = new Post({catId: 0, date: "", title: "", author: "", text: "", tags: []});

  $scope.save = function() {
    $scope.post.id = 0;
    if ($scope.selectedCategory != null) {
      $scope.post.catId = parseInt($scope.selectedCategory);
      $scope.post.category = _.find($scope.categories, function(c) { return c.id == $scope.post.catId });
    } else {
      $scope.post.catId = 0;
    }
    $scope.post.date = new Date().getTime();

    Post.save($scope.post, function(post) {
      $location.path('/posts');
    });
  }

  $scope.cancel = function() {
    $location.path('/posts');
  }
}

function EditPostController($scope, $location, $routeParams, Post, Tag, Category) {
  var self = this;
  self.original = null;

  $scope.tags = Tag.query();
  $scope.categories = Category.query();

  Post.get({postId: $routeParams.postId}, function(post) {
    self.original = post;
    $scope.post = new Post(post);
    $scope.selectedCategory = $scope.post.category.id;
  })

  $scope.isClean = function() {
    return angular.equals(self.original, $scope.post) && (self.original != null && self.original.catId == $scope.selectedCategory.id);
  }

  $scope.cancel = function() {
    $location.path('/posts');
  }

  $scope.save = function() {
    $scope.post.catId = parseInt($scope.selectedCategory);
    $scope.post.category = _.find($scope.categories, function(c) { return c.id == $scope.post.catId });

    Post.update($scope.post, function(post) {
      $location.path('/posts');
    });
  }
}

function GalleryController($scope, Gallery, Tag) {
  $scope.tags = Tag.query();
  $scope.galleries = Gallery.query();

  $scope.delete = function(id) {
    Gallery.delete({galleryId: id}, function() {
      $scope.galleries = Gallery.query();
    })
  }
}

function CreateGalleryController($scope, $location, Gallery, Tag) {
  $scope.tags = Tag.query();
  $scope.galleries = Gallery.query();

  $scope.gallery = new Gallery({date: 0, title: "", author: "", shortlink: "", text: "", tags: []});

  $scope.save = function() {
    $scope.gallery.id = 0;
    $scope.gallery.coverId = 0;
    $scope.gallery.date = new Date().getTime();

    Gallery.save($scope.gallery, function(gallery) {
      $location.path('/galleries');
    });
  }

  $scope.cancel = function() {
    $location.path('/galleries');
  }
}

function EditGalleryController($scope, $location, $routeParams, Gallery, Tag, Image) {
  var self = this;
  self.original = null;

  $scope.tags = Tag.query();
  $scope.galleries = Gallery.query();

  Gallery.get({galleryId: $routeParams.galleryId}, function(gallery) {
    self.original = gallery;
    $scope.gallery = new Gallery(gallery);
  })

  $scope.onRender = function(a) {
    $scope.$watch("gallery.id", function(galleryId) {
      if (galleryId != undefined) {
        $('#file_upload').uploadify({
          'swf' : 'lib/uploadify-3.1.1/uploadify.swf',
          'folder'    : '/uploads',
          'auto'      : true,
          'multi'     : true,
          'method'    : 'POST',
          'debug'     : false,
          'uploader'  : 'http://localhost:8080/admin/api/images',
          'checkExisting' : false,
          'fileObjName'   : 'file',
          'fileTypeExts'  : '*.jpg;*.jpeg;*.gif;*.png',
          'fileTypeDesc'  : 'Image Files (.JPG, .GIF, .PNG)',
          'buttonClass'   : 'btn',
          'height'        : 18,
          'width'         : 42,
          'buttonText'    : 'Upload',
          'onQueueComplete' : function() {
            Gallery.get({galleryId: $routeParams.galleryId}, function(gallery) {<commit_msg>Using relative image upload url.<commit_after>'use strict';

function PostController($scope, Tag, Post) {
  $scope.tags = Tag.query();
  $scope.posts = Post.query();

  $scope.delete = function(id) {
    Post.delete({postId: id}, function() {
      $scope.posts = Post.query();
    })
  }
}

function CreatePostController($scope, $location, Tag, Post, Category) {
  $scope.tags = Tag.query();
  $scope.posts = Post.query();
  $scope.categories = Category.query();
  $scope.post = new Post({catId: 0, date: "", title: "", author: "", text: "", tags: []});

  $scope.save = function() {
    $scope.post.id = 0;
    if ($scope.selectedCategory != null) {
      $scope.post.catId = parseInt($scope.selectedCategory);
      $scope.post.category = _.find($scope.categories, function(c) { return c.id == $scope.post.catId });
    } else {
      $scope.post.catId = 0;
    }
    $scope.post.date = new Date().getTime();

    Post.save($scope.post, function(post) {
      $location.path('/posts');
    });
  }

  $scope.cancel = function() {
    $location.path('/posts');
  }
}

function EditPostController($scope, $location, $routeParams, Post, Tag, Category) {
  var self = this;
  self.original = null;

  $scope.tags = Tag.query();
  $scope.categories = Category.query();

  Post.get({postId: $routeParams.postId}, function(post) {
    self.original = post;
    $scope.post = new Post(post);
    $scope.selectedCategory = $scope.post.category.id;
  })

  $scope.isClean = function() {
    return angular.equals(self.original, $scope.post) && (self.original != null && self.original.catId == $scope.selectedCategory.id);
  }

  $scope.cancel = function() {
    $location.path('/posts');
  }

  $scope.save = function() {
    $scope.post.catId = parseInt($scope.selectedCategory);
    $scope.post.category = _.find($scope.categories, function(c) { return c.id == $scope.post.catId });

    Post.update($scope.post, function(post) {
      $location.path('/posts');
    });
  }
}

function GalleryController($scope, Gallery, Tag) {
  $scope.tags = Tag.query();
  $scope.galleries = Gallery.query();

  $scope.delete = function(id) {
    Gallery.delete({galleryId: id}, function() {
      $scope.galleries = Gallery.query();
    })
  }
}

function CreateGalleryController($scope, $location, Gallery, Tag) {
  $scope.tags = Tag.query();
  $scope.galleries = Gallery.query();

  $scope.gallery = new Gallery({date: 0, title: "", author: "", shortlink: "", text: "", tags: []});

  $scope.save = function() {
    $scope.gallery.id = 0;
    $scope.gallery.coverId = 0;
    $scope.gallery.date = new Date().getTime();

    Gallery.save($scope.gallery, function(gallery) {
      $location.path('/galleries');
    });
  }

  $scope.cancel = function() {
    $location.path('/galleries');
  }
}

function EditGalleryController($scope, $location, $routeParams, Gallery, Tag, Image) {
  var self = this;
  self.original = null;

  $scope.tags = Tag.query();
  $scope.galleries = Gallery.query();

  Gallery.get({galleryId: $routeParams.galleryId}, function(gallery) {
    self.original = gallery;
    $scope.gallery = new Gallery(gallery);
  })

  $scope.onRender = function(a) {
    $scope.$watch("gallery.id", function(galleryId) {
      if (galleryId != undefined) {
        $('#file_upload').uploadify({
          'swf' : 'lib/uploadify-3.1.1/uploadify.swf',
          'folder'    : '/uploads',
          'auto'      : true,
          'multi'     : true,
          'method'    : 'POST',
          'debug'     : false,
          'uploader'  : '/admin/api/images',
          'checkExisting' : false,
          'fileObjName'   : 'file',
          'fileTypeExts'  : '*.jpg;*.jpeg;*.gif;*.png',
          'fileTypeDesc'  : 'Image Files (.JPG, .GIF, .PNG)',
          'buttonClass'   : 'btn',
          'height'        : 18,
          'width'         : 42,
          'buttonText'    : 'Upload',
          'onQueueComplete' : function() {
            Gallery.get({galleryId: $routeParams.galleryId}, function(gallery) {
{'fraction_non_alphanumeric': 0.18601451088316237, 'fraction_numerical': 0.0037528146109582186, 'mean_word_length': 2.915279138099902, 'pattern_counts': {'":': 0, '<': 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': '2352219', 'n_tokens_mistral': 2680, 'n_tokens_neox': 2582, 'n_words': 474}