-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.rb
executable file
·87 lines (67 loc) · 1.42 KB
/
routes.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
### FILTERS
# CATCH ALL
before do
@Assets = Assets.new
@Page = Page.new
@Params = params
@Request = request
@Page.params = @Params
@Page.request = @Request
@Page.title = @Page.pagetitle
@View = @Page.view
@Publicview = is_view_public(@View)
@Ajaxview = is_view_ajax(@View)
# if request.xhr?
@Ajax = Ajax.new
@Ajax.params = @Params
# end
end
before "/github_users" do
@Data = @Ajax.get_data
end
before "/github_limits" do
@Data = @Ajax.get_seconds_to_wait
end
### ROUTES
# STARTPAGE
get "/" do
erb @View.to_sym, :layout => :app
end
# SASS
get "/stylesheets/:name.css" do
content_type "text/css", :charset => "utf-8"
if !settings.show_debuginfo
response["Expires"] = (Time.now + 60*60*24*356*3).httpdate
end
scss(:"stylesheets/#{params[:name]}", Compass.sass_engine_options)
end
# CATCH ALL
get "/:page/?*" do
if params[:format] == "json"
response.headers['Content-Type'] = "application/json"
end
# if request.xhr?
if @Ajaxview
layout = "ajax"
else
layout = "app"
end
# View found
if @View != "notfound"
# All is fine - render view
erb @View.to_sym, :layout => layout.to_sym
else
# View isn't there - render 404
raise error(404)
end
else
# View isn't set - render 404
raise error(404)
end
end
# NOT FOUND (404)
not_found do
@Page.title = "Not found"
erb :"common/notfound", :layout => :app
end