<commit_before>/*
 * Copyright 2014 <NAME>. (http://www.onehippo.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

(function () {
    "use strict";
    angular.module('hippo.essentials')

        //############################################
        // MENU DATA
        //############################################
        .service('menuService', function () {
            this.getMenu = function () {
                return [
                    {name: "Plugins", link: "#/plugins"},
                    {name: "Tools", link: "#/tools"}
                ];
            };

        })

        //############################################
        // PLUGINS CONTROLLER LOADER
        //############################################
        .controller('pluginLoaderCtrl', function ($scope, $sce, $log, $rootScope, $http, $filter) {

        })
        .controller('introductionCtrl', function ($scope, $location, $sce, $log, $rootScope, $http) {
            // just sets a hide screen boolean flag to true
            $scope.addUrl = function () {
                $scope.projectSettings.pluginRepositories.push('');
            };

            $scope.removeUrl = function (url) {
                var idx = $scope.projectSettings.pluginRepositories.indexOf(url);
                if (idx > -1) {
                     $scope.projectSettings.pluginRepositories.splice(idx, 1);
                }
            };
            $scope.getStarted = function () {
                // mark setup as done...
                $scope.projectSettings.setupDone = true;
                $http.post($rootScope.REST.save_settings, $scope.projectSettings).success(function (data) {
                    window.location = "/essentials";
                });

            }
            $scope.setup = function () {
                $http.get($rootScope.REST.project_settings).success(function (data) {
                    $scope.projectSettings = data;
                    // set some defaults
                    $scope.projectSettings.templateLanguage = 'jsp';
                    $scope.projectSettings.useSamples = true;
                });
            }
            // initialize
            $scope.setup();

        })
        .controller('pluginCtrl', function ($scope, $location, $sce, $log, $rootScope, $http) {

            $scope.allPluginsInstalled = "No additional plugins could be found";
            $scope.plugins = [];
            $scope.pluginNeedsInstall = [];
            $scope.selectedPlugin = null;
            $scope.tabs = [
                {name: "Installed Plugins", link: "/plugins"},
                {name: "Find", link: "/find-plugins"}
            ];
            $scope.isPageSelected = function (path) {
                return $location.path() == path;
            };
            $scope.isTabSelected = function (path) {
                var myPath = $location.path();
                return  myPath.indexOf(path) != -1;
            };
            $scope.isMenuSelected = function (path) {
                var myPath = $location.path();
                return  myPath.indexOf(path) != -1;
            };


            $scope.showPluginDetail = function (pluginId) {
                $scope.selectedPlugin = extracted(pluginId);
                $rootScope.selectedPlugin = extracted(pluginId);
            };
            $scope.installPlugin = function (pluginId) {
                $rootScope.pluginsCache = null;
                $scope.selectedPlugin = extracted(pluginId);
                if ($scope.selectedPlugin) {
                    $http.post($rootScope.REST.pluginInstall + pluginId).success(function (data) {
                        // we'll get error message or
                        $scope.init();
                    });
                }
            };


            //fetch plugin list
            $scope.init = function () {

                if ($rootScope.pluginsCache) {
                    processItems($rootScope.pluginsCache);
                } else {
                    $http.get($rootScope.REST.plugins).success(function (data) {
                        var items = data.items;
                        $rootScope.pluginsCache = items;
                        processItems(items);
                        // fetch remote repositories:
                        console.log(">>> LOCAL <<<");
                        fetchRemote(items)
                        function fetchRemote(items) {

                            if(!items){
                                items = [];
                            }
                            $http.get($rootScope.REST.plugins  + "remote").success(function (data) {
                                console.log("==========================================");
                                console.log("==========================================");
                                console.log("==========================================");
                                console.log(" >>> remote data");
                                console.log(data.items);
                                items.concat(data.items);
                                console.log("+++++++++++++++++++++++++++++++++++++++===");
                                var all = items.concat(data.items);
                                console.log(all);
                                $rootScope.pluginsCache = all;
                                processItems(items);
                            });
                        }


                    });


                }

                function processItems(items) {
                    $scope.plugins = items;
                    $scope.pluginNeedsInstall = [];
                    angular.forEach(items, function (obj) {
                        if (obj.needsInstallation) {
                            $scope.pluginNeedsInstall.push(obj);
                        }
                    });
                }
            };
            $scope.init();
            function extracted(pluginId) {
                var sel = null;
                angular.forEach($scope.plugins, function (selected) {
                    if (selected.pluginId == pluginId) {
                        sel = selected;<commit_msg>- cleanup logging<commit_after>/*
 * Copyright 2014 <NAME>.V. (http://www.onehippo.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

(function () {
    "use strict";
    angular.module('hippo.essentials')

        //############################################
        // MENU DATA
        //############################################
        .service('menuService', function () {
            this.getMenu = function () {
                return [
                    {name: "Plugins", link: "#/plugins"},
                    {name: "Tools", link: "#/tools"}
                ];
            };

        })

        //############################################
        // PLUGINS CONTROLLER LOADER
        //############################################
        .controller('pluginLoaderCtrl', function ($scope, $sce, $log, $rootScope, $http, $filter) {

        })
        .controller('introductionCtrl', function ($scope, $location, $sce, $log, $rootScope, $http) {
            // just sets a hide screen boolean flag to true
            $scope.addUrl = function () {
                $scope.projectSettings.pluginRepositories.push('');
            };

            $scope.removeUrl = function (url) {
                var idx = $scope.projectSettings.pluginRepositories.indexOf(url);
                if (idx > -1) {
                     $scope.projectSettings.pluginRepositories.splice(idx, 1);
                }
            };
            $scope.getStarted = function () {
                // mark setup as done...
                $scope.projectSettings.setupDone = true;
                $http.post($rootScope.REST.save_settings, $scope.projectSettings).success(function (data) {
                    window.location = "/essentials";
                });

            }
            $scope.setup = function () {
                $http.get($rootScope.REST.project_settings).success(function (data) {
                    $scope.projectSettings = data;
                    // set some defaults
                    $scope.projectSettings.templateLanguage = 'jsp';
                    $scope.projectSettings.useSamples = true;
                });
            }
            // initialize
            $scope.setup();

        })
        .controller('pluginCtrl', function ($scope, $location, $sce, $log, $rootScope, $http) {

            $scope.allPluginsInstalled = "No additional plugins could be found";
            $scope.plugins = [];
            $scope.pluginNeedsInstall = [];
            $scope.selectedPlugin = null;
            $scope.tabs = [
                {name: "Installed Plugins", link: "/plugins"},
                {name: "Find", link: "/find-plugins"}
            ];
            $scope.isPageSelected = function (path) {
                return $location.path() == path;
            };
            $scope.isTabSelected = function (path) {
                var myPath = $location.path();
                return  myPath.indexOf(path) != -1;
            };
            $scope.isMenuSelected = function (path) {
                var myPath = $location.path();
                return  myPath.indexOf(path) != -1;
            };


            $scope.showPluginDetail = function (pluginId) {
                $scope.selectedPlugin = extracted(pluginId);
                $rootScope.selectedPlugin = extracted(pluginId);
            };
            $scope.installPlugin = function (pluginId) {
                $rootScope.pluginsCache = null;
                $scope.selectedPlugin = extracted(pluginId);
                if ($scope.selectedPlugin) {
                    $http.post($rootScope.REST.pluginInstall + pluginId).success(function (data) {
                        // we'll get error message or
                        $scope.init();
                    });
                }
            };


            //fetch plugin list
            $scope.init = function () {

                if ($rootScope.pluginsCache) {
                    processItems($rootScope.pluginsCache);
                } else {
                    $http.get($rootScope.REST.plugins).success(function (data) {
                        var items = data.items;
                        $rootScope.pluginsCache = items;
                        processItems(items);
                        // fetch remote repositories:
                        fetchRemote(items)
                        function fetchRemote(items) {

                            if(!items){
                                items = [];
                            }
                            $http.get($rootScope.REST.plugins  + "remote").success(function (data) {
                                items.concat(data.items);
                                var all = items.concat(data.items);
                                $rootScope.pluginsCache = all;
                                processItems(items);
                            });
                        }


                    });


                }

                function processItems(items) {
                    $scope.plugins = items;
                    $scope.pluginNeedsInstall = [];
                    angular.forEach(items, function (obj) {
                        if (obj.needsInstallation) {
                            $scope.pluginNeedsInstall.push(obj);
                        }
                    });
                }
            };
            $scope.init();
            function extracted(pluginId) {
                var sel = null;
                angular.forEach($scope.plugins, function (selected) {
                    if (selected.pluginId == pluginId) {
                        sel = selected;
{'fraction_non_alphanumeric': 0.14717333748637285, 'fraction_numerical': 0.0018688677776047345, 'mean_word_length': 1.3278955954323002, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '670194', 'n_tokens_mistral': 3065, 'n_tokens_neox': 2835, 'n_words': 632}