Skip to content

Commit

Permalink
Merge pull request #38 from vict0rsch/options
Browse files Browse the repository at this point in the history
  • Loading branch information
vict0rsch authored Dec 7, 2021
2 parents 8743365 + b1667ce commit d5fa0e4
Show file tree
Hide file tree
Showing 35 changed files with 1,153 additions and 453 deletions.
21 changes: 14 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This browser extension allows you to do automatically store research papers you

### Supported venues

* Arxiv
* Arxiv (PaperMemory will try to find if a pre-print has been published and create a corresponding `note` to the paper (see [preprints](#preprints)))
* BioRxiv
* NeurIPS
* Open Review (ICLR etc.)
Expand Down Expand Up @@ -116,6 +116,18 @@ Share ideas 💡 in [issues](https://github.com/vict0rsch/PaperMemory/issues) an
<img src="https://raw.github.com/vict0rsch/PaperMemory/master/extra/imgs/guide-memory.png?raw=true">
</p>

## Advanced

In the extension's `options` (right click on the icon or in the popup's menu) you will find advanced customization features:

* **Auto-tagging**: add tags to papers based on regexs matched on authors and titles
* **Custom title function**: provide Javascript code to generate your own web page titles and pdf filenames based on a paper's attributes
* **Data management**: export/load your memory data and export the bibliography as a `.bib` file

<p align="center">
<img src="https://raw.github.com/vict0rsch/PaperMemory/master/extra/imgs/options.png?raw=true">
</p>

## Install from source (Brave & Chrome)

* Download the repo
Expand All @@ -126,8 +138,6 @@ Share ideas 💡 in [issues](https://github.com/vict0rsch/PaperMemory/issues) an

## Preprints

(*Beta: upcoming in 3.4 -- install from source for early access*)

There currently exists, to my knowledge, no centralized source for matching a preprint to its subsequent published article. This makes it really hard to try and implement best practices in terms of citing published papers rather than their preprint.

My approach with PaperMemory is to try and notify you that a publication likely exists by utilizing the `note` field. You will occasionally notice `Accepted @ X` in a Paper's notes. This will be added automatically if you are on a known published venue's website (as PMLR or NeurIPS) but also from:
Expand All @@ -148,11 +158,8 @@ There's room for improvement here^, please contact me (an issue will do) if you

## Todo

* [ ] Update visuals
* [ ] Document `:` being replaced by `_` when downloading a pdf ([OS requirements...](https://stackoverflow.com/questions/30960190/problematic-characters-for-filename-in-chrome-downloads-download))
* [ ] Document backup and how to get it
* [ ] Improve `Contributing.md`
* [ ] Tests (WIP => [Puppeteer + Mocha #26](https://github.com/vict0rsch/PaperMemory/pull/26))
* [ ] Tests & Docs (WIP => [Puppeteer + Mocha #26](https://github.com/vict0rsch/PaperMemory/pull/26))

## Help

Expand Down
1 change: 1 addition & 0 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Once you load the local extension as an unpackaged extension, changes that affec

### File structure

(slightly deprecated since some files have moved but names are unique enough for you to still understand I hope)

```tree
├── jsconfig.json ➤➤➤ vscode js config
Expand Down
Binary file modified extra/imgs/d2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extra/imgs/options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 16 additions & 12 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ function popupJS() {
function utilsJS() {
return (
src([
"src/shared/utils/miniquery.js",
"src/shared/utils/config.js",
"src/shared/utils/levenshtein.js",
"src/shared/utils/functions.js",
"src/shared/utils/parsers.js",
"src/shared/js/utils/miniquery.js",
"src/shared/js/utils/config.js",
"src/shared/js/utils/levenshtein.js",
"src/shared/js/utils/functions.js",
"src/shared/js/utils/parsers.js",
])
// .pipe(debug())
.pipe(concat("utils.js"))
Expand All @@ -50,15 +50,15 @@ function utilsJS() {
)
.pipe(uglify({ mangle: true }))
.pipe(rename({ suffix: ".min" }))
.pipe(dest("src/shared/"))
.pipe(dest("src/shared/min"))
);
}

function themeJS() {
return src(["src/popup/js/theme.js"])
return src(["src/shared/js/theme.js"])
.pipe(uglify({ mangle: true }))
.pipe(rename({ suffix: ".min" }))
.pipe(dest("src/popup/min/"));
.pipe(dest("src/shared/min"));
}

function popupHTMLDev() {
Expand All @@ -78,9 +78,10 @@ function popupHTML() {

function popupCSS() {
return src([
"src/shared/css/vars.css",
"src/popup/css/options.css",
"src/popup/css/popup.css",
"src/shared/loader.css",
"src/shared/css/loader.css",
])
.pipe(concat("popup.css"))
.pipe(cleanCss())
Expand All @@ -96,10 +97,13 @@ function popupDarkCSS() {

function watchFiles() {
watch("src/popup/js/*.js", popupJS);
watch("src/popup/theme.js", themeJS);
watch("src/popup/css/*.css", parallel(popupCSS, popupDarkCSS));
watch("src/shared/js/theme.js", themeJS);
watch(
["src/popup/css/*.css", "src/shared/css/*.css"],
parallel(popupCSS, popupDarkCSS)
);
watch("src/popup/popup.html", popupHTMLDev);
watch("src/shared/utils/*", utilsJS);
watch("src/shared/js/utils/*", utilsJS);
}

function createArchive(cb) {
Expand Down
16 changes: 10 additions & 6 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Paper Memory",
"version": "0.3.4",
"version": "0.4.0",
"manifest_version": 2,
"description": "Automatically record papers you read from Arxiv, OpenReview & more! Organize your library with tags, links to code and quick notes.",
"homepage_url": "https://github.com/vict0rsch/PaperMemory",
Expand All @@ -10,8 +10,8 @@
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"background": {
"scripts": [
"src/shared/jquery.min.js",
"src/shared/utils.min.js",
"src/shared/min/jquery.min.js",
"src/shared/min/utils.min.js",
"src/background/background.js"
]
},
Expand All @@ -27,6 +27,10 @@
}
}
},
"options_ui": {
"page": "src/options/options.html",
"open_in_tab": true
},
"permissions": [
"https://arxiv.org/*",
"*://api.biorxiv.org/*",
Expand Down Expand Up @@ -56,12 +60,12 @@
],
"run_at": "document_start",
"js": [
"src/shared/jquery.min.js",
"src/shared/utils.min.js",
"src/shared/min/jquery.min.js",
"src/shared/min/utils.min.js",
"src/content_scripts/content_script.js"
],
"css": [
"src/shared/loader.css",
"src/shared/css/loader.css",
"src/content_scripts/content_script.css"
]
}
Expand Down
41 changes: 20 additions & 21 deletions src/content_scripts/content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ const contentScriptMain = async (url) => {
menu[m] = storedMenu.hasOwnProperty(m) ? storedMenu[m] : true;
}

menu.pdfTitleFn =
menu.pdfTitleFn && typeof menu.pdfTitleFn === "string"
? getPdfFn(menu.pdfTitleFn)
: defaultPDFTitleFn;

let is = isPaper(url);

if (is.arxiv) {
Expand All @@ -108,11 +103,9 @@ const contentScriptMain = async (url) => {

if (menu.checkPdfTitle) {
const makeTitle = async (id, url) => {
let title = global.state.papers.hasOwnProperty(id)
? global.state.papers[id].title
: "";
if (!title) return;
title = statePdfTitle(title, id);
if (!global.state.papers.hasOwnProperty(id)) return;
const paper = global.state.papers[id];
title = stateTitleFunction(paper);
window.document.title = title;
chrome.runtime.sendMessage({
type: "update-title",
Expand Down Expand Up @@ -196,11 +189,9 @@ const updatePaper = (papers, id) => {
return papers;
};

const arxiv = (checks) => {
const { checkMd, checkBib, checkDownload, pdfTitleFn } = checks;
global.state.pdfTitleFn = pdfTitleFn;

// console.log({ checks })
const arxiv = async (checks) => {
const { checkMd, checkBib, checkDownload } = checks;
global.state.titleFunction = (await getTitleFunction()).titleFunction;

const url = window.location.href;
const isArxivAbs = url.includes("https://arxiv.org/abs/");
Expand Down Expand Up @@ -235,12 +226,20 @@ const arxiv = (checks) => {
hasClass("arxiv-button", "downloaded") &&
removeClass("arxiv-button", "downloaded");
}, 1500);
const title = await $.get(
`https://export.arxiv.org/api/query?id_list=${id.split("-")[1]}`
).then((data) => {
return $($(data).find("entry title")[0]).text();
});
downloadFile(pdfUrl, statePdfTitle(title, id));
if (!global.state.papers.hasOwnProperty(id)) {
const title = await $.get(
`https://export.arxiv.org/api/query?id_list=${id.split("-")[1]}`
).then((data) => {
return $($(data).find("entry title")[0]).text();
});
downloadFile(pdfUrl, `${title}.pdf`);
} else {
let title = stateTitleFunction(id);
if (!title.endsWith(".pdf")) {
title += ".pdf";
}
downloadFile(pdfUrl);
}
});
}
// ---------------------------
Expand Down
Loading

0 comments on commit d5fa0e4

Please sign in to comment.