Skip to content

Commit

Permalink
Merge pull request #107 from vict0rsch/frontiers
Browse files Browse the repository at this point in the history
  • Loading branch information
vict0rsch authored Jun 16, 2022
2 parents 4457a8a + 632eca7 commit 45883f8
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 7 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Paper Memory",
"version": "0.5.6",
"version": "0.5.7",
"manifest_version": 2,
"description": "Automatically record papers and their codes from Arxiv, OpenReview & more! Organize your library with tags, links and quick notes.",
"homepage_url": "https://github.com/vict0rsch/PaperMemory",
Expand Down
1 change: 0 additions & 1 deletion src/content_scripts/content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,6 @@ const arxiv = async (checks) => {
const results = await Promise.all([paperPromise, domReadyPromise]);

paper = results[0];
console.log("paper: ", paper);
if (paper) {
// a paper was parsed

Expand Down
2 changes: 1 addition & 1 deletion src/popup/min/popup.min.html

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion src/popup/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,14 @@ <h3>Search</h3>
<h3 style="margin-bottom: 0px;">What's new</h3>
<ul>
<li><strong>Current: </strong><a
href="https://github.com/vict0rsch/PaperMemory/releases/tag/0.5.6">0.5.6</a>
href="https://github.com/vict0rsch/PaperMemory/releases/tag/0.5.7">0.5.7</a>
<em>(2022-06-13)</em>
<ul>
<li>[new source] Add FrontiersIn paper source</li>
<li>[dev] Improve preprint/publication matching</li>
</ul>
</li>
<li><a href="https://github.com/vict0rsch/PaperMemory/releases/tag/0.5.6">0.5.6</a>
<em>(2022-06-13)</em>
<ul>
<li>[feature] Add paper code to arxiv.org's rightmost column</li>
Expand Down
1 change: 1 addition & 0 deletions src/shared/js/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ global.knownPaperPages = {
arxiv: ["arxiv.org/abs/", "arxiv.org/pdf/", "scirate.com/arxiv/"],
biorxiv: ["biorxiv.org/content"],
cvf: ["openaccess.thecvf.com/content"],
frontiers: ["frontiersin.org/articles"],
ijcai: [(url) => /ijcai\.org\/proceedings\/\d{4}\/\d+/gi.test(url)],
ieee: [
"ieeexplore.ieee.org/document/",
Expand Down
1 change: 1 addition & 0 deletions src/shared/js/utils/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const isObject = (obj) =>
const isPdfUrl = (url) => {
return (
url.endsWith(".pdf") ||
url.endsWith("/pdf") ||
url.includes("openreview.net/pdf") ||
url.match(/\/e?pdf\//g) ||
url.includes("ieee.org/stamp/stamp.jsp?tp=&arnumber=")
Expand Down
10 changes: 10 additions & 0 deletions src/shared/js/utils/paper.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ const paperToAbs = (paper) => {
abs = `https://science.org/doi/full/${doi}`;
break;

case "frontiers":
abs = pdf.replace(/\/pdf$/, "/full");
break;

default:
abs = "https://xkcd.com/1969/";
break;
Expand Down Expand Up @@ -246,6 +250,9 @@ const paperToPDF = (paper) => {
case "science":
break;

case "frontiers":
break;

default:
pdf = "https://xkcd.com/1969/";
break;
Expand Down Expand Up @@ -760,6 +767,9 @@ const parseIdFromUrl = async (url) => {
doi = doi.split("/").slice(1).join("/");
}
idForUrl = findPaperId(papers, "science", miniHash(doi));
} else if (is.frontiers) {
doi = noParamUrl(url).split("/articles/")[1].split("/").slice(0, -1).join("/");
idForUrl = findPaperId(papers, "frontiers", miniHash(doi));
} else if (is.localFile) {
idForUrl = is.localFile;
} else {
Expand Down
29 changes: 29 additions & 0 deletions src/shared/js/utils/parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,30 @@ const makeSciencePaper = async (url) => {
return { author, bibtex, id, key, note, pdfLink, title, venue, year };
};

const makeFrontiersPaper = async (url) => {
url = url.replace(/\/pdf$/, "/full");
const doi = noParamUrl(url).split("/articles/")[1].split("/full")[0];
const bib = await fetchText(`https://www.frontiersin.org/articles/${doi}/bibTex`);
const data = Object.fromEntries(
Object.entries(bibtexToObject(bib)).map(([k, v]) => [
k === "citationKey" || k === "entryType" ? k : k.toLowerCase(),
v,
])
);
data.author = flipAndAuthors(data.author);
delete data.abstract;
const { author, journal, year, title, citationKey } = data;
const bibtex = bibtexToString(data);

const venue = journal;
const note = `Published @ ${venue} (${year})`;
const id = `Frontiers-${year}_${miniHash(doi)}`;
const key = citationKey;
const pdfLink = url.replace(/\/full$/, "/pdf");

return { author, bibtex, id, key, note, pdfLink, title, venue, year };
};

// -------------------------------
// ----- PREPRINT MATCHING -----
// -------------------------------
Expand Down Expand Up @@ -1605,6 +1629,11 @@ const makePaper = async (is, url) => {
if (paper) {
paper.source = "science";
}
} else if (is.frontiers) {
paper = await makeFrontiersPaper(url);
if (paper) {
paper.source = "frontiers";
}
} else {
throw new Error("Unknown paper source: " + JSON.stringify({ is, url }));
}
Expand Down
6 changes: 3 additions & 3 deletions src/shared/min/utils.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions test/data/urls.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
"venue": "cvpr"
}
],
"frontiers": [
"https://www.frontiersin.org/articles/10.3389/fpace.2022.892330/full",
"https://www.frontiersin.org/articles/10.3389/fpace.2022.892330/pdf",
{
"noPdf": true
}
],
"ijcai": [
"https://www.ijcai.org/proceedings/2020/1",
"https://www.ijcai.org/proceedings/2020/0001.pdf",
Expand Down
6 changes: 6 additions & 0 deletions test/test-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ describe("Test paper detection and storage", function () {
`prevents automated browsing`
);
delete urls[source];
} else if (targets.length === 3 && targets[2].noPdf) {
console.log(
`\n>>> Skipping test for ${source} because its ` +
`pdf page does not exist`
);
delete urls[source];
}
}

Expand Down

0 comments on commit 45883f8

Please sign in to comment.