<commit_before>var app = angular.module('codeLinks', ['ui.router']);
app.config([
    '$stateProvider',
    '$urlRouterProvider',
    function($stateProvider, $urlRouterProvider) {
        $stateProvider.state('home', {
            url: '/home',
            templateUrl: '/home.html',
            controller: 'MainCtrl'
        });

        $urlRouterProvider.otherwise('home');
    }
]);
app.factory('posts', [function() {
    var o = {
        posts: []
    };
    return o;
}]);
app.controller('MainCtrl', [
    '$scope',
    'posts',
    function($scope, posts) {
        $scope.test = 'Hello world!';
        $scope.posts = posts.posts;
        $scope.addPost = function() {
            if (!$scope.title || $scope.title === '') {
                return;
            }
            $scope.posts.push({
                title: $scope.title, 
                link: $scope.link, 
                upvotes: 0
            });
            $scope.title = '';
            $scope.link = '';
        };
        $scope.incrementUpvotes = function(post) {
            post.upvotes += 1;
        };
    }
]);<commit_msg>Add posts state and inject service to PostsCtrl.<commit_after>var app = angular.module('codeLinks', ['ui.router']);
app.config([
    '$stateProvider',
    '$urlRouterProvider',
    function($stateProvider, $urlRouterProvider) {
        $stateProvider
            .state('home', {
                url: '/home',
                templateUrl: '/home.html',
                controller: 'MainCtrl'
            })
            .state('posts', {
                url: '/posts/{id}',
                templateUrl: '/posts.html',
                controller: 'PostCtrl'
            });

        $urlRouterProvider.otherwise('home');
    }
]);
app.factory('posts', [function() {
    var o = {
        posts: []
    };
    return o;
}]);
app.controller('MainCtrl', [
    '$scope',
    'posts',
    function($scope, posts) {
        $scope.test = 'Hello world!';
        $scope.posts = posts.posts;
        $scope.addPost = function() {
            if (!$scope.title || $scope.title === '') {
                return;
            }
            $scope.posts.push({
                title: $scope.title, 
                link: $scope.link, 
                upvotes: 0
            });
            $scope.title = '';
            $scope.link = '';
        };
        $scope.incrementUpvotes = function(post) {
            post.upvotes += 1;
        };
    }
]);
app.controller('PostsCtrl', [
    '$scope',
    '$stateParams',
    'posts',
    function($scope, $stateParams, posts) {
        
    }
]);
{'fraction_non_alphanumeric': 0.16705336426914152, 'fraction_numerical': 0.0015467904098994587, 'mean_word_length': 1.5639246778989098, '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': '4244736', 'n_tokens_mistral': 754, 'n_tokens_neox': 728, 'n_words': 128}