Website/Rakefile

151 lines
3.8 KiB
Ruby

$:.push "lib"
require "gemsmith.rb"
require "jdb.rb"
require "lab_metadata.rb"
require "util.rb"
require "cv.rb"
require "nsfcp.rb"
require "bootstrap_markdown.rb"
include GemSmith
$db = JDB.new("db")
$cv_users = ["okennedy"]
LabMetadata::build_people_metadata()
site :odin_lab, out: "build" do
## Splice off header information
for_files(/((\.erb)|(\.md)|(\.html))$/) do
exclude_files(/^\/?(slides|software)\//) do
extract_headers
end
end
## Render specialized formats
for_files(/\.md$/) do
render_markdown(BootstrapMarkdown.new,
tables: true,
disable_indented_code_blocks: true,
fenced_code_blocks: true,
autolink: true,
no_intra_emphasis: true
)
end
for_files(/\.erb$/) do
render_erb
end
## Generate pages for each lab member
LabMetadata::create_people_pages
for_files(/people\/.*\.html$/) do
exclude_files(/index\.html/) do
apply_template("templates/person.erb")
end
end
## Render 'news' pages
for_files(/rants\/.*\.html$/) do
exclude_files(/index\.html$/) do
extract_date_from_filename
create_collection("rants")
apply { |f| f[:news_prev] = f[:rants_prev]; f[:news_next] = f[:rants_next] }
apply_template("templates/news.erb")
end
for_files(/index\.html$/) do
get_collection("rants").map { |f| f[:in_path] }.each { |dep| add_dependency dep }
end
end
for_files(/news\/.*\.html$/) do
exclude_files(/index\.html$/) do
extract_date_from_filename
create_collection("news")
apply_template("templates/news.erb")
end
for_files(/index\.html$/) do
get_collection("news").map { |f| f[:in_path] }.each { |dep| add_dependency dep }
end
end
## Specialized Formatting
for_files(/seminar\/.*\.html$/) do
apply {|f| f[:extraCSS] = [{ "asset" => "seminar.css" }] }
apply_template("templates/seminar.erb")
end
## Apply templating
for_files(/\.html$/) do
exclude_files(/^\/?(slides|software)\//) do
apply_template("templates/lab.erb")
end
end
## Specify specialized dependencies (e.g., on the database)
for_files(/people\/.*\.html$/) do
add_dependency "db/lab.json"
add_dependency "db/publications.json"
end
for_files(/grants\/index\.html/) do
add_dependency "db/cv/okennedy/grants.json"
end
for_files(/papers\/index.html/) do
add_dependency "db/publications.json"
end
for_files(/research\/.*\/index.html/) do
add_dependency "db/lab.json"
end
## Static assets
add_assets([
"bootstrap", "jquery.js", "mathjax",
"odin.css", "seminar.css",
"logos", "favicon", "people"
])
add_static("slides", "slides")
add_static("software", "software")
end
task :default => [ :odin_lab ]
task :open => :default do
system("open build/index.html")
end
task :clean do
system("rm -r build")
end
directory "artifacts"
$cv_users.each do |who|
file "artifacts/#{who}.tex" => (["artifacts", "db/cv/#{who}.json"]+Dir["db/cv/#{who}/**"]) do
File.open("artifacts/#{who}.tex", "w+") do |fh|
CV.make(who, fh)
end
end
file "artifacts/#{who}.pdf" => "artifacts/#{who}.tex" do
system("cd artifacts; pdflatex #{who}.tex")
end
task :cv => "artifacts/#{who}.pdf"
end
file "artifacts/okennedy_current_and_pending.pdf" do
NSFCnP.new("Oliver Kennedy",
$db["cv/okennedy/grants"].select { |r| r["status"] == "accepted" or r["status"] == "submitted" or r["status"] == "planned"}
).render("artifacts/okennedy_current_pending.pdf")
end
task :cnp => "artifacts/okennedy_current_and_pending.pdf"
file "artifacts/db.json" => "artifacts" do
File.open("artifacts/db.json", "w+") do |f|
f.puts JSON.generate($db.data)
end
end
task :documents => ["artifacts/db.json", :cv, :cnp]
directory "build/artifacts"
task :deploy => [:documents,:odin_lab,"build/artifacts"] do
system("cp -r artifacts/*.{pdf,json} build/artifacts/")
end