adding works list and plumbing

This commit is contained in:
mwinter 2022-01-27 11:32:34 -06:00
parent ff248d6a92
commit 9259436903
3 changed files with 253 additions and 226 deletions

View file

@ -855,23 +855,32 @@ function populatePublications() {
function populateAbout() { function populateAbout() {
var head = $('<h4>').append($('<div>').css('width', '50px').css('min-width', '50px').append('CV')); var cvHead = $('<h4>').append($('<div>').css('width', '50px').css('min-width', '50px').append('CV'));
//var documentButton = $("<button id=cv_button data-iframe='true' data-src='/cv'>").attr({title: "CV"}).addClass('score_icon'); //var documentButton = $("<button id=cv_button data-iframe='true' data-src='/cv'>").attr({title: "CV"}).addClass('score_icon');
var documentButton = $("<button id=cv_button>").attr({title: "CV"}).addClass('score_icon'); var cvButton = $("<button id=cv_button>").attr({title: "CV"}).addClass('score_icon');
documentButton.click(function() { var wlHead = $('<h4>').append($('<div>').css('width', '300px').css('min-width', '300px').append('Works List with Presentation History'));
var wlButton = $("<button id=cv_button>").attr({title: "Works List with Presentation History"}).addClass('score_icon');
cvButton.click(function() {
window.open('/cv'); window.open('/cv');
}); });
wlButton.click(function() {
window.open('/works_list');
});
/* /*
documentButton.lightGallery({ cvButton.lightGallery({
selector: 'this', selector: 'this',
width: '90%', width: '90%',
galleryId: 'cv' galleryId: 'cv'
}); });
*/ */
head.append(documentButton).insertBefore('#mc_embed_signup'); cvHead.append(cvButton).insertBefore('#mc_embed_signup');
wlHead.append(wlButton).insertBefore('#mc_embed_signup');
$('#my_image').html(""); $('#my_image').html("");
$('#my_image').append("<ul id='myimagegallerylist'>"); $('#my_image').append("<ul id='myimagegallerylist'>");

View file

@ -107,6 +107,14 @@ a {
margin-bottom: 5px; margin-bottom: 5px;
} }
.work-info {
margin-left: -30px;
}
.venue-info {
margin-left: 15px;
}
.education-gpa { .education-gpa {
padding-left: 2px; padding-left: 2px;
} }

View file

@ -26,253 +26,263 @@ router.get('/cv', function(req, res, next) {
var pubs = bibtexParse.toJSON(pubdata); var pubs = bibtexParse.toJSON(pubdata);
var dict = items[0] var dict = items[0]
dict.publications = pubs; dict.publications = pubs;
db.collection('talks').aggregate(
db.collection('works').find({}, function(err, works) { [
{'$sort' : {'date' : -1}},
function removeDuplicates(originalArray, objKey) { {'$group': {_id: { $substr: ['$date',0,4] }, talks: { $push: "$$ROOT" }}},
{'$sort' : {'_id' : -1}}]).toArray(function (err, talks) {
if (originalArray.length == 1) { dict.talks = talks;
return originalArray; res.render('cv.template', {resume: dict, css: css});
}
var trimmedArray = [];
var values = [];
var value;
for(var i = 0; i < originalArray.length; i++) {
value = originalArray[i][objKey];
if(values.map(Number).indexOf(+value) === -1) {
trimmedArray.push(originalArray[i]);
values.push(value);
}
}
trimmedArray.sort(function(a,b){
// Turn your strings into dates, and then subtract them
// to get a value that is either negative, positive, or zero.
return new Date(b.start_date) - new Date(a.start_date);
}); });
return trimmedArray });
} });
function processWork(err, work) { /* GET works_list. */
/* router.get('/works_list', function(req, res, next) {
if(work === null) {
db.collection('works').aggregate(
[
{'$sort' : {'date' : -1}},
{'$group': {_id: { $year: "$date" }, works: { $push: "$$ROOT" }}},
{'$sort' : {'_id' : -1}}]).toArray(function (err, worksCV) {
db.collection('talks').find().sort( { date: -1 } ).toArray(function (err, talks) {
dict.works = worksCV;
dict.talks = talks;
res.render('cv.template', {resume: dict, css: css});
db.collection('works').update({}, {$unset: {'events':1}}, {multi: true});
});
});
return; // All done!
}
*/
if(work === null) { var css = fs.readFileSync( path.join(__dirname, '../public/stylesheets/resume_style.css'), 'utf8');
db.collection('works').aggregate( var db = req.db;
[
{'$sort' : {'date' : -1}},
{'$group': {_id: { $year: "$date" }, works: { $push: "$$ROOT" }}},
{'$sort' : {'_id' : -1}}]).toArray(function (err, worksCV) {
db.collection('talks').aggregate(
[
{'$sort' : {'date' : -1}},
{'$group': {_id: { $substr: ['$date',0,4] }, talks: { $push: "$$ROOT" }}},
{'$sort' : {'_id' : -1}}]).toArray(function (err, talks) {
dict.works = worksCV;
dict.talks = talks;
console.log('talks: ' + talks);
console.log('works: ' + worksCV);
res.render('cv.template', {resume: dict, css: css});
db.collection('works').update({}, {$unset: {'events':1}}, {multi: true});
});
});
return; // All done!
}
var titleToSearch = work.title; db.collection('resume').find().toArray(function (err, items) {
//the abstract will need to be handled better eventually var dict = items[0];
//the rule: abstract = total intersection in performance; redux = the non-redux version includes the redux version but not vice-versa
if( titleToSearch === 'minor third' ){ db.collection('works').find({}, function(err, works) {
titleToSearch = '**********';
function removeDuplicates(originalArray, objKey) {
if (originalArray.length == 1) {
return originalArray;
} }
if( titleToSearch === 'seams' ){
titleToSearch = '**********'; var trimmedArray = [];
var values = [];
var value;
for(var i = 0; i < originalArray.length; i++) {
value = originalArray[i][objKey];
if(values.map(Number).indexOf(+value) === -1) {
trimmedArray.push(originalArray[i]);
values.push(value);
}
} }
if( titleToSearch === 'minor third abstract' ){
titleToSearch = 'minor third' trimmedArray.sort(function(a,b){
} // Turn your strings into dates, and then subtract them
if( titleToSearch === 'to walk and ponder (abstract)' ){ // to get a value that is either negative, positive, or zero.
titleToSearch = 'to walk and ponder' return new Date(b.start_date) - new Date(a.start_date);
}
if( titleToSearch === 'to converge (abstract)' ){
titleToSearch = 'to converge'
}
if( titleToSearch === 'pedal, triangle machine, and (perhaps) coda (abstract)' ){
titleToSearch = 'pedal, triangle machine, and (perhaps) coda'
}
/*
if( titleToSearch === 'Approximating Omega (redux)' ){
titleToSearch = 'Approximating Omega';
}
*/
if( titleToSearch == 'economy study (in one dimension)' ){
titleToSearch = 'economy study';
}
if( titleToSearch == '[___south america___] miscellany' ){
titleToSearch = 'miscellany';
}
if( (titleToSearch.indexOf('one') !== -1) && (titleToSearch.indexOf('two') !== -1)){
titleToSearch = 'two';
}
// bug: why is mercado san juan or first not updating?
db.collection('events').find( { $text: { $search: "\"" + titleToSearch + "\"" } } ).toArray(function (err, events1) {
db.collection('events').find( { 'program' : { "$elemMatch" : { 'work' : { $regex : titleToSearch.replace('(','\\(').replace(')','\\)'), $options : 'i' } } } } ).toArray(function (err, events2) {
if( titleToSearch !== '**********'){
db.collection('works').update({ 'title' : work.title }, { $set: { "events": removeDuplicates(events1.concat(events2), 'start_date') } });
}
works.next(processWork);
});
}); });
}; return trimmedArray
works.next(processWork); }
function processWork(err, work) {
/*
if(work === null) {
db.collection('works').aggregate(
[
{'$sort' : {'date' : -1}},
{'$group': {_id: { $year: "$date" }, works: { $push: "$$ROOT" }}},
{'$sort' : {'_id' : -1}}]).toArray(function (err, worksCV) {
db.collection('talks').find().sort( { date: -1 } ).toArray(function (err, talks) {
dict.works = worksCV;
dict.talks = talks;
res.render('cv.template', {resume: dict, css: css});
db.collection('works').update({}, {$unset: {'events':1}}, {multi: true});
});
}); });
}); return; // All done!
}); }
*/
//handle code releases if(work === null) {
router.get('/code_releases/*.zip', function(req, res) { db.collection('works').aggregate(
var db = req.db; [
var splitreq = req.url.split('/'); {'$sort' : {'date' : -1}},
var filename = splitreq.pop(); {'$group': {_id: { $year: "$date" }, works: { $push: "$$ROOT" }}},
var bucketName = splitreq.pop(); {'$sort' : {'_id' : -1}}]).toArray(function (err, worksCV) {
dict.works = worksCV;
res.render('workslist.template', {resume: dict, css: css});
db.collection('works').update({}, {$unset: {'events':1}}, {multi: true});
});
return; // All done!
}
db.collection(bucketName + ".files").findOne({ filename: filename }, function (err, file) { var titleToSearch = work.title;
//the abstract will need to be handled better eventually
if (err) return res.status(400).send(err); //the rule: abstract = total intersection in performance; redux = the non-redux version includes the redux version but not vice-versa
if (!file) return res.status(404).send(''); if( titleToSearch === 'minor third' ){
console.log(file.redirect); titleToSearch = '**********';
res.redirect(file.redirect); }
}); if( titleToSearch === 'seams' ){
}); titleToSearch = '**********';
}
/* redirect catch */ if( titleToSearch === 'minor third abstract' ){
router.get('/redirect=*', function(req, res, next) { titleToSearch = 'minor third'
var link = req.url.split('=').pop(); }
request(link).pipe(res); if( titleToSearch === 'to walk and ponder (abstract)' ){
}); titleToSearch = 'to walk and ponder'
}
if( titleToSearch === 'to converge (abstract)' ){
router.get('/*/*', function(req, res) { titleToSearch = 'to converge'
var db = req.db; }
var splitreq = req.url.split('/'); if( titleToSearch === 'pedal, triangle machine, and (perhaps) coda (abstract)' ){
var filename = splitreq.pop(); titleToSearch = 'pedal, triangle machine, and (perhaps) coda'
var bucketName = splitreq.pop(); }
/*
db.collection(bucketName + ".files").findOne({ filename: filename }, function (err, file) { if( titleToSearch === 'Approximating Omega (redux)' ){
if (err) return res.status(400).send(err); titleToSearch = 'Approximating Omega';
if (!file) return res.status(404).send(''); }
*/
var bucket = new mongo.GridFSBucket(db, { if( titleToSearch == 'economy study (in one dimension)' ){
chunkSizeBytes: 1024, titleToSearch = 'economy study';
bucketName: bucketName }
if( titleToSearch == '[___south america___] miscellany' ){
titleToSearch = 'miscellany';
}
if( (titleToSearch.indexOf('one') !== -1) && (titleToSearch.indexOf('two') !== -1)){
titleToSearch = 'two';
}
// bug: why is mercado san juan or first not updating?
db.collection('events').find( { $text: { $search: "\"" + titleToSearch + "\"" } } ).toArray(function (err, events1) {
db.collection('events').find( { 'program' : { "$elemMatch" : { 'work' : { $regex : titleToSearch.replace('(','\\(').replace(')','\\)'), $options : 'i' } } } } ).toArray(function (err, events2) {
if( titleToSearch !== '**********'){
db.collection('works').update({ 'title' : work.title }, { $set: { "events": removeDuplicates(events1.concat(events2), 'start_date') } });
}
works.next(processWork);
});
}); });
};
works.next(processWork);
});
});
});
bucket.openDownloadStreamByName(filename). //handle code releases
pipe(res). router.get('/code_releases/*.zip', function(req, res) {
on('error', function(error) { var db = req.db;
//assert.ifError(error); var splitreq = req.url.split('/');
res.end(); var filename = splitreq.pop();
}). var bucketName = splitreq.pop();
on('finish', function() {
console.log('done!'); db.collection(bucketName + ".files").findOne({ filename: filename }, function (err, file) {
});
}); if (err) return res.status(400).send(err);
if (!file) return res.status(404).send('');
console.log(file.redirect);
res.redirect(file.redirect);
});
});
/* redirect catch */
router.get('/redirect=*', function(req, res, next) {
var link = req.url.split('=').pop();
request(link).pipe(res);
});
router.get('/*/*', function(req, res) {
var db = req.db;
var splitreq = req.url.split('/');
var filename = splitreq.pop();
var bucketName = splitreq.pop();
db.collection(bucketName + ".files").findOne({ filename: filename }, function (err, file) {
if (err) return res.status(400).send(err);
if (!file) return res.status(404).send('');
var bucket = new mongo.GridFSBucket(db, {
chunkSizeBytes: 1024,
bucketName: bucketName
}); });
/* bucket.openDownloadStreamByName(filename).
router.get('/album_art/*', function(req, res) { pipe(res).
res.render('file'); on('error', function(error) {
//assert.ifError(error);
res.end();
}).
on('finish', function() {
console.log('done!');
}); });
});
});
router.get('/pubs/*', function(req, res) {
res.render('file');
});
*/
//legacy file handler
/* /*
router.get('/*.*', function(req, res) { router.get('/album_art/*', function(req, res) {
var file = req.url.split('/').pop() res.render('file');
request("http://legacy.unboundedpress.org/"+file).pipe(res); });
});
router.get('/pubs/*', function(req, res) {
res.render('file');
});
*/
//legacy file handler
/*
router.get('/*.*', function(req, res) {
var file = req.url.split('/').pop()
request("http://legacy.unboundedpress.org/"+file).pipe(res);
});
*/ */
/* catch all*/ /* catch all*/
router.get('/*', function(req, res, next) { router.get('/*', function(req, res, next) {
res.render('index', { title: 'Michael Winter' }); res.render('index', { title: 'Michael Winter' });
}); });
Handlebars.registerHelper("prettifyDayDate", function(resumeDate) { Handlebars.registerHelper("prettifyDayDate", function(resumeDate) {
if (!resumeDate) { if (!resumeDate) {
return 'present'; return 'present';
} }
var newDate = Moment(resumeDate).format('MM.DD.YYYY'); var newDate = Moment(resumeDate).format('MM.DD.YYYY');
//console.log('newDate: ' + newDate); //console.log('newDate: ' + newDate);
return newDate; return newDate;
}); });
Handlebars.registerHelper("prettifyMonthDate", function(resumeDate) { Handlebars.registerHelper("prettifyMonthDate", function(resumeDate) {
if (!resumeDate) { if (!resumeDate) {
return 'present'; return 'present';
} }
var newDate = Moment(resumeDate).format('MMM YYYY'); var newDate = Moment(resumeDate).format('MMM YYYY');
//console.log('newDate: ' + newDate); //console.log('newDate: ' + newDate);
return newDate; return newDate;
}); });
Handlebars.registerHelper("prettifyYearDate", function(resumeDate) { Handlebars.registerHelper("prettifyYearDate", function(resumeDate) {
if (!resumeDate) { if (!resumeDate) {
return 'present'; return 'present';
} }
var newDate = Moment(resumeDate).format('YYYY'); var newDate = Moment(resumeDate).format('YYYY');
//console.log('newDate: ' + newDate); //console.log('newDate: ' + newDate);
return newDate; return newDate;
}); });
Handlebars.registerHelper('toLowerCase', function(str) { Handlebars.registerHelper('toLowerCase', function(str) {
return str.toLowerCase(); return str.toLowerCase();
}); });
Handlebars.registerHelper('toArray', function(val) { Handlebars.registerHelper('toArray', function(val) {
if (typeof val === 'string') { if (typeof val === 'string') {
return [val] return [val]
} else { } else {
return val return val
} }
}); });
Handlebars.registerHelper('unless_blank', function(item, block) { Handlebars.registerHelper('unless_blank', function(item, block) {
return (item && item.replace(/\s/g,"").length) ? block.fn(this) : block.inverse(this); return (item && item.replace(/\s/g,"").length) ? block.fn(this) : block.inverse(this);
}); });
Handlebars.registerHelper('equal', function(lvalue, rvalue, options) { Handlebars.registerHelper('equal', function(lvalue, rvalue, options) {
if (arguments.length < 3) if (arguments.length < 3)
throw new Error("Handlebars Helper equal needs 2 parameters"); throw new Error("Handlebars Helper equal needs 2 parameters");
if( lvalue!=rvalue ) { if( lvalue!=rvalue ) {
return options.inverse(this); return options.inverse(this);
} else { } else {
return options.fn(this); return options.fn(this);
} }
}); });
module.exports = router; module.exports = router;