<commit_before>angular.module('registry.controllers', [])

.controller('MainController', function($scope, $location, Search, API){
    $scope.search = function(){
        if(this.data.search !== ""){
            Search.setValue(this.data.search);
            $location.path("/registry");
        }
    };

    $scope.signin = function(page){
        API.signin(page);
    };
})

.controller('MyStackController', function($scope, $rootScope, API, Search){
    API.getUser().success(function(data, status, headers, config){
         $rootScope.setUser(data.username);
         $scope.user = $rootScope.getUser();
    }).error(function(data, status, headers, config){
        $scope.err = true;
    });

     API.getUserFiles().success(function(data, status, headers, config){
         $scope.files = data;
         $scope.loaded = true;
     }).error(function(data, status, headers, config){
         $scope.err = true;
         $scope.loaded = true;
     });

     $scope.showModal = false;
     $scope.toggleModal = function(){
         $scope.showModal = !$scope.showModal;
     };

     $scope.generateEmbed = function(id){
         API.getFileWithId(id).success(function(data, status, headers, config){
             $scope.embedScript = '<div id="stackfile"></div><script type="text/javascript" src="http://code.jquery.com/jquery-2.0.3.min.js"></script><script>WebFontConfig={google:{families:["Lato::latin"]}},function(){var t=document.createElement("script");'+
             't.src=("https:"==document.location.protocol?"https":"http")+"://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js",'+
             't.type="text/javascript",t.async="true";var e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(t,e)}();'+
             'var file=document.createElement("pre");$.get("http://staging.stackfiles.io/api/v1/user/repos/embed?user='+data.user+'&repository='+data.projectName+'&branch='+data.branch+'&path='+data.path+'").done(function(t){file.setAttribute("id","stack");'+
             'var e=document.createElement("p");e.setAttribute("style","padding: 15px 20px 15px 20px"),$(e).append(t),file.setAttribute("style","width: 516px; max-height: 500px; border: 1px solid #999999; border-radius: 2px;'+
             '  overflow: auto; display:inline-block;");var p=document.createElement("div");p.setAttribute("style","font-family: \'Lato\'; font-size: 14px; margin-top: 40px; border-top: 1px solid #999999; height:54px; width: 100%;"),'+
             '$("#stack").append($(e)),$(p).append("<p style=\'display: inline-block; padding: 20px 0px 18px 13px; margin: 0;\'>Stackfile hosted by </p><a href=\'http://tutum.co\' style=\'color: #2196F3; text-decoration: none;\'>Tutum</a><span><a style=\'float:right; padding: 6px 9px 6px 9px; line-height: 20px;'+
             ' font-size: 14px; font-weight: 700; border-radius: 2px; border: 2px solid #FFFFFF; text-transform: uppercase; color: #2196F3; border-color: #2196F3; text-decoration: none; margin-top: 10px; margin-right: 18px;\''+
             ' href=\'https://dashboard.tutum.co/stack/deploy/?repo='+ data.profileLink + '/' + data.projectName + '\'>Deploy to Tutum</a></span>"),$("#stack").append($(p))}),$(file).appendTo($("#stackfile"));</script>';
         }).error(function(data, status, headers, config){
             $scope.embedScript = 'Unable to generate the embed script. Please try again.';
         });
     };

     $scope.signin = function(page){
         API.signin(page);
     };

    $scope.searchFile = function(){
        var term = this.data.search;
        API.searchFile(term).success(function(data, status, headers, config){
            $scope.results = data;
        }).error(function(data, status, headers, config){
            $scope.err = true;
        });
    };
})


.controller('FavoriteController', function($scope, $rootScope, API, Search){

})

