Skip to content

Commit

Permalink
Merge branch 'master' into mkdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
vict0rsch authored Nov 20, 2023
2 parents 757314e + d12bfe2 commit 0e4d432
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/bibMatcher/bibMatcher.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h1>Bib Matcher</h1>
<div class="d-flex-center-center">
<input type="checkbox" id="api-timeout" checked class="switch"
style="min-width: 38px">&nbsp;&nbsp;
<label for="api-timeout" style="min-width: 150px">Wait for 2s between queries</label>
<label for="api-timeout" style="min-width: 150px">Wait for 3s between queries</label>
</div>
<br />
<div class="option-help d-flex-center-center">Data providers protect their APIs by restricting
Expand Down
2 changes: 1 addition & 1 deletion src/bibMatcher/bibMatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ const matchItems = async (papersToMatch) => {
);
changeProgress(parseInt((idx / papersToMatch.length) * 100));

apiTimeout && idx > 0 && (await sleep(2000));
apiTimeout && idx > 0 && (await sleep(3000));

let { bibtex, source, venue } = await matchPaper(paper);

Expand Down
14 changes: 13 additions & 1 deletion src/options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,19 @@ <h3>Syncronization conflict</h3>
<script src="../shared/min/jquery.min.js"></script>
<script src="../popup/js/select2.min.js"></script>
<script src="highlight.min.js"></script>
<script src="../shared/min/utils.min.js"></script>

<script src="../shared/js/utils/logTrace.js"></script>
<script src="../shared/js/utils/miniquery.js"></script>
<script src="../shared/js/utils/config.js"></script>
<script src="../shared/js/utils/gist.js"></script>
<script src="../shared/js/utils/sync.js"></script>
<script src="../shared/js/utils/functions.js"></script>
<script src="../shared/js/utils/data.js"></script>
<script src="../shared/js/utils/paper.js"></script>
<script src="../shared/js/utils/state.js"></script>
<script src="../shared/js/utils/bibtexParser.js"></script>
<script src="../shared/js/utils/parsers.js"></script>

<script src="options.js"></script>
</body>

Expand Down
27 changes: 27 additions & 0 deletions src/shared/js/utils/bibtexParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,30 @@ function BibtexParser() {
});
};

this.cleanCitationKey = function () {
// "hern{\\'a}ndez-garc{\\'\\i}a2021rethinking" -> "hernandez-garcia2021rethinking"
const start = this.pos;
const end = start + this.input.slice(start).indexOf(",");

const left = this.input.slice(0, start);
const right = this.input.slice(end);

const citationKey = this.input.slice(start, end);
const openingParts = citationKey.split("{");
let newCitationKey = openingParts[0];
for (var i = 1; i < openingParts.length; i++) {
const closingParts = openingParts[i].split("}");
newCitationKey += closingParts[0].replace(/\W/g, "") + closingParts[1];
}
newCitationKey = newCitationKey.replace(/\s+/g, "");
this.input = left + newCitationKey + right;
};

this.bibtex = function () {
while (this.matchAt()) {
var d = this.directive();
this.match("{");
this.cleanCitationKey();
if (d.toUpperCase() == "@STRING") {
this.string();
} else if (d.toUpperCase() == "@PREAMBLE") {
Expand Down Expand Up @@ -326,6 +346,13 @@ const bibtexToString = (bibtex) => {
if (typeof bibtex === "string") {
bibtex = bibtexToObject(bibtex);
}
if (bibtex.hasOwnProperty("entryTags")) {
bibtex = {
...bibtex.entryTags,
entryType: bibtex.entryType,
citationKey: bibtex.citationKey,
};
}

bibtex = { ...bibtex };
let bstr = `@${bibtex.entryType.toLowerCase()}{${bibtex.citationKey},\n`;
Expand Down
40 changes: 36 additions & 4 deletions src/shared/js/utils/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,14 @@ const migrateData = async (papers, manifestDataVersion, store = true) => {
}
if (currentVersion < 450) {
if (!papers[id].hasOwnProperty("venue")) {
papers[id].venue = await makeVenue(papers[id]);
migrationSummaries[id].push("(m450) venue from id");
try {
papers[id].venue = await makeVenue(papers[id]);
migrationSummaries[id].push("(m450) venue from id");
} catch (error) {
logError(error);
papers[id].venue = "";
migrationSummaries[id].push("(m450) ERROR in venue from id");
}
}
}
if (currentVersion < 502) {
Expand Down Expand Up @@ -446,6 +452,17 @@ const validatePaper = (paper, log = true) => {
author: {
type: "string",
desc: "` and `-separated authors `${firstName} ${lastName}`",
validation: (p) => {
if (!p) {
throw Error(
`No author: ${p} for paper ${paper.id}:\n${JSON.stringify(
paper,
null,
2
)}\nFix the json file and try again.\n`
);
}
},
},
bibtex: {
type: "string",
Expand All @@ -454,7 +471,7 @@ const validatePaper = (paper, log = true) => {
try {
bibtexToObject(p);
} catch (error) {
return `Invalid BibTex: ${error}`;
return `Invalid BibTex: ${error} :\n${p}`;
}
},
},
Expand Down Expand Up @@ -545,6 +562,21 @@ const validatePaper = (paper, log = true) => {
desc: "the user's tags for this paper",
default: (p) => [],
},
title: {
type: "string",
desc: "the paper's title",
validation: (p) => {
if (!p) {
throw Error(
`No title: ${p} for paper ${paper.id}:\n${JSON.stringify(
paper,
null,
2
)}\nFix the json file and try again.\n`
);
}
},
},
venue: {
type: "string",
desc: "the paper's publication venue",
Expand Down Expand Up @@ -642,7 +674,7 @@ const validatePaper = (paper, log = true) => {
warns[key] = [];
}
warns[key].push(validation);
log && console.warn(validation);
log && console.warn(validation + ` (${paper.id})`);
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/shared/js/utils/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,10 @@ const spaceCamelCase = (str) =>

const toSingleSpace = (str) => str.replace(/\s\s+/g, " ");

const dedent = (str) => {
return ("" + str).replace(/(\n)\s+/g, "$1");
};

const arxivIdFromPaperID = (paperId) => paperId.split("-").last().replace("_", "/");

const arxivIdFromURL = (url) =>
Expand Down
13 changes: 13 additions & 0 deletions src/shared/js/utils/parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,19 @@ const makeOpenReviewPaper = async (url) => {
const noteJson = await getOpenReviewNoteJSON(url);
const forumJson = await getOpenReviewForumJSON(url);

if (noteJson.status === 403 && noteJson.name === "ForbiddenError") {
logError(
dedent(`Error parsing OpenReview url ${url}.
Most likely because this entry is protected and you do not have the rights to access it.
1/ Make sure you are logged in.
2/ Alternatively, this may be due to OpenReview changing the visibility of this paper.
Try accessing this URL manually to make sure.`)
);
throw Error(noteJson.message);
}

var paper = noteJson.notes[0];
var forum = forumJson.notes;

Expand Down
13 changes: 10 additions & 3 deletions src/shared/min/utils.min.js

Large diffs are not rendered by default.

0 comments on commit 0e4d432

Please sign in to comment.