<commit_before>var render = require('./render'),
  util = require('./util'),
  file = util.file,
  yfm = util.yfm,
  partial = util.partial,
  async = require('async'),
  path = require('path'),
  _ = require('underscore'),
  cache = {};

var config = exports.config = {};

exports.init = function(callback){
  render.compile(hexo.theme_dir + '_config.yml', function(err, file){
    if (err) throw err;

    if (file){
      for (var i in file){
        (function(i){
          config.__defineGetter__(i, function(){
            return file[i];
          });
        })(i);

        callback();
      }
      console.log(file);
    } else {
      callback();
    }
  });
};

exports.assets = function(callback){
  var themeDir = hexo.theme_dir,
    publicDir = hexo.public_dir;

  file.dir(themeDir, function(files){
    async.forEach(files, function(item, next){
      var extname = path.extname(item),
        filename = path.basename(item, extname),
        dirs = item.split('/');

      for (var i=0, len=dirs.length; i<len; i++){
        var front = dirs[i].substring(0, 1);
        if (front === '_' || front === '.'){
          return next(null);
        }
      }

      if (dirs[0] === 'layout'){
        file.read(themeDir + item, function(err, file){
          if (err) throw err;
          cache[filename] = yfm(file);
          cache[filename].source = themeDir + item;
          next(null);
        });
      } else {
        render.compile(themeDir + item, function(err, result, output){
          if (err) throw err;
          file.write(publicDir + item.replace(extname, '.' + output), result, next);
        });
      }
    }, callback);
  })
};

exports.render = function(template, locals, callback){
  if (_.isFunction(locals)){
    callback = locals;
    locals = {};
  }
<commit_msg>Fixed theme assets copy<commit_after>var render = require('./render'),
  util = require('./util'),
  file = util.file,
  yfm = util.yfm,
  partial = util.partial,
  async = require('async'),
  path = require('path'),
  _ = require('underscore'),
  cache = {};

var config = exports.config = {};

exports.init = function(callback){
  render.compile(hexo.theme_dir + '_config.yml', function(err, file){
    if (err) throw err;

    if (file){
      for (var i in file){
        (function(i){
          config.__defineGetter__(i, function(){
            return file[i];
          });
        })(i);

        callback();
      }
    } else {
      callback();
    }
  });
};

exports.assets = function(callback){
  var themeDir = hexo.theme_dir,
    publicDir = hexo.public_dir;

  file.dir(themeDir, function(files){
    async.forEach(files, function(item, next){
      var extname = path.extname(item),
        filename = path.basename(item, extname),
        dirs = item.split('/');

      for (var i=0, len=dirs.length; i<len; i++){
        var front = dirs[i].substring(0, 1);
        if (front === '_' || front === '.'){
          return next(null);
        }
      }

      if (dirs[0] === 'layout'){
        file.read(themeDir + item, function(err, file){
          if (err) throw err;
          cache[filename] = yfm(file);
          cache[filename].source = themeDir + item;
          next(null);
        });
      } else {
        render.compile(themeDir + item, function(err, result, output){
          if (err) throw err;
          var outputFile = output ? item.replace(extname, '.' + output) : item;
          file.write(publicDir + outputFile, result, next);
        });
      }
    }, callback);
  })
};

exports.render = function(template, locals, callback){
  if (_.isFunction(locals)){
    callback = locals;
    locals = {};
  }

{'fraction_non_alphanumeric': 0.16757940854326397, 'fraction_numerical': 0.002190580503833516, 'mean_word_length': 2.279174147217235, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2519318', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1141, 'n_words': 255}