<commit_before>(function() {
    'use strict';

    var DEFAULT_TRUNCATE_LENGTH = 160;
    var app = angular.module('portal.misc.filters', []);

    app.filter('truncate', function() {
        return function(input, maxlen, useEllipsis) {
            maxlen = maxlen || DEFAULT_TRUNCATE_LENGTH;
            useEllipsis = angular.isDefined(useEllipsis) ? !!useEllipsis : true;

            if (input && input.length > maxlen) {
                return useEllipsis ?
                        input.substring(0, maxlen - 3) + '...' :
                        input.substring(0, maxlen);
            }

            return input;
        };
    });
    app.filter('showApplicable', function() {
        return function(portlets, showAll) {
            var filteredPortlets = [];
            if (showAll === true) {
              return portlets;
            }
            if (showAll === false) {
              angular.forEach(portlets, function(portlet) {
                if ( portlet.canAdd === true) {
                  filteredPortlets.push(portlet);
                }
              });
              return filteredPortlets;
            }
        };
    });
    app.filter('showCategory', function () {
      return function (portlets, category) {
        if (category === "") {
          return portlets;
        }
        var filtered = [];
        for (var i = 0; i < portlets.length; i++) {
          var portlet = portlets[i];
          for (var j=0; j < portlet.categories.length; j++) {
            if (portlet.categories[j] === category) {
              filtered.push(portlet);
            }
          }
        }
        return filtered;
      };
    });
} ());
<commit_msg>Add `to_trusted` filter.<commit_after>(function() {
    'use strict';

    var DEFAULT_TRUNCATE_LENGTH = 160;
    var app = angular.module('portal.misc.filters', []);

    app.filter('truncate', function() {
        return function(input, maxlen, useEllipsis) {
            maxlen = maxlen || DEFAULT_TRUNCATE_LENGTH;
            useEllipsis = angular.isDefined(useEllipsis) ? !!useEllipsis : true;

            if (input && input.length > maxlen) {
                return useEllipsis ?
                        input.substring(0, maxlen - 3) + '...' :
                        input.substring(0, maxlen);
            }

            return input;
        };
    });
    app.filter('showApplicable', function() {
        return function(portlets, showAll) {
            var filteredPortlets = [];
            if (showAll === true) {
              return portlets;
            }
            if (showAll === false) {
              angular.forEach(portlets, function(portlet) {
                if ( portlet.canAdd === true) {
                  filteredPortlets.push(portlet);
                }
              });
              return filteredPortlets;
            }
        };
    });
    app.filter('showCategory', function () {
      return function (portlets, category) {
        if (category === "") {
          return portlets;
        }
        var filtered = [];
        for (var i = 0; i < portlets.length; i++) {
          var portlet = portlets[i];
          for (var j=0; j < portlet.categories.length; j++) {
            if (portlet.categories[j] === category) {
              filtered.push(portlet);
            }
          }
        }
        return filtered;
      };
    });
    
    /* WARNING: THIS FILTER IS DANGEROUS.
       You should only filter to trusted status HTML that you are
       absolutely sure you can trust 
       (i.e., it definitely did not come from end user input, 
       it only is from a trusted source.)
       
       If you don't understand what this filter does, no worries,
       but then you really shouldn't be using it! :)
     */
    app.filter('to_trusted', ['$sce', function($sce){
      return function(text) {
          return $sce.trustAsHtml(text);
      };
    }]);
} ());

{'fraction_non_alphanumeric': 0.12471190781049936, 'fraction_numerical': 0.00409731113956466, 'mean_word_length': 1.547945205479452, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '6434490', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1060, 'n_words': 249}