forked from icco/resume
-
Notifications
You must be signed in to change notification settings - Fork 23
/
resume.rb
executable file
·53 lines (44 loc) · 1.32 KB
/
resume.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
#!/usr/bin/ruby1.8
# A Sinatra app for displaying one's resume in multiple formats
require 'rubygems'
require 'sinatra'
require 'less'
require 'rdiscount'
require 'maruku'
set :public_folder, File.dirname(__FILE__) + '/public'
get '/' do
title = resume_data.split("\n").first
#oops 1.8.7 only?
#resume_data.lines.first.strip
resume = RDiscount.new(resume_data, :smart).to_html
erubis :index, :locals => { :title => title, :resume => resume, :formats => true }
end
get '/style.css' do
content_type 'text/css', :charset => 'utf-8'
less :style
end
get '/latex' do
content_type 'application/x-latex'
doc = Maruku.new(resume_data)
doc.to_latex_document
end
get '/markdown' do
content_type 'application/markdown'
resume_data
end
# note this only works if pdflatex is installed which is part of most LaTeX packages, but doesn't work on Heroku
# TODO if this ever works on heroku clean it up and add caching
get '/pdf' do
content_type 'application/x-latex'
pdf_file = 'tmp/resume.pdf'
latex_file = 'tmp/resume.tex'
return File.read(pdf_file) if File.exists?(pdf_file)
doc = Maruku.new(resume_data)
tex = doc.to_latex_document
File.open(latex_file, 'w') {|f| f.write(tex) }
`cd tmp && pdflatex resume.tex -interaction=nonstopmode`
File.read(pdf_file)
end
def resume_data
File.read("data/resume.md")
end