.controller('RegistryController', function($scope, $rootScope, $window, API, Search){
    $scope.favoriteList = [];

    API.getUser().success(function(data, status, headers, config){
         $rootScope.setUser(data.username);
         $scope.user = $rootScope.getUser();

         API.checkFav().success(function(data, status, header, config){
            $scope.favoriteList = data;
        }).error(function(data, status, headers, config){
            console.log(data);
        });

    }).error(function(data, status, headers, config){
        $scope.err = true;
    });

    $scope.showModal = false;
    $scope.toggleModal = function(){
        $scope.showModal = !$scope.showModal;
    };

    $scope.generateEmbed = function(id){
        API.getFileWithId(id).success(function(data, status, headers, config){
            $scope.embedScript = '<div id="stackfile"></div><script type="text/javascript" src="http://code.jquery.com/jquery-2.0.3.min.js"></script><script>WebFontConfig={google:{families:["Lato::latin"]}},function(){var t=document.createElement("script");'+
            't.src=("https:"==document.location.protocol?"https":"http")+"://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js",'+
            't.type="text/javascript",t.async="true";var e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(t,e)}();'+
            'var file=document.createElement("pre");$.get("http://staging.stackfiles.io/api/v1/user/repos/embed?user='+data.user+'&repository='+data.projectName+'&branch='+data.branch+'&path='+data.path+'").done(function(t){file.setAttribute("id","stack");'+
            'var e=document.createElement("p");e.setAttribute("style","padding: 15px 20px 15px 20px"),$(e).append(t),file.setAttribute("style","width: 516px; max-height: 500px; border: 1px solid #999999; border-radius: 2px;'+
            '  overflow: auto; display:inline-block;");var p=document.createElement("div");p.setAttribute("style","font-family: \'Lato\'; font-size: 14px; margin-top: 40px; border-top: 1px solid #999999; height:54px; width: 100%;"),'+
            '$("#stack").append($(e)),$(p).append("<p style=\'display: inline-block; padding: 20px 0px 18px 13px; margin: 0;\'>Stackfile hosted by </p><a href=\'http://tutum.co\' style=\'color: #2196F3; text-decoration: none;\'>Tutum</a><span><a style=\'float:right; padding: 6px 9px 6px 9px; line-height: 20px;'+
            ' font-size: 14px; font-weight: 700; border-radius: 2px; border: 2px solid #FFFFFF; text-transform: uppercase; color: #2196F3; border-color: #2196F3; text-decoration: none; margin-top: 10px; margin-right: 18px;\''+
            ' href=\'https://dashboard.tutum.co/stack/deploy/?repo='+ data.profileLink + '/' + data.projectName + '\'>Deploy to Tutum</a></span>"),$("#stack").append($(p))}),$(file).appendTo($("#stackfile"));</script>';
        }).error(function(data, status, headers, config){
            $scope.embedScript = 'Unable to generate the embed script. Please try again.';
        });
    };

    $scope.signin = function(page){
        API.signin(page);
    };

    $scope.deploy = function(id){
        window.location.href = ('/api/v1/deploy/'+id);
    };

    API.getFiles().success(function(data, status, headers, config){
        $scope.files = data;
        $scope.loaded = true;
    }).error(function(data, status, headers, config){
        $scope.err = true;
    });

    $scope.searchFile = function(){
        var term = this.data.search;
        API.searchFile(term).success(function(data, status, headers, config){
            $scope.results = data;
        }).error(function(data, status, headers, config){
            $scope.err = true;
        });
    };

    $scope.checkSearch = function(){
        if(Search.getValue().search !== null){
            $scope.data = Search.getValue();
            $scope.searchFile(Search.getValue());
        }
    };

    $scope.toggleStatus = function(file) {
        $scope.favoriteList.push(file._id);
        API.favFile(file._id).success(function(data, status, headers, config){

        }).error(function(data, status, headers, config){
            $scope.err = true;
        });
    };
    $scope.isSelected = function(file) {
        return $scope.favoriteList.indexOf(file._id) > -1;
    };
})

