61 lines
1.7 KiB
JavaScript
61 lines
1.7 KiB
JavaScript
module.exports = plugin;
|
|
|
|
var formatAuthor = require("../lib/format-author.js");
|
|
|
|
function plugin() {
|
|
return function (files, smith, done){
|
|
var lab = smith.metadata().odinLab.members.concat(
|
|
smith.metadata().odinLab.alumni);
|
|
var pubs = smith.metadata().okennedy.data.publications.concat(
|
|
smith.metadata().altPubs);
|
|
var venues = smith.metadata().okennedy.venues;
|
|
var pubsByYear = {}
|
|
for(i in pubs){
|
|
var pub = pubs[i]
|
|
var venue = venues[pub.venue] || {}
|
|
if(pub.type == "patent"){ continue; }
|
|
|
|
if(venue.type == "techreport") {
|
|
if(pub.venue != "ArXiv"){ continue; }
|
|
}
|
|
var authorFormat =
|
|
pub.authors
|
|
.map(formatAuthor(lab))
|
|
.join(", ")
|
|
if(typeof pub.year == 'undefined'){
|
|
console.log(pub);
|
|
throw "Unknown year for "+pub
|
|
}
|
|
|
|
if(typeof pubsByYear[pub.year] == 'undefined') {
|
|
pubsByYear[pub.year] = []
|
|
}
|
|
|
|
var resourcesFormat = ""
|
|
if(typeof pub.urls == 'object') {
|
|
var resources = []
|
|
for(cat in pub.urls){
|
|
resources.push("<a href="+pub.urls[cat]+">"+cat+"</a>")
|
|
}
|
|
resourcesFormat = "( "+resources.join(" | ")+" )";
|
|
}
|
|
|
|
pubsByYear[pub.year].push(
|
|
{
|
|
title: pub.title,
|
|
authorFormat: authorFormat,
|
|
authors: pub.authors,
|
|
venue: pub.venue+" "+pub.year,
|
|
resourcesFormat: resourcesFormat
|
|
}
|
|
)
|
|
}
|
|
var out = []
|
|
for(i in pubsByYear) {
|
|
out.push({year: i, pubs: pubsByYear[i]})
|
|
}
|
|
// console.log(out)
|
|
smith.metadata()["allpubs"] = out.reverse()
|
|
done()
|
|
}
|
|
} |