Website/Rakefile

139 lines
3.4 KiB
Ruby
Raw Normal View History

2016-05-24 14:05:21 -04:00
$:.push "lib"
require "gemsmith.rb"
2016-05-25 12:06:00 -04:00
require "jdb.rb"
require "lab_metadata.rb"
2016-05-25 20:57:21 -04:00
require "util.rb"
2016-06-14 19:56:33 -04:00
require "cv.rb"
require "nsfcp.rb"
2016-05-24 14:05:21 -04:00
2016-05-25 12:06:00 -04:00
include GemSmith
$db = JDB.new("db")
2016-05-24 14:05:21 -04:00
2016-05-25 12:06:00 -04:00
LabMetadata::build_people_metadata()
site :odin_lab, out: "build" do
2016-05-24 14:05:21 -04:00
2016-05-25 16:58:50 -04:00
## Splice off header information
2016-05-25 12:06:00 -04:00
for_files(/((\.erb)|(\.md)|(\.html))$/) do
2016-05-25 23:08:33 -04:00
exclude_files(/^\/?(slides|software)\//) do
2016-07-31 13:26:09 -04:00
extract_headers
2016-05-25 23:08:33 -04:00
end
2016-05-25 12:06:00 -04:00
end
2016-05-25 16:58:50 -04:00
## Render specialized formats
2016-05-25 12:06:00 -04:00
for_files(/\.md$/) do
2016-07-31 13:26:09 -04:00
render_markdown
2016-05-25 12:06:00 -04:00
end
for_files(/\.erb$/) do
2016-07-31 13:26:09 -04:00
render_erb
2016-05-25 12:06:00 -04:00
end
2016-05-25 16:58:50 -04:00
## Generate pages for each lab member
LabMetadata::create_people_pages
for_files(/people\/.*\.html$/) do
exclude_files(/index\.html/) do
2016-07-31 13:26:09 -04:00
apply_template("templates/person.erb")
2016-05-25 16:58:50 -04:00
end
end
2016-07-31 13:26:09 -04:00
## 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 }
2016-05-25 23:08:33 -04:00
end
2016-05-25 12:06:00 -04:00
end
2016-05-25 16:58:50 -04:00
2016-05-25 23:08:33 -04:00
## Specialized Formatting
2016-07-31 13:26:09 -04:00
for_files(/seminar\/.*\.html$/) do
apply {|f| f[:extraCSS] = [{ "asset" => "seminar.css" }] }
apply_template("templates/seminar.erb")
end
2016-05-25 23:08:33 -04:00
2016-07-31 13:26:09 -04:00
## Apply templating
for_files(/\.html$/) do
exclude_files(/^\/?(slides|software)\//) do
apply_template("templates/lab.erb")
end
end
2016-05-25 23:08:33 -04:00
2016-05-25 16:58:50 -04:00
## Specify specialized dependencies (e.g., on the database)
2016-05-25 12:06:00 -04:00
for_files(/people\/.*\.html$/) do
add_dependency "db/lab.json"
2016-08-10 11:28:08 -04:00
add_dependency "db/publications.json"
2016-05-25 12:06:00 -04:00
end
for_files(/grants\/index\.html/) do
add_dependency "db/cv/okennedy/grants.json"
end
2016-06-03 12:13:12 -04:00
for_files(/papers\/index.html/) do
add_dependency "db/publications.json"
end
2016-07-09 11:31:41 -04:00
for_files(/research\/.*\/index.html/) do
add_dependency "db/lab.json"
end
2016-05-25 12:06:00 -04:00
2016-05-25 16:58:50 -04:00
## Static assets
2016-05-25 12:06:00 -04:00
add_assets([
2016-05-25 23:08:33 -04:00
"bootstrap", "jquery.js", "mathjax",
2016-05-25 20:57:21 -04:00
"odin.css", "seminar.css",
"logos", "favicon", "people"
2016-05-25 12:06:00 -04:00
])
2016-06-14 19:56:33 -04:00
add_static("slides", "slides")
add_static("software", "software")
2016-05-25 23:08:33 -04:00
2016-05-25 12:06:00 -04:00
end
2016-05-25 23:08:33 -04:00
task :default => [ :odin_lab ]
2016-05-25 12:06:00 -04:00
task :open => :default do
system("open build/index.html")
end
task :clean do
system("rm -r build")
end
2016-06-14 19:56:33 -04:00
directory "artifacts"
2016-06-14 19:56:33 -04:00
["okennedy"].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|
2016-06-14 19:56:33 -04:00
CV.make(who, fh)
end
end
file "artifacts/#{who}.pdf" => "artifacts/#{who}.tex" do
system("cd artifacts; pdflatex #{who}.tex")
2016-06-14 19:56:33 -04:00
end
task :cv => "artifacts/#{who}.pdf"
2016-06-14 19:56:33 -04:00
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"
2016-07-26 00:57:23 -04:00
file "artifacts/db.json" => "artifacts" do
2016-07-26 00:57:23 -04:00
File.open("db.json", "w+") do |f|
f.puts JSON.generate($db.data)
end
end
task :documents => ["artifacts/db.json", :cv, :cnp]