.controller('RegistryDetailsController', function($scope, $rootScope, $window, $routeParams, API){

    $scope.favoriteList = [];
    $scope.user = $rootScope.getUser();

    API.getFileWithId($routeParams.registryId).success(function(data, status, headers, config){
        $scope.data = data;
        API.getYAMLFile(data._id, data.projectName, data.path).success(function(yamlData, status, headers, config){
            $scope.composeFile = yamlData;
            $scope.loaded = true;<commit_msg>Mock implementation of fav toggling<commit_after>angular.module('registry.controllers', [])

.controller('MainController', function($scope, $location, Search, API){
    $scope.search = function(){
        if(this.data.search !== ""){
            Search.setValue(this.data.search);
            $location.path("/registry");
        }
    };

    $scope.signin = function(page){
        API.signin(page);
    };
})

.controller('MyStackController', function($scope, $rootScope, API, Search){
    API.getUser().success(function(data, status, headers, config){
         $rootScope.setUser(data.username);
         $scope.user = $rootScope.getUser();
    }).error(function(data, status, headers, config){
        $scope.err = true;
    });

     API.getUserFiles().success(function(data, status, headers, config){
         $scope.files = data;
         $scope.loaded = true;
     }).error(function(data, status, headers, config){
         $scope.err = true;
         $scope.loaded = true;
     });

     $scope.showModal = false;
     $scope.toggleModal = function(){
         $scope.showModal = !$scope.showModal;
     };

     $scope.generateEmbed = function(id){
         API.getFileWithId(id).success(function(data, status, headers, config){
             $scope.embedScript = '<div id="stackfile"></div><script type="text/javascript" src="http://code.jquery.com/jquery-2.0.3.min.js"></script><script>WebFontConfig={google:{families:["Lato::latin"]}},function(){var t=document.createElement("script");'+
             't.src=("https:"==document.location.protocol?"https":"http")+"://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js",'+
             't.type="text/javascript",t.async="true";var e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(t,e)}();'+
             'var file=document.createElement("pre");$.get("http://staging.stackfiles.io/api/v1/user/repos/embed?user='+data.user+'&repository='+data.projectName+'&branch='+data.branch+'&path='+data.path+'").done(function(t){file.setAttribute("id","stack");'+
             'var e=document.createElement("p");e.setAttribute("style","padding: 15px 20px 15px 20px"),$(e).append(t),file.setAttribute("style","width: 516px; max-height: 500px; border: 1px solid #999999; border-radius: 2px;'+
             '  overflow: auto; display:inline-block;");var p=document.createElement("div");p.setAttribute("style","font-family: \'Lato\'; font-size: 14px; margin-top: 40px; border-top: 1px solid #999999; height:54px; width: 100%;"),'+
             '$("#stack").append($(e)),$(p).append("<p style=\'display: inline-block; padding: 20px 0px 18px 13px; margin: 0;\'>Stackfile hosted by </p><a href=\'http://tutum.co\' style=\'color: #2196F3; text-decoration: none;\'>Tutum</a><span><a style=\'float:right; padding: 6px 9px 6px 9px; line-height: 20px;'+
             ' font-size: 14px; font-weight: 700; border-radius: 2px; border: 2px solid #FFFFFF; text-transform: uppercase; color: #2196F3; border-color: #2196F3; text-decoration: none; margin-top: 10px; margin-right: 18px;\''+
             ' href=\'https://dashboard.tutum.co/stack/deploy/?repo='+ data.profileLink + '/' + data.projectName + '\'>Deploy to Tutum</a></span>"),$("#stack").append($(p))}),$(file).appendTo($("#stackfile"));</script>';
         }).error(function(data, status, headers, config){
             $scope.embedScript = 'Unable to generate the embed script. Please try again.';
         });
     };

     $scope.signin = function(page){
         API.signin(page);
     };

    $scope.searchFile = function(){
        var term = this.data.search;
        API.searchFile(term).success(function(data, status, headers, config){
            $scope.results = data;
        }).error(function(data, status, headers, config){
            $scope.err = true;
        });
    };
})


.controller('FavoriteController', function($scope, $rootScope, API, Search){

})

.controller('RegistryController', function($scope, $rootScope, $window, API, Search){
    $scope.favoriteList = [];

    API.getUser().success(function(data, status, headers, config){
         $rootScope.setUser(data.username);
         $scope.user = $rootScope.getUser();

         API.checkFav().success(function(data, status, header, config){
            $scope.favoriteList = data;
        }).error(function(data, status, headers, config){
            console.log(data);
        });

    }).error(function(data, status, headers, config){
        $scope.err = true;
    });

    $scope.showModal = false;
    $scope.toggleModal = function(){
        $scope.showModal = !$scope.showModal;
    };

    $scope.generateEmbed = function(id){
        API.getFileWithId(id).success(function(data, status, headers, config){
            $scope.embedScript = '<div id="stackfile"></div><script type="text/javascript" src="http://code.jquery.com/jquery-2.0.3.min.js"></script><script>WebFontConfig={google:{families:["Lato::latin"]}},function(){var t=document.createElement("script");'+
            't.src=("https:"==document.location.protocol?"https":"http")+"://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js",'+
            't.type="text/javascript",t.async="true";var e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(t,e)}();'+
            'var file=document.createElement("pre");$.get("http://staging.stackfiles.io/api/v1/user/repos/embed?user='+data.user+'&repository='+data.projectName+'&branch='+data.branch+'&path='+data.path+'").done(function(t){file.setAttribute("id","stack");'+
            'var e=document.createElement("p");e.setAttribute("style","padding: 15px 20px 15px 20px"),$(e).append(t),file.setAttribute("style","width: 516px; max-height: 500px; border: 1px solid #999999; border-radius: 2px;'+
            '  overflow: auto; display:inline-block;");var p=document.createElement("div");p.setAttribute("style","font-family: \'Lato\'; font-size: 14px; margin-top: 40px; border-top: 1px solid #999999; height:54px; width: 100%;"),'+
            '$("#stack").append($(e)),$(p).append("<p style=\'display: inline-block; padding: 20px 0px 18px 13px; margin: 0;\'>Stackfile hosted by </p><a href=\'http://tutum.co\' style=\'color: #2196F3; text-decoration: none;\'>Tutum</a><span><a style=\'float:right; padding: 6px 9px 6px 9px; line-height: 20px;'+
            ' font-size: 14px; font-weight: 700; border-radius: 2px; border: 2px solid #FFFFFF; text-transform: uppercase; color: #2196F3; border-color: #2196F3; text-decoration: none; margin-top: 10px; margin-right: 18px;\''+
            ' href=\'https://dashboard.tutum.co/stack/deploy/?repo='+ data.profileLink + '/' + data.projectName + '\'>Deploy to Tutum</a></span>"),$("#stack").append($(p))}),$(file).appendTo($("#stackfile"));</script>';
        }).error(function(data, status, headers, config){
            $scope.embedScript = 'Unable to generate the embed script. Please try again.';
        });
    };

    $scope.signin = function(page){
        API.signin(page);
    };

    $scope.deploy = function(id){
        window.location.href = ('/api/v1/deploy/'+id);
    };

    API.getFiles().success(function(data, status, headers, config){
        $scope.files = data;
        $scope.loaded = true;
    }).error(function(data, status, headers, config){
        $scope.err = true;
    });

    $scope.searchFile = function(){
        var term = this.data.search;
        API.searchFile(term).success(function(data, status, headers, config){
            $scope.results = data;
        }).error(function(data, status, headers, config){
            $scope.err = true;
        });
    };

    $scope.checkSearch = function(){
        if(Search.getValue().search !== null){
            $scope.data = Search.getValue();
            $scope.searchFile(Search.getValue());
        }
    };

    $scope.toggleStatus = function(file) {
        $scope.favoriteList.push(file._id);
        API.favFile(file._id).success(function(data, status, headers, config){

        }).error(function(data, status, headers, config){
            $scope.err = true;
        });
    };
    $scope.isSelected = function(file) {
        return $scope.favoriteList.indexOf(file._id) > -1;
})

.controller('RegistryDetailsController', function($scope, $rootScope, $window, $routeParams, API){

    $scope.favoriteList = [];
    $scope.user = $rootScope.getUser();

    API.getFileWithId($routeParams.registryId).success(function(data, status, headers, config){
        $scope.data = data;
        API.getYAMLFile(data._id, data.projectName, data.path).success(function(yamlData, status, headers, config){
            $scope.composeFile = yamlData;
            $scope.loaded = true;
{'fraction_non_alphanumeric': 0.19495505943751812, 'fraction_numerical': 0.019715859669469413, 'mean_word_length': 3.5146596858638746, 'pattern_counts': {'":': 8, '<': 59, '<?xml version=': 0, '>': 61, 'https://': 4, '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': '7448774', 'n_tokens_mistral': 5653, 'n_tokens_neox': 5334, 'n_words': 875}