<commit_before>'use strict'

var fs = require('fs')
var path = require('path')
var util = require('util')
var http = require('http')
var opbeat = require('opbeat')()
var debug = require('debug')('followers')
var patterns = require('patterns')()
var request = require('request')
var csv = require('csv-parser')
var Handlebars = require('handlebars')
var pkg = require('./package')

var githubUsername = /^([A-Za-z\d]|[A-Za-z\d][-A-Za-z\d]*[A-Za-z\d])$/
var userAgent = pkg.name + '/' + pkg.version
var css = new Handlebars.SafeString(fs.readFileSync(path.join(__dirname, 'style.css')).toString())
var tmpl = Handlebars.compile(fs.readFileSync(path.join(__dirname, 'tmpl.html')).toString())
var top10k = []

debug('Loading top 10k GitHub users')
fs.createReadStream(path.join(__dirname, 'top-10K.csv'))
  .pipe(csv())
  .on('data', function (data) {
    top10k.push(data.login)
  })
  .on('end', function () {
    debug('Finished loading top 10k GitHub users')
  })

var userDiv = function (login, avatar, rank) {
  rank = rank ? '#' + rank : 'no rank'
  return util.format('<div class=user style="background-image: url(%s)"><a href="https://github.com/%s"><span class=name>%s</span><span class=rank>%s</span></a></div>', avatar, login, login, rank)
}

var respond = function (res, body, status) {
  body = tmpl({
    css: css,
    gaTrackingId: process.env.GA_TRACKING_ID,
    body: new Handlebars.SafeString(body)
  })
  res.writeHead(status || 200, {
    'Content-Type': 'text/html; charset=utf-8',
    'Content-Length': Buffer.byteLength(body)
  })
  res.end(body)
}

patterns.add('GET /', function (req, res) {
  respond(res, '')
})

patterns.add('GET /{username}', function (req, res) {
  var username = req.params.username

  if (!githubUsername.test(username)) {<commit_msg>Add copy to front page<commit_after>'use strict'

var fs = require('fs')
var path = require('path')
var util = require('util')
var http = require('http')
var opbeat = require('opbeat')()
var debug = require('debug')('followers')
var patterns = require('patterns')()
var request = require('request')
var csv = require('csv-parser')
var Handlebars = require('handlebars')
var pkg = require('./package')

var githubUsername = /^([A-Za-z\d]|[A-Za-z\d][-A-Za-z\d]*[A-Za-z\d])$/
var userAgent = pkg.name + '/' + pkg.version
var css = new Handlebars.SafeString(fs.readFileSync(path.join(__dirname, 'style.css')).toString())
var tmpl = Handlebars.compile(fs.readFileSync(path.join(__dirname, 'tmpl.html')).toString())
var top10k = []

debug('Loading top 10k GitHub users')
fs.createReadStream(path.join(__dirname, 'top-10K.csv'))
  .pipe(csv())
  .on('data', function (data) {
    top10k.push(data.login)
  })
  .on('end', function () {
    debug('Finished loading top 10k GitHub users')
  })

var userDiv = function (login, avatar, rank) {
  rank = rank ? '#' + rank : 'no rank'
  return util.format('<div class=user style="background-image: url(%s)"><a href="https://github.com/%s"><span class=name>%s</span><span class=rank>%s</span></a></div>', avatar, login, login, rank)
}

var respond = function (res, body, status) {
  body = tmpl({
    css: css,
    gaTrackingId: process.env.GA_TRACKING_ID,
    body: new Handlebars.SafeString(body)
  })
  res.writeHead(status || 200, {
    'Content-Type': 'text/html; charset=utf-8',
    'Content-Length': Buffer.byteLength(body)
  })
  res.end(body)
}

patterns.add('GET /', function (req, res) {
  var body = '<h1>Does someone famous follow you on GitHub?</h1>' +
    '<p>Enter your GitHub username below to see who among the top 10k most active GitHub users follow you:</p>'
  respond(res, body)
})

patterns.add('GET /{username}', function (req, res) {
  var username = req.params.username

  if (!githubUsername.test(username)) {
{'fraction_non_alphanumeric': 0.1914156225006665, 'fraction_numerical': 0.008531058384430818, 'mean_word_length': 4.6, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 2, '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': '28083', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1297, 'n_words': 300}