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
|
# File 'app/blogical/blog.rb', line 3
def self.included(app)
app.get %r{^/blog/?(\?.*)?$} do
@posts = options.repository.paginated(Integer(params['page']))
@pages = options.repository.total_pages
erb :blog
end
app.get '/blog/:year/:month/:day/:title' do |year, month, day, title|
@post = options.repository.find_by_permalink(title)
raise Sinatra::NotFound, 'No such post' unless @post
@title = @post.title
erb :article
end
app.get '/assets/:year/:month/:day/:attachment' do |year, month, day, attachment|
@attachment = options.repository.find_by_attachment(attachment)
raise Sinatra::NotFound, 'No such attachment' unless @attachment
send_file @attachment.content, :disposition => 'attachment'
end
end
|