bibtex-search
Advanced tools
Comparing version 0.1.1 to 0.1.2
34
index.js
@@ -12,6 +12,8 @@ #!/usr/bin/env node | ||
const chalk = require('chalk'); | ||
const hyperlinker = require('hyperlinker'); | ||
const MAX_ARTICLES = 10; | ||
const ACM_SEARCH_URL = 'https://dl.acm.org/results.cfm'; | ||
const ACM_REFERENCE_URL = 'https://dl.acm.org/exportformats.cfm'; | ||
const ACM_BASE = 'https://dl.acm.org'; | ||
const ACM_SEARCH_URL = `${ACM_BASE}/results.cfm`; | ||
const ACM_REFERENCE_URL = `${ACM_BASE}/exportformats.cfm`; | ||
@@ -35,10 +37,10 @@ /** | ||
const { id } = querystring.parse( | ||
link | ||
.attr('href') | ||
.split('?') | ||
.pop() | ||
); | ||
return { id, title, authors }; | ||
const url = link.attr('href'); | ||
const { id } = querystring.parse(url.split('?').pop()); | ||
return { | ||
id, | ||
title, | ||
authors, | ||
href: `${ACM_BASE}/${url}` | ||
}; | ||
}); | ||
@@ -69,6 +71,10 @@ } | ||
function buildQuestions(articles) { | ||
const choices = articles.map(({ id, title, authors }, i) => ({ | ||
value: id, | ||
name: `${title} ${chalk.dim(`(${authors})`)}` | ||
})); | ||
const choices = articles.map(({ id, href, title, authors }, i) => { | ||
const prefix = hyperlinker(title, href); | ||
const suffix = chalk.dim(`(${authors})`); | ||
return { | ||
value: id, | ||
name: `${prefix} ${suffix}` | ||
}; | ||
}); | ||
@@ -75,0 +81,0 @@ return [ |
{ | ||
"name": "bibtex-search", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Search for BibTeX references", | ||
@@ -34,2 +34,3 @@ "main": "index.js", | ||
"got": "^8.0.0", | ||
"hyperlinker": "^1.0.0", | ||
"inquirer": "^4.0.0", | ||
@@ -36,0 +37,0 @@ "meow": "^4.0.0", |
@@ -5,3 +5,3 @@ # bibtex-search [](https://travis-ci.org/ekmartin/bibtex-search) | ||
 | ||
 | ||
@@ -13,2 +13,4 @@ Currently uses [ACM's Digital Library](https://dl.acm.org/) to find papers, but | ||
bibtex-search needs at least version 7.6 of Node.js installed. | ||
```bash | ||
@@ -15,0 +17,0 @@ $ npm install --global bibtex-search |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
55020
110
18
8
+ Addedhyperlinker@^1.0.0
+ Addedhyperlinker@1.0.0(transitive)