<commit_before>'use strict';

module.exports = function(grunt) {

    var ph_libutil = require("phantomizer-libutil");
    var phantomizer_helper = ph_libutil.phantomizer_helper;

    grunt.registerMultiTask("phantomizer-dir-inject-html-extras", "Inject extras phantomizer loader into html directory", function () {

        var options = this.options();

        var in_dir = options.in_dir;

        var requirejs_src = options.requirejs.src;
        var requirejs_baseUrl = options.requirejs.baseUrl;

        var files = grunt.file.expand(in_dir+"**/*.{html,htm}");

        for( var n in files ){
            var file = files[n];
            var retour = grunt.file.read(file);
            retour = inject_extras(retour,requirejs_baseUrl,requirejs_src);
            grunt.file.write(file, retour);
            grunt.log.ok("Extras inject in "+file)
        }
    });
    function inject_extras(buf,requirejs_baseUrl,requirejs_src){
        buf = phantomizer_helper.inject_requirejs(requirejs_baseUrl, requirejs_src, buf, null)

        var injected = '/js/vendors/go-phantomizer/extras-loader.js';
        buf = phantomizer_helper.inject_after_requirejs(requirejs_baseUrl,requirejs_src, buf, injected)
        return buf;<commit_msg>Fixed bug where it was not posssible to include a requirejs main script when the routed request was not in www-core folder<commit_after>'use strict';

module.exports = function(grunt) {

    var ph_libutil = require("phantomizer-libutil");
    var phantomizer_helper = ph_libutil.phantomizer_helper;

    grunt.registerMultiTask("phantomizer-dir-inject-html-extras", "Scan a directory and inject extra html into all html / htm files", function () {

        var options = this.options();

        var in_dir = options.in_dir;

        var requirejs_src = options.requirejs.src;
        var requirejs_baseUrl = options.requirejs.baseUrl;
        var requirejs_paths = options.requirejs.paths;

        var files = grunt.file.expand(in_dir+"**/*.{html,htm}");

        for( var n in files ){
            var file = files[n];
            var retour = grunt.file.read(file);
            retour = inject_extras(retour,requirejs_baseUrl,requirejs_src, requirejs_paths);
            grunt.file.write(file, retour);
            grunt.log.ok("Extras inject in "+file)
        }
    });
    function inject_extras(buf,requirejs_baseUrl,requirejs_src, requirejs_paths){
        buf = phantomizer_helper.inject_requirejs(requirejs_baseUrl, requirejs_src, requirejs_paths, buf, null)

        var injected = '/js/vendors/go-phantomizer/extras-loader.js';
        buf = phantomizer_helper.inject_after_requirejs(requirejs_baseUrl,requirejs_src, requirejs_paths, buf, injected)
        return buf;
{'fraction_non_alphanumeric': 0.1036764705882353, 'fraction_numerical': 0.0, 'mean_word_length': 3.2251552795031055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '6386684', 'n_tokens_mistral': 854, 'n_tokens_neox': 813, 'n_words': 170}