{"size": 907, "ext": "js", "max_stars_repo_path": "public/modules/core/controllers/home.client.controller.js", "max_stars_repo_name": "serializedowen/Kick-Start-Up", "max_stars_repo_stars_event_min_datetime": "2015-08-04T02:44:31.000Z", "max_stars_repo_stars_event_max_datetime": "2015-08-24T00:39:12.000Z", "max_issues_repo_path": "public/modules/core/controllers/home.client.controller.js", "max_issues_repo_name": "serializedowen/Kick-Start-Up", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/modules/core/controllers/home.client.controller.js", "max_forks_repo_name": "serializedowen/Kick-Start-Up", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 4, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.2580645161, "max_line_length": 106, "alphanum_fraction": 0.6295479603}
'use strict';


angular.module('core').controller('HomeController', ['$scope', '$stateParams', '$http', 'Authentication',
	function($scope, $stateParams, $http, Authentication) {
		// This provides Authentication context.
		$scope.authentication = Authentication;
    $scope.isAdmin = false;

    $scope.postFilter = function(post){
      return post.user.displayName.indexOf($scope.keyword) > -1 || post.title.indexOf($scope.keyword) > -1
    };

    $scope.search = function(){
      $scope.keyword = $stateParams.keyword;
      $http.put('/search/' + $stateParams.keyword).success(function(data){
        $scope.result = data;
      });
    };


    $scope.loginAdmin = function(){
      $http.post('/admin', $scope.credentials).then(function(data){
        $scope.isAdmin = data.data.isAdmin;
        $scope.articles = data.data.articles;
        $scope.users = data.data.users;
      });
    };

	}
]);