2015-12-04 12:10:33 -05:00
|
|
|
module.exports = plugin;
|
|
|
|
|
2015-12-05 18:44:51 -05:00
|
|
|
var formatAuthor = require("../lib/format-name.js");
|
|
|
|
var push = function(arr, key, elem)
|
|
|
|
{
|
|
|
|
if(typeof arr[key] == 'undefined') { arr[key] = [] }
|
|
|
|
arr[key].push(elem)
|
|
|
|
}
|
2015-12-04 22:42:41 -05:00
|
|
|
|
2015-12-04 12:10:33 -05:00
|
|
|
function plugin() {
|
|
|
|
return function (files, smith, done){
|
2015-12-05 18:44:51 -05:00
|
|
|
var lab = smith.metadata().labMembers;
|
2015-12-04 12:10:33 -05:00
|
|
|
var pubs = smith.metadata().okennedy.data.publications.concat(
|
|
|
|
smith.metadata().altPubs);
|
|
|
|
var venues = smith.metadata().okennedy.venues;
|
|
|
|
var pubsByYear = {}
|
2015-12-05 18:44:51 -05:00
|
|
|
var pubsByProject = {}
|
2015-12-04 12:10:33 -05:00
|
|
|
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; }
|
|
|
|
}
|
2015-12-05 18:44:51 -05:00
|
|
|
|
2015-12-04 12:10:33 -05:00
|
|
|
var authorFormat =
|
|
|
|
pub.authors
|
2015-12-04 22:42:41 -05:00
|
|
|
.map(formatAuthor(lab))
|
2015-12-04 12:10:33 -05:00
|
|
|
.join(", ")
|
|
|
|
if(typeof pub.year == 'undefined'){
|
|
|
|
console.log(pub);
|
|
|
|
throw "Unknown year for "+pub
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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(" | ")+" )";
|
|
|
|
}
|
2015-12-05 18:44:51 -05:00
|
|
|
var venue = pub.venue;
|
|
|
|
// console.log(pub);
|
|
|
|
if(typeof pub.track != 'undefined'){
|
|
|
|
venue = venue+"-"+pub.track.toUpperCase();
|
|
|
|
}
|
|
|
|
venue = venue+" "+pub.year
|
2015-12-04 12:10:33 -05:00
|
|
|
|
2015-12-05 18:44:51 -05:00
|
|
|
var pubMeta =
|
2015-12-04 12:10:33 -05:00
|
|
|
{
|
|
|
|
title: pub.title,
|
2015-12-05 18:44:51 -05:00
|
|
|
visible: !(pub.hidden || false),
|
2015-12-04 12:10:33 -05:00
|
|
|
authorFormat: authorFormat,
|
|
|
|
authors: pub.authors,
|
2015-12-05 18:44:51 -05:00
|
|
|
venue: venue,
|
|
|
|
resourcesFormat: resourcesFormat,
|
|
|
|
projects: pub.projects
|
2015-12-04 12:10:33 -05:00
|
|
|
}
|
2015-12-05 18:44:51 -05:00
|
|
|
// console.log(pubMeta)
|
|
|
|
|
|
|
|
// Associate the publication with its year, but only if not hidden
|
|
|
|
push(pubsByYear, pub.year, pubMeta)
|
|
|
|
|
|
|
|
// Associate the publication with each of its authors if they're lab
|
|
|
|
// members
|
|
|
|
for(i in pub.authors){
|
|
|
|
var author = pub.authors[i]
|
|
|
|
// console.log("affiliating " +pub.title+" with "+author)
|
|
|
|
// console.log(smith.metadata().odinLab.members[author])
|
|
|
|
if(typeof smith.metadata().odinLab.members[author] != 'undefined'){
|
|
|
|
if(typeof smith.metadata().odinLab.members[author].pubs == 'undefined'){
|
|
|
|
smith.metadata().odinLab.members[author].pubs = [pubMeta]
|
|
|
|
} else {
|
|
|
|
smith.metadata().odinLab.members[author].pubs.push(pubMeta)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Associate the publication with each of its projects
|
|
|
|
for(p in pub.projects){
|
2015-12-08 17:37:25 -05:00
|
|
|
// console.log("Associating "+pubMeta.title+" with "+pub.projects[p])
|
|
|
|
push(pubsByProject, pub.projects[p], pubMeta)
|
2015-12-05 18:44:51 -05:00
|
|
|
}
|
2015-12-04 12:10:33 -05:00
|
|
|
}
|
|
|
|
var out = []
|
|
|
|
for(i in pubsByYear) {
|
|
|
|
out.push({year: i, pubs: pubsByYear[i]})
|
|
|
|
}
|
|
|
|
// console.log(out)
|
|
|
|
smith.metadata()["allpubs"] = out.reverse()
|
2015-12-08 17:37:25 -05:00
|
|
|
// console.log(pubsByProject)
|
2015-12-05 18:44:51 -05:00
|
|
|
smith.metadata()["projectPubs"] = pubsByProject
|
2015-12-04 12:10:33 -05:00
|
|
|
done()
|
|
|
|
}
|
|
|
|
}
|