-
Notifications
You must be signed in to change notification settings - Fork 26
/
index.js
63 lines (58 loc) · 2.45 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const captain = require('captain-log')
const parse = require('bibtex-parse-js').toJSON
const fs = require('fs')
const path = require('path')
function formatAuthors (authorsString) {
var authors = authorsString.split('and')
if (authors.length > 3) {
return (authors[0] + ' et al.').replace(/(\n|\t|\r)/, '').replace(/ +/, ' ')
} else {
return authorsString.replace(/(\n|\t|\r)/, '').replace(/ +/, ' ')
}
}
function formatTitle (titleString) {
return titleString.replace(/ +/, ' ').replace(/\{\}/, '*')
}
console.log("# 📖 [nicola](http://nicola.io)'s decentralized-research")
console.log('> This is the place where I list papers I am reading, take notes, write ideas and plan research and collaborate with others\n')
console.log('##### How to participate')
console.log('- [Suggest papers to read](https://github.com/nicola/reading-list/issues/new)')
console.log('- [Check on-going research/reading](https://github.com/nicola/reading-list/issues)')
console.log('- [Help me out figure out stuff](https://github.com/nicola/reading-list/issues)')
console.log('- [Read to my notes](https://github.com/nicola/reading-list/tree/master/notes)')
console.log('- [Ask any question](https://github.com/nicola/reading-list/issues/new)')
console.log('\n---\n')
console.log('# reading-list')
console.log('Papers I am reading\n')
console.log('Suggest me a paper by [opening an issue](https://github.com/nicola/reading-list/issues/new)')
const folders = fs.readdirSync('./bibs').filter(f => f !== '.DS_Store')
folders.reverse().forEach(folder => {
console.log('\n##', folder.replace(/^[0-9]+ /, ''), '\n')
const bibs = fs.readdirSync(path.join('./bibs/', folder)).filter(f => f !== '.DS_Store')
bibs
.sort((a, b) => {
let aRelevant = !!a.match(/relevant/)
let bRelevant = !!b.match(/relevant/)
if (aRelevant && !bRelevant) return -1
if (bRelevant && !aRelevant) return 1
return 0
})
.forEach(bib => {
let obj = parse(fs.readFileSync(path.join('./bibs/', folder, bib), 'utf8'))[0]
const relevant = !!bib.match(/relevant/)
let separator = '*'
if (relevant) {
separator = '**'
}
console.log('- ', `${separator}${formatTitle(obj.entryTags.title)}${separator}, ` + (relevant ? `${formatAuthors(obj.entryTags.author)}, ` : '') + `${obj.entryTags.year}`)
})
})
/*
captain([{
title: 'Learning material',
repo: 'nicola/decentralized-research',
labels: ['learn'],
prefix: '🗒 ',
issueLink: true
}])
*/