<commit_before>require 'sinatra'
require 'haml'

require_relative 'lib/recording'
require_relative 'lib/recordings'
require_relative 'lib/user'
require_relative 'lib/users'

# Shows the recordings grouped by users.
#
get %r{(?<path>[\/\w]+)\/users\/?$} do
  @path = params[:path]
  
  @users = Users.new(@path).map_uuids do |uuid|
    user = User.load_from @path, uuid
    user.load_recordings @path
    user
  end
  @users.sort_by! &:name
  
  haml :users
end

# Shows all the recordings.
#
get %r{(?<path>[\/\w]+)\/recordings\/?$} do
  @path = params[:path]
  
  @recordings = Recordings.new(@path).map_uuids do |uuid|
    Recording.load_from @path, uuid
  end
  
  haml :recordings
end

# Returns a file if requested.
#
get %r{(?<path>[\/\w]+)\/recordings\/(?<uuid>[0-9a-f\-]+)\.\w+$} do
  recording = Recording.load_from params[:path], params[:uuid]
  
  send_file recording.path
end<commit_msg>+ make it work on an SD card, including space characters in the name<commit_after>require 'sinatra'
require 'haml'

require_relative 'lib/recording'
require_relative 'lib/recordings'
require_relative 'lib/user'
require_relative 'lib/users'

# Shows the recordings grouped by users.
#
get %r{(?<path>.+)\/users\/?$} do
  @path = params[:path]
  
  @users = Users.new(@path).map_uuids do |uuid|
    user = User.load_from @path, uuid
    user.load_recordings @path
    user
  end
  @users.sort_by! &:name
  
  haml :users
end

# Shows all the recordings.
#
get %r{(?<path>.+)\/recordings\/?$} do
  @path = params[:path]
  
  @recordings = Recordings.new(@path).map_uuids do |uuid|
    Recording.load_from @path, uuid
  end
  
  haml :recordings
end

# Returns a file if requested.
#
get %r{(?<path>.+)\/recordings\/(?<uuid>[0-9a-f\-]+)\.\w+$} do
  recording = Recording.load_from params[:path], params[:uuid]
  
  send_file recording.path
end
{'fraction_non_alphanumeric': 0.16539717083786726, 'fraction_numerical': 0.002176278563656148, 'mean_word_length': 3.7890625, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5670342', 'n_tokens_mistral': 694, 'n_tokens_neox': 691, 'n_words': 162}