forked from blackfalcon/sinatra_bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
73 lines (57 loc) · 1.97 KB
/
app.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
67
68
69
70
71
72
73
require 'rubygems'
require 'sass'
require 'compass'
require 'stipe'
# require 'thin' # Uncomment here and in Gemfile for better performance in production, especially on Heroku
# If you're using bundler, you will need to add this
require 'bundler/setup'
require 'sinatra'
require 'sinatra/partial'
set :partial_template_engine, :erb
helpers do
include ERB::Util
alias_method :code, :html_escape
# write better links
def link_to_unless_current(location, text )
if request.path_info == location
text
else
link_to location, text
end
end
def link_to(url,text=url,opts={})
attributes = ""
opts.each { |key,value| attributes << key.to_s << "=\"" << value << "\" "}
"<a href=\"#{url}\" #{attributes}>#{text}</a>"
end
end
# Wanna use Compass? Rock it!
# ------------------------------------------
configure do
Compass.add_project_configuration(File.join(Sinatra::Application.root, 'config.rb'))
end
# at a minimum, the main sass file must reside within the ./views directory. here, we create a ./views/stylesheets directory where all of the sass files can safely reside.
# ------------------------------------------
# I don't recommend running this route in production; precompile your Sass and
# WARNING: remove this route. As long as your compiled CSS files are in a directory below
# /public, Sinatra will automatically find and serve them.
# ------------------------------------------
get '/stylesheets/:name.css' do
content_type 'text/css', :charset => 'utf-8'
scss(:"../sass/#{params[:name]}", Compass.sass_engine_options )
end
get '/' do
erb :index
end
get '/toadstool' do
erb :"toadstool/typography", :layout => :"toadstool/layout"
end
get '/toadstool/grid' do
erb :"toadstool/grid", :layout => :"toadstool/layout"
end
get '/toadstool/color_palettes' do
erb :"toadstool/color_palettes", :layout => :"toadstool/layout"
end
get '/toadstool/forms' do
erb :"toadstool/forms", :layout => :"toadstool/layout"
end