<commit_before>_        = require('underscore')._
_.str    = require('underscore.string')
http     = require('http')
express  = require('express')
phantom  = require('phantom')
fs       = require('fs')
open     = require("open")

Document = require('./document')

class NotaServer
  constructor: ( @serverAddress, @serverPort, @templatePath, @data ) ->

    # Start express server to serve dependencies from a unified namespaces
    @app = express()
    @server = http.createServer(@app)

    # Open the server with servering the template path as root
    @app.use express.static(templatePath)
    # Serve 'template.html' by default (instead of index.html default behaviour)
    @app.get '/', ( req, res ) =>
      # Load template.html as index
      fs.readFile "#{@templatePath}/template.html", "utf8", ( err, html ) ->
        # Insert the nota loader in the head tag
        scriptTag = "<script data-main='nota' src='vendor/requirejs/require.js'>"
        res.send html.replace(/(<head[s\S]*>)([\s\S]*<\/head>)/, "$1\n#{scriptTag}</script>$2")

    # Expose some extras at the first specified subpaths
    @app.use '/lib/', express.static("#{__dirname}/")
    @app.use '/vendor/', express.static("#{__dirname}/../bower_components/")
    @app.use '/nota.js', express.static("#{__dirname}/client-config.js")

    @app.get '/data.json', ( req, res ) ->
      res.send JSON.stringify(@data)

    @server.listen(serverPort)<commit_msg>JS scoping ftw<commit_after>_        = require('underscore')._
_.str    = require('underscore.string')
http     = require('http')
express  = require('express')
phantom  = require('phantom')
fs       = require('fs')
open     = require("open")

Document = require('./document')

class NotaServer
  constructor: ( @serverAddress, @serverPort, @templatePath, @data ) ->

    # Start express server to serve dependencies from a unified namespaces
    @app = express()
    @server = http.createServer(@app)

    # Open the server with servering the template path as root
    @app.use express.static(templatePath)
    # Serve 'template.html' by default (instead of index.html default behaviour)
    @app.get '/', ( req, res ) =>
      # Load template.html as index
      fs.readFile "#{@templatePath}/template.html", "utf8", ( err, html ) ->
        # Insert the nota loader in the head tag
        scriptTag = "<script data-main='nota' src='vendor/requirejs/require.js'>"
        res.send html.replace(/(<head[s\S]*>)([\s\S]*<\/head>)/, "$1\n#{scriptTag}</script>$2")

    # Expose some extras at the first specified subpaths
    @app.use '/lib/', express.static("#{__dirname}/")
    @app.use '/vendor/', express.static("#{__dirname}/../bower_components/")
    @app.use '/nota.js', express.static("#{__dirname}/client-config.js")

    @app.get '/data.json', ( req, res ) =>
      res.send JSON.stringify(@data)

    @server.listen(serverPort)
{'fraction_non_alphanumeric': 0.16997561825148033, 'fraction_numerical': 0.0020898641588296763, 'mean_word_length': 3.364741641337386, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, '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': '6371743', 'n_tokens_mistral': 901, 'n_tokens_neox': 873, 'n_words': 219}