forked from sinatra/sinatra-book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
35 lines (30 loc) · 1.04 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
require File.join(File.dirname(__FILE__), "book.rb")
require 'erb'
require 'sinatra'
include Book
get('/'){ erb build }
get('/download'){ build(true); send_file "#{OUTPUT_DIR}/sinatra-book.pdf", :type => 'application/pdf'; }
get('/book.css') { send_file "#{ASSETS_DIR}/book.css", :type => 'text/css' }
get('/print.css') { send_file "#{ASSETS_DIR}/print.css", :type => 'text/css' }
get('/download.png') { send_file "#{ASSETS_DIR}/images/download.png", :type => :png }
__END__
@@layout
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Sinatra Book</title>
<link rel="stylesheet" type="text/css" href="/book.css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="/print.css" media="print" />
<link rel="shortcut icon" href="/images/favicon.ico">
</head>
<body>
<div id="download">
<a href="/download">
<img src="/images/download.png" alt="Download the Sinatra Book" />
</a>
</div>
<%= yield %>
</body>
</html>