<commit_before>require 'sinatra/base'
require 'sinatra/respond_to'

class Polytexnic::App < Sinatra::Base
  register Sinatra::RespondTo

  set :public_folder, File.join(File.dirname(__FILE__),'../template/html')
  set :bind, '0.0.0.0'

  before do
    @manifest = Polytexnic::BookManifest.new
  end

  get '/' do
    # redirect to first chapter
    redirect @manifest.chapters.first.slug
  end

  get '/refresh' do
    require 'coffee_script'
    @mathjax_src    = Polytexnic::Mathjax::AMS_HTML
    coffee erb :refresh
  end

  get '/stylesheets/pygments' do
    @pygments_css ||= Pygments.send(:mentos, :css, ['html', '']).
                               gsub!(/^/, '.highlight ')
  end

  # Gets the image specified by the path and content type.
  get '/images/*' do |path|
    extension  = response.header['Content-Type'].split('/').last
    # Arrange to handle both '.jpeg' and '.jpg' extensions.
    if extension == 'jpeg' && !File.exist?(image_filename(path, extension))
      extension = 'jpg'
    end
    File.read(image_filename(path, extension))
  end
<commit_msg>Implement (restore?) math numbering in server HTML<commit_after>require 'sinatra/base'
require 'sinatra/respond_to'

class Polytexnic::App < Sinatra::Base
  register Sinatra::RespondTo

  set :public_folder, File.join(File.dirname(__FILE__),'../template/html')
  set :bind, '0.0.0.0'

  before do
    @manifest = Polytexnic::BookManifest.new
  end

  get '/' do
    # redirect to first chapter
    redirect @manifest.chapters.first.slug
  end

  get '/refresh' do
    require 'coffee_script'
    @mathjax_src    = Polytexnic::Mathjax::AMS_HTML
    @mathjax_config = Polytexnic::Mathjax.config
    coffee erb :refresh
  end

  get '/stylesheets/pygments' do
    @pygments_css ||= Pygments.send(:mentos, :css, ['html', '']).
                               gsub!(/^/, '.highlight ')
  end

  # Gets the image specified by the path and content type.
  get '/images/*' do |path|
    extension  = response.header['Content-Type'].split('/').last
    # Arrange to handle both '.jpeg' and '.jpg' extensions.
    if extension == 'jpeg' && !File.exist?(image_filename(path, extension))
      extension = 'jpg'
    end
    File.read(image_filename(path, extension))
  end

{'fraction_non_alphanumeric': 0.1378692927484333, 'fraction_numerical': 0.0035810205908683975, 'mean_word_length': 3.177570093457944, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7292536', 'n_tokens_mistral': 742, 'n_tokens_neox': 712, 'n_words': 178}