<commit_before>import React from 'react';
import Router from 'react-router';
import routes from '../components/routes.jsx';
import englishStrings from '../locales/en-US.json';
import currencies from '../data/currencies.js';
import {localeCurrencyData, localeCountryData} from '../data/locale-data.js';
import url from 'url';
var fs = require('fs');
var Path = require('path');
var FS = require("q-io/fs");

module.exports = function(outputPath, callback) {
  Router.run(routes, outputPath, function(Handler) {
    var locale = url.parse(outputPath).pathname.split('/')[1];
    var currencyCode = localeCurrencyData[locale] || 'usd';
    var country = localeCountryData[locale] || 'US';
    var values = {
      currency: currencies[currencyCode],
      presets: currencies.usd.presets.single,
      amount: '',
      frequency: 'single',
      country: country
    };
    var index = React.createFactory(require('../pages/index.jsx'));
    var page = React.createFactory(Handler);
    var currentString, mergedStrings;

    if (locale && require('../locales/index.js').indexOf(locale) !== -1) {
      currentString = require('../locales/' + locale +'.json');
      mergedStrings = Object.assign({}, englishStrings, currentString);
      values = Object.assign({}, {locales : [locale], messages: mergedStrings}, values);
    } else {
      locale = 'en-US';
      values = Object.assign({}, {locales : [locale], messages: englishStrings}, values);
    }
    FS.makeTree(Path.join(__dirname, '..', 'public', outputPath)).then(function() {
      var contentOfTheFile = React.renderToStaticMarkup(index({
        localeInfo: locale,
        metaData: {
          desc: values.messages.i_donated_to_mozilla,
          title: values.messages.support_mozilla,
          site_name: 'mozilla.org',
          site_url: url.resolve(process.env.APPLICATION_URI, locale + '/'),
          site_title: values.messages.give_to_mozilla
        },
        markup: React.renderToStaticMarkup(page(values))
      }));

      var nameOfTheFile = Path.join(__dirname, '..', 'public', outputPath, 'index.html');

      fs.writeFile(nameOfTheFile, contentOfTheFile, function(err) {
        callback(err, nameOfTheFile);
      });
    });
  });
};<commit_msg>using renderToString instead of renderToStaticMarkup for route pages, but not for index<commit_after>import React from 'react';
import Router from 'react-router';
import routes from '../components/routes.jsx';
import englishStrings from '../locales/en-US.json';
import currencies from '../data/currencies.js';
import {localeCurrencyData, localeCountryData} from '../data/locale-data.js';
import url from 'url';
var fs = require('fs');
var Path = require('path');
var FS = require("q-io/fs");

module.exports = function(outputPath, callback) {
  Router.run(routes, outputPath, function(Handler) {
    var locale = url.parse(outputPath).pathname.split('/')[1];
    var currencyCode = localeCurrencyData[locale] || 'usd';
    var country = localeCountryData[locale] || 'US';
    var values = {
      currency: currencies[currencyCode],
      presets: currencies.usd.presets.single,
      amount: '',
      frequency: 'single',
      country: country
    };
    var index = React.createFactory(require('../pages/index.jsx'));
    var page = React.createFactory(Handler);
    var currentString, mergedStrings;

    if (locale && require('../locales/index.js').indexOf(locale) !== -1) {
      currentString = require('../locales/' + locale +'.json');
      mergedStrings = Object.assign({}, englishStrings, currentString);
      values = Object.assign({}, {locales : [locale], messages: mergedStrings}, values);
    } else {
      locale = 'en-US';
      values = Object.assign({}, {locales : [locale], messages: englishStrings}, values);
    }
    FS.makeTree(Path.join(__dirname, '..', 'public', outputPath)).then(function() {
      var contentOfTheFile = React.renderToStaticMarkup(index({
        localeInfo: locale,
        metaData: {
          desc: values.messages.i_donated_to_mozilla,
          title: values.messages.support_mozilla,
          site_name: 'mozilla.org',
          site_url: url.resolve(process.env.APPLICATION_URI, locale + '/'),
          site_title: values.messages.give_to_mozilla
        },
        markup: React.renderToString(page(values))
      }));

      var nameOfTheFile = Path.join(__dirname, '..', 'public', outputPath, 'index.html');

      fs.writeFile(nameOfTheFile, contentOfTheFile, function(err) {
        callback(err, nameOfTheFile);
      });
    });
  });
};
{'fraction_non_alphanumeric': 0.1545414462081129, 'fraction_numerical': 0.0008818342151675485, 'mean_word_length': 3.465551181102362, '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': '4376594', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1314, 'n_words': 285}