Website/Rakefile

223 lines
6.1 KiB
Ruby
Raw Normal View History

require "rubygems"
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"
require "nsfconflicts.rb"
2016-08-24 14:20:50 -04:00
require "bootstrap_markdown.rb"
2016-05-24 14:05:21 -04:00
2016-05-25 12:06:00 -04:00
include GemSmith
$db = JDB.new("db")
2016-08-11 10:30:00 -04:00
$cv_users = ["okennedy"]
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
exclude_files(/^\/?(slides)\//) 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-08-24 14:20:50 -04:00
render_markdown(BootstrapMarkdown.new,
tables: true,
disable_indented_code_blocks: true,
fenced_code_blocks: true,
autolink: true,
no_intra_emphasis: true
)
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
2017-01-09 12:17:45 -05:00
for_files(/seminar\/[0-9]{4}(sp|fa)\.html$/) do
2016-07-31 13:26:09 -04:00
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)\//) do
2017-01-31 18:04:30 -05:00
exclude_files(/^\/?teaching\/.*\/?(slides)\/.*\.html/) do
apply_template("templates/lab.erb")
end
2016-07-31 13:26:09 -04:00
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"
2017-02-02 22:08:39 -05:00
add_dependency "db/lab.json"
end
2016-06-03 12:13:12 -04:00
for_files(/papers\/index.html/) do
add_dependency "db/publications.json"
2017-02-02 22:08:39 -05:00
add_dependency "db/lab.json"
add_dependency "lib/publication.erb"
2016-06-03 12:13:12 -04:00
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",
2016-11-08 10:02:12 -05:00
"logos", "favicon", "people", "photos"
2016-05-25 12:06:00 -04:00
])
2016-06-14 19:56:33 -04:00
add_static("slides", "slides")
## Sub-sites
add_static("subsites/nmeneghetti", "people/niccolo_meneghetti")
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
2016-08-11 10:30:00 -04:00
$cv_users.each do |who|
2017-03-05 17:41:34 -05:00
file "artifacts/#{who}.tex" => (["artifacts", "db/cv/#{who}.json", "lib/cv.rb", "Rakefile"]+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-08-11 10:30:00 -04:00
File.open("artifacts/db.json", "w+") do |f|
2016-07-26 00:57:23 -04:00
f.puts JSON.generate($db.data)
end
end
2016-08-11 10:35:07 -04:00
task :documents => ["artifacts/db.json", :cv, :cnp]
2016-08-11 10:30:00 -04:00
directory "build/artifacts"
2016-08-11 10:35:07 -04:00
task :deploy => [:documents,:odin_lab,"build/artifacts"] do
2016-08-11 10:30:00 -04:00
system("cp -r artifacts/*.{pdf,json} build/artifacts/")
2016-09-18 18:45:09 -04:00
end
###################### Specialized Stuff for Individual Use ######################
file "okennedy_short.tex" => (["db/cv/okennedy.json", "lib/cv.rb", "Rakefile"]+Dir["db/cv/okennedy/**"]) do
File.open("okennedy_short.tex", "w+") do |fh|
CV.make("okennedy", fh,
title: "Recent Activities",
since: {
education: 2008,
reviewer: 2015,
general_service: 2015,
volunteering: 2015,
talks: 2015,
courses: 2015,
2016-09-18 19:14:05 -04:00
publications: 2014
2016-09-18 18:45:09 -04:00
},
skip: [
:employment,
:memberships,
:dept_service,
:tech_reports
]
)
end
end
file "okennedy_short.pdf" => "okennedy_short.tex" do
system("pdflatex okennedy_short.tex")
end
2017-02-16 02:02:48 -05:00
file "artifacts/okennedy_collaborators.tsv" => $db.files do
NSFConflicts.new("Oliver Kennedy", $db).
2017-02-16 02:02:48 -05:00
render("artifacts/okennedy_collaborators.tsv")
end
2017-02-16 02:02:48 -05:00
task :collab => "artifacts/okennedy_collaborators.tsv"
2016-09-18 18:45:09 -04:00
2017-05-11 03:45:25 -04:00
file "artifacts/oracle_papers.txt" => [ $db.files, "artifacts", "Rakefile" ].flatten do
File.open("artifacts/oracle_papers.txt", "w+") do |fh|
fh.puts $db["publications"].
where { |pub| pub.fetch("projects", []).include? "mimir" }.
map { |pub|
pub = LabMetadata::complete_venue(pub)
case pub["type"]
when "conference", "journal", "workshop", "abstract" then
[ pub["title"],
pub["authors"].join(", "),
"#{LabMetadata::venue_name(pub, size: :full_parens)} #{pub["year"]}",
pub["urls"].map { |k,v| "#{k.capitalize}: #{v}" },
LabMetadata.bibtex_for(pub).split("\n")
].flatten
when "thesis" then
[ pub["title"],
pub["authors"].join(", "),
"Thesis #{pub["degree"]} #{pub["year"]}",
pub["urls"].map { |k,v| "#{k.capitalize}: #{v}" },
LabMetadata.bibtex_for(pub).split("\n")
].flatten
else nil
end
}.
compact.
map { |record| "> #{record.join("\n ")}" }.
join("\n\n")
end
end