<commit_before># Inspired by the following:
# http://rubylearning.com/blog/2009/03/20/interview-ryan-tomayko-on-sinatra/
# https://gist.github.com/8ff54cdfd44e1a6485e2
# http://ididitmyway.heroku.com/past/2010/11/9/sinatra_settings_and_configuration/

require 'rubygems'
require 'sinatra'
require 'sinatra/flash'
require 'dm-core'
require 'dm-validations'
require 'dm-types'
require 'dm-migrations'
require 'dm-postgres-adapter'
require 'rdiscount'
require 'rack-ssl-enforcer'

DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/database.db")

class Page 
  include DataMapper::Resource
  property :id,           Serial
  property :slug,         String
  property :title,        String
  property :content,      Text
  property :last_updated, DateTime  
  property :sidebar,      Enum[ :yes, :no ], :default => :no
end

DataMapper.finalize

# Global variables
NAV_TITLE = 'Main'
FOOTER = '\<em>Not everything that is more difficult is more meritorious.\</em> - \<strong><NAME>\</strong>'

# Authentication
use Rack::Auth::Basic, "Restricted Area" do |username, password|
  [username, password] == [ENV['ADMIN_USER'], ENV['ADMIN_PASS']]
end

# Force all connections to use SSL
use Rack::SslEnforcer

# Converts page name into post slug
def slugify(content)
  content.downcase.gsub(/ /, '-').gsub(/[^a-z0-9_-]/, '').squeeze('-')<commit_msg>Fix edit button alignment<commit_after># Inspired by the following:
# http://rubylearning.com/blog/2009/03/20/interview-ryan-tomayko-on-sinatra/
# https://gist.github.com/8ff54cdfd44e1a6485e2
# http://ididitmyway.heroku.com/past/2010/11/9/sinatra_settings_and_configuration/

require 'rubygems'
require 'sinatra'
require 'sinatra/flash'
require 'dm-core'
require 'dm-validations'
require 'dm-types'
require 'dm-migrations'
require 'dm-postgres-adapter'
require 'rdiscount'
require 'rack-ssl-enforcer'

DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/database.db")

class Page 
  include DataMapper::Resource
  property :id,           Serial
  property :slug,         String
  property :title,        String
  property :content,      Text
  property :last_updated, DateTime  
  property :sidebar,      Enum[ :yes, :no ], :default => :no
end

DataMapper.finalize

# Global variables
NAV_TITLE = 'Main'
FOOTER = '<em>"Not everything that is more difficult is more meritorious."</em> - <strong><NAME></strong>'

# Authentication
use Rack::Auth::Basic, "Restricted Area" do |username, password|
  [username, password] == [ENV['ADMIN_USER'], ENV['ADMIN_PASS']]
end

# Force all connections to use SSL
use Rack::SslEnforcer

# Converts page name into post slug
def slugify(content)
  content.downcase.gsub(/ /, '-').gsub(/[^a-z0-9_-]/, '').squeeze('-')
{'fraction_non_alphanumeric': 0.14809384164222875, 'fraction_numerical': 0.02126099706744868, 'mean_word_length': 4.479919678714859, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 2, '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': '4389042', 'n_tokens_mistral': 987, 'n_tokens_neox': 947, 'n_words': 214}