-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.rb
66 lines (54 loc) · 1.43 KB
/
web.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require 'bundler'
ENV["RACK_ENV"] ||= "development"
Bundler.setup(:default, ENV["RACK_ENV"])
require 'sinatra'
require 'compass'
require 'redcarpet'
require 'haml'
require 'coderay'
class HTMLwithCodeRay < Redcarpet::Render::HTML
INNER_RENDERER = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new)
def block_code(code, language)
if language
CodeRay.scan(code, language).div(:css => :class)
else
INNER_RENDERER.render(code)
end
end
end
configure do
Compass.configuration do |config|
config.project_path = File.dirname(__FILE__)
config.sass_dir = 'views/stylesheets'
config.cache_dir = 'tmp/sass-cache'
config.images_path = 'public/images'
end
set :scss, Compass.sass_engine_options
set :markdown,
:layout_engine => :erb,
:no_intra_emphasis => true,
:fenced_code_blocks => true,
:renderer => HTMLwithCodeRay.new
end
get '/' do
erb :index
end
get '/screen.css' do
content_type 'text/css', :charset => 'utf-8'
scss :"stylesheets/screen"
end
get '/coderay_github' do
content_type 'text/css', :charset => 'utf-8'
scss :"stylesheets/_coderay_github"
end
# This handles default routes for the markdown files in `views/`
# Mostly added so that people who don't want to fuss with a Sinatra app can
# get right in and start making markdown files.
get '/*' do
page = File.join params[:splat]
if File.exist? "views/#{page}.markdown"
markdown page.intern
else
pass
end
end