<commit_before>/**
 * User: rupin_t
 * Date: 7/22/13
 * Time: 11:00 AM
 */

(function ($) {
    var isCrawlable = navigator.userAgent == 'crawlable'; // TODO make it dynamic

    $.solidify = function (rawTemplate) {
        if (!isCrawlable) {
            var regex = /\{\{ *[#/]?solidify(-\w+)?[^\}]*\}\}/;
            while (rawTemplate.match(regex))
                rawTemplate = rawTemplate.replace(regex, '');

            regex = /((\{ )+\{|(\} )+\})/;
            while (rawTemplate.match(regex))
                rawTemplate = rawTemplate.replace(regex, function (expr) {
                    return expr.split(' ').join('');
                });
        }
        else {
            var inR = /\{\{ *#?(solidify(-\w+)?)[^\}]*\}\}/, s = rawTemplate;
            while (s.match(inR)) {
                s = s.replace(inR, function (__, name) {
                    Handlebars.registerHelper(name, function () {
                        var n = name.replace('solidify-', '');
                        if (_.isFunction($.solidify.addons[n]))
                            return $.solidify.addons[n].apply(this, arguments);
                        var options = arguments[arguments.length - 1],
                            args = _.map(_.toArray(arguments).slice(0, arguments.length - 1),function (e) {
                                return '"' + e + '"';
                            }).join(' '),
                            isScope = _.isFunction(options.fn);
                        return '{{' + (isScope ? '#' : '') + name + ' ' + args + '}}' + (isScope ? options.fn(this) + '{{/' + name + '}}' : '');
                    });
                    return '';
                });
            }
        }
        return Handlebars.compile(rawTemplate);
    };

    $.solidify.addons = {
        include: _.memoize(function (url) {
            var rawTemplate = '', $el;
            try {
                $el = $('#' + url);
            } catch (e) {
                $el = [];
            }
            if ($el.length)
                rawTemplate = $el.html();
            else
                $.ajax({ url: url, async: false })
                    .done(function (data) {
                        rawTemplate = data;
                    });
            return new Handlebars.SafeString($.solidify(rawTemplate)());
        })
    };
})(jQuery);<commit_msg>start implementing preCache<commit_after>/**
 * User: rupin_t
 * Date: 7/22/13
 * Time: 11:00 AM
 */

(function ($) {
    var isCrawlable = navigator.userAgent == 'crawlable'; // TODO make it dynamic

    $.solidify = function (rawTemplate) {
        if (!isCrawlable) {
            var regex = /\{\{ *[#/]?solidify(-\w+)?[^\}]*\}\}/;
            while (rawTemplate.match(regex))
                rawTemplate = rawTemplate.replace(regex, '');

            regex = /((\{ )+\{|(\} )+\})/;
            while (rawTemplate.match(regex))
                rawTemplate = rawTemplate.replace(regex, function (expr) {
                    return expr.split(' ').join('');
                });
        }
        else {
            var inR = /\{\{ *#?(solidify(-\w+)?)[^\}]*\}\}/, s = rawTemplate;
            while (s.match(inR)) {
                s = s.replace(inR, function (__, name) {
                    Handlebars.registerHelper(name, function () {
                        var n = name.replace('solidify-', '');
                        if (_.isFunction($.solidify.addons[n]))
                            return $.solidify.addons[n].apply(this, arguments);
                        var options = arguments[arguments.length - 1],
                            args = _.map(_.toArray(arguments).slice(0, arguments.length - 1),function (e) {
                                return '"' + e + '"';
                            }).join(' '),
                            isScope = _.isFunction(options.fn);
                        return '{{' + (isScope ? '#' : '') + name + ' ' + args + '}}' + (isScope ? options.fn(this) + '{{/' + name + '}}' : '');
                    });
                    return '';
                });
            }
        }
        return Handlebars.compile(rawTemplate);
    };

    $.solidify.addons = {
        include: _.memoize(function (url) {
            var rawTemplate = '', $el;
            try {
                $el = $('#' + url);
            } catch (e) {
                $el = [];
            }
            if ($el.length)
                rawTemplate = $el.html();
            else
                $.ajax({ url: url, async: false })
                    .done(function (data) {
                        rawTemplate = data;
                    });
            return new Handlebars.SafeString($.solidify(rawTemplate)());
        }),
        html: function (html) {
            return new Handlebars.SafeString(html);
        }
    };
})(jQuery);
{'fraction_non_alphanumeric': 0.17237798546209762, 'fraction_numerical': 0.004984423676012461, 'mean_word_length': 1.2234533702677748, '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': '7346900', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1293, 'n_words': 239}