<commit_before>require 'rubygems'
require 'bundler/setup'
require 'sinatra'
require 'haml'
require 'rack-canonical-host'
require 'app/rk2gpx'

set :root, File.dirname(__FILE__) + '/..'
set :erb, :layout => :'layout.html'

if settings.environment == :production
	use Rack::CanonicalHost, 'rk2gpx.hyzkia.com'
end

helpers do
  include Rack::Utils
  alias_method :h, :escape_html

  def host
  	settings.environment == :production ?
  		'rk2gpx.hyzkia.com' :
  		'localhost:9292'
  end

  def bookmarklet
  	"(function(){var d=document,s=d.createElement('script');s.setAttribute('src','http://#{host}/bm.js');d.body.appendChild(s);})()"
  end
end

get '/' do 
	erb :'index.html'
end

get '/bm.js' do
	erb :'bm.js', :layout => false
end

post '/route' do
	@json  = params[:json]
	@route = Route.from_json(@json)
	erb :'route.html'
end

post '/route.gpx' do
	@json  = params[:json]
	@route = Route.from_json(@json)
	attachment   "#{@route.title}.gpx"
	content_type 'application/gpx+xml', :charset => 'utf-8'
	haml :'route.gpx'
end<commit_msg>Content type first to prevent Sinatra error<commit_after>require 'rubygems'
require 'bundler/setup'
require 'sinatra'
require 'haml'
require 'rack-canonical-host'
require 'app/rk2gpx'

set :root, File.dirname(__FILE__) + '/..'
set :erb, :layout => :'layout.html'

if settings.environment == :production
	use Rack::CanonicalHost, 'rk2gpx.hyzkia.com'
end

helpers do
  include Rack::Utils
  alias_method :h, :escape_html

  def host
  	settings.environment == :production ?
  		'rk2gpx.hyzkia.com' :
  		'localhost:9292'
  end

  def bookmarklet
  	"(function(){var d=document,s=d.createElement('script');s.setAttribute('src','http://#{host}/bm.js');d.body.appendChild(s);})()"
  end
end

get '/' do 
	erb :'index.html'
end

get '/bm.js' do
	erb :'bm.js', :layout => false
end

post '/route' do
	@json  = params[:json]
	@route = Route.from_json(@json)
	erb :'route.html'
end

post '/route.gpx' do
	@json  = params[:json]
	@route = Route.from_json(@json)
	content_type 'application/gpx+xml', :charset => 'utf-8'
	attachment   "#{@route.title}.gpx"
	haml :'route.gpx'
end
{'fraction_non_alphanumeric': 0.17490494296577946, 'fraction_numerical': 0.0076045627376425855, 'mean_word_length': 4.496083550913838, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7165124', 'n_tokens_mistral': 844, 'n_tokens_neox': 825, 'n_words': 175}