forked from watsonbox/telescope-pinna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
themekit.rb
61 lines (46 loc) · 1.38 KB
/
themekit.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
require 'sinatra'
require 'liquid'
require 'active_support/core_ext/string'
require 'json'
require 'hashie'
require_relative 'lib/theme_kit'
before do
ThemeKit.load
end
get '/' do
ThemeKit.render 'index.html'
end
get '/news' do
ThemeKit.render 'news.html', news: ThemeKit.store.news
end
get '/news/posts/:item' do
ThemeKit.render 'news-item.html', item: ThemeKit.store.news.items.first
end
get '/store' do
ThemeKit.render 'category.html', category: { name: 'All', products: ThemeKit.store.products }
end
get '/products/:slug' do
ThemeKit.render 'product.html', product: ThemeKit.store.products.find { |p| p.url == request.path_info }
end
get '/artists' do
ThemeKit.render 'roster.html', roster: ThemeKit.store.roster
end
get '/artists/:artist' do
item = ThemeKit.store.roster.items.find { |i| i.url == request.path_info }
item.products = ThemeKit.store.products
ThemeKit.render 'roster-item.html', item: item
end
get '/contact' do
ThemeKit.render 'contact.html'
end
get '/stylesheets/:file' do
content_type :css
css = File.read(File.join(ThemeKit::PATHS[:stylesheets], params[:file]))
Liquid::Template.parse(css).render('config' => ThemeKit.config)
end
get '/stylesheets/fonts/:file' do
send_file File.join(ThemeKit::PATHS[:stylesheets], 'fonts', params[:file])
end
get '/javascripts/:file' do
send_file File.join(ThemeKit::PATHS[:javascripts], params[:file])
end