<commit_before>$ = require 'jquery'
_ = require 'underscore'
{Chrome, File, Dir} = require 'osx'
Editor = require 'editor'

{Chrome, Dir, File, Process} = require 'osx'
{bindKey} = require 'editor'

exports.init = ->
  @html = File.read Chrome.appRoot() + "/plugins/project/project.html"

  bindKey 'toggleProjectDrawer', 'Command-Ctrl-N', (env) =>
    @toggle()

  $('#project .file').live 'click', (event) =>
    el = $(event.currentTarget)
    path =  decodeURIComponent el.attr 'path'
    Editor.open path

exports.toggle = ->
  if @showing
    $('#project').parent().remove()
  else
    Chrome.addPane 'left', @html
    @reload()

  @showing = not @showing

exports.reload = ->
  dir = OSX.NSFileManager.defaultManager.currentDirectoryPath
  $('#project .cwd').text dir

  files = Dir.list dir
  listItems = _.map files, (path) ->
    filename = path.replace(dir, "").substring 1
    type = if Dir.isDir(path) then 'dir' else 'file'
    "<li class='#{type}' path='#{encodeURIComponent path}'>#{filename}</li>"

  $('#project .files').append listItems.join '\n'
<commit_msg>we can require() any files we want! non-js files come back as plaintext.<commit_after>$ = require 'jquery'
_ = require 'underscore'
{Chrome, File, Dir} = require 'osx'
Editor = require 'editor'

{Chrome, Dir, File, Process} = require 'osx'
{bindKey} = require 'editor'

exports.init = ->
  @html = require "project/project.html"

  bindKey 'toggleProjectDrawer', 'Command-Ctrl-N', (env) =>
    @toggle()

  $('#project .file').live 'click', (event) =>
    el = $(event.currentTarget)
    path =  decodeURIComponent el.attr 'path'
    Editor.open path

exports.toggle = ->
  if @showing
    $('#project').parent().remove()
  else
    Chrome.addPane 'left', @html
    @reload()

  @showing = not @showing

exports.reload = ->
  dir = OSX.NSFileManager.defaultManager.currentDirectoryPath
  $('#project .cwd').text dir

  files = Dir.list dir
  listItems = _.map files, (path) ->
    filename = path.replace(dir, "").substring 1
    type = if Dir.isDir(path) then 'dir' else 'file'
    "<li class='#{type}' path='#{encodeURIComponent path}'>#{filename}</li>"

  $('#project .files').append listItems.join '\n'

{'fraction_non_alphanumeric': 0.1757437070938215, 'fraction_numerical': 0.0009153318077803204, 'mean_word_length': 3.7833698030634575, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6935231', 'n_tokens_mistral': 726, 'n_tokens_neox': 735, 'n_words': 187}