Skip to content

Commit 8818d55

Browse files
committed
Merge branch 'dev' into fontawesome-update
2 parents b05f206 + 41545d9 commit 8818d55

13 files changed

Lines changed: 184 additions & 290 deletions

File tree

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Changelog
22

3+
## 2022-01-20
4+
5+
### New features
6+
7+
- backend data sanitization
8+
- pdfs searchable by the searchbox
9+
10+
### Changes
11+
12+
- data preprocessing refactoring
13+
14+
### Bug fixes
15+
16+
- footer size on narrow screens
17+
18+
### Internal
19+
20+
- test database update
21+
22+
## 2021-12-22
23+
24+
### Changes
25+
26+
- unified HTML & CSS of various paper tags (access tags, dataset tag, custom tags)
27+
328
## 2021-12-09
429

530
### New features

server/storage/test.sqlite

1.43 MB
Binary file not shown.

vis/js/default-config.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,6 @@ var config = {
267267
cite_vis_km: "Please cite this knowledge map as follows",
268268
cite_vis_sg: "Please cite this streamgraph as follows",
269269
cite_paper: "Cite this document as",
270-
cite_metadata_warn_1: "Unfortunately important metadata is missing",
271-
cite_metadata_warn_2: "for this document (e.g. title, authors, year). Therefore we are unable to provide meaningful citations. If you'd like to find out more about this document, please visit the",
272-
cite_metadata_warn_3: "document's website",
273270
},
274271
ger: {
275272
loading: "Wird geladen...",
@@ -340,9 +337,6 @@ var config = {
340337
cite_vis_km: "Please cite this knowledge map as follows",
341338
cite_vis_sg: "Please cite this streamgraph as follows",
342339
cite_paper: "Cite this document as",
343-
cite_metadata_warn_1: "Unfortunately important metadata is missing",
344-
cite_metadata_warn_2: "for this document (e.g. title, authors, year). Therefore we are unable to provide meaningful citations. If you'd like to find out more about this document, please visit the",
345-
cite_metadata_warn_3: "document's website",
346340
},
347341
ger_linkedcat: {
348342
loading: "Wird geladen...",
@@ -416,9 +410,6 @@ var config = {
416410
cite_vis_km: "Please cite this knowledge map as follows",
417411
cite_vis_sg: "Please cite this streamgraph as follows",
418412
cite_paper: "Cite this document as",
419-
cite_metadata_warn_1: "Unfortunately important metadata is missing",
420-
cite_metadata_warn_2: "for this document (e.g. title, authors, year). Therefore we are unable to provide meaningful citations. If you'd like to find out more about this document, please visit the",
421-
cite_metadata_warn_3: "document's website",
422413
},
423414
eng_plos: {
424415
loading: "Loading...",
@@ -481,9 +472,6 @@ var config = {
481472
cite_vis_km: "Please cite this knowledge map as follows",
482473
cite_vis_sg: "Please cite this streamgraph as follows",
483474
cite_paper: "Cite this document as",
484-
cite_metadata_warn_1: "Unfortunately important metadata is missing",
485-
cite_metadata_warn_2: "for this document (e.g. title, authors, year). Therefore we are unable to provide meaningful citations. If you'd like to find out more about this document, please visit the",
486-
cite_metadata_warn_3: "document's website",
487475
},
488476
eng_pubmed: {
489477
loading: "Loading knowledge map.",
@@ -567,9 +555,6 @@ var config = {
567555
cite_vis_km: "Please cite this knowledge map as follows",
568556
cite_vis_sg: "Please cite this streamgraph as follows",
569557
cite_paper: "Cite this document as",
570-
cite_metadata_warn_1: "Unfortunately important metadata is missing",
571-
cite_metadata_warn_2: "for this document (e.g. title, authors, year). Therefore we are unable to provide meaningful citations. If you'd like to find out more about this document, please visit the",
572-
cite_metadata_warn_3: "document's website",
573558
},
574559
eng_openaire: {
575560
loading: "Loading...",
@@ -659,9 +644,6 @@ var config = {
659644
cite_vis_km: "Please cite this knowledge map as follows",
660645
cite_vis_sg: "Please cite this streamgraph as follows",
661646
cite_paper: "Cite this document as",
662-
cite_metadata_warn_1: "Unfortunately important metadata is missing",
663-
cite_metadata_warn_2: "for this document (e.g. title, authors, year). Therefore we are unable to provide meaningful citations. If you'd like to find out more about this document, please visit the",
664-
cite_metadata_warn_3: "document's website",
665647
},
666648
ger_cris: {
667649
loading: "Wird geladen...",
@@ -725,9 +707,6 @@ var config = {
725707
cite_vis_km: "Please cite this knowledge map as follows",
726708
cite_vis_sg: "Please cite this streamgraph as follows",
727709
cite_paper: "Cite this document as",
728-
cite_metadata_warn_1: "Unfortunately important metadata is missing",
729-
cite_metadata_warn_2: "for this document (e.g. title, authors, year). Therefore we are unable to provide meaningful citations. If you'd like to find out more about this document, please visit the",
730-
cite_metadata_warn_3: "document's website",
731710
},
732711
ger_cris_2: {
733712
loading: "Wird geladen...",
@@ -791,9 +770,6 @@ var config = {
791770
cite_vis_km: "Please cite this knowledge map as follows",
792771
cite_vis_sg: "Please cite this streamgraph as follows",
793772
cite_paper: "Cite this document as",
794-
cite_metadata_warn_1: "Unfortunately important metadata is missing",
795-
cite_metadata_warn_2: "for this document (e.g. title, authors, year). Therefore we are unable to provide meaningful citations. If you'd like to find out more about this document, please visit the",
796-
cite_metadata_warn_3: "document's website",
797773
},
798774
eng_cris_2: {
799775
loading: "Loading...",
@@ -861,9 +837,6 @@ var config = {
861837
cite_vis_km: "Please cite this knowledge map as follows",
862838
cite_vis_sg: "Please cite this streamgraph as follows",
863839
cite_paper: "Cite this document as",
864-
cite_metadata_warn_1: "Unfortunately important metadata is missing",
865-
cite_metadata_warn_2: "for this document (e.g. title, authors, year). Therefore we are unable to provide meaningful citations. If you'd like to find out more about this document, please visit the",
866-
cite_metadata_warn_3: "document's website",
867840
},
868841
eng_gsheets: {
869842
loading: "Updating and retrieving map. This may take a few seconds, please hold on.",
@@ -945,9 +918,6 @@ var config = {
945918
cite_vis_km: "Please cite this knowledge map as follows",
946919
cite_vis_sg: "Please cite this streamgraph as follows",
947920
cite_paper: "Cite this document as",
948-
cite_metadata_warn_1: "Unfortunately important metadata is missing",
949-
cite_metadata_warn_2: "for this document (e.g. title, authors, year). Therefore we are unable to provide meaningful citations. If you'd like to find out more about this document, please visit the",
950-
cite_metadata_warn_3: "document's website",
951921
},
952922
},
953923

vis/js/templates/listentry/Details.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ const Details = ({ authors, source, isSelected }) => {
2424
</div>
2525
{!!source && (
2626
<div className={"list_source" + (isSelected ? "" : " short")}>
27-
<span className="list_in">
28-
<Highlight> in </Highlight>
29-
</span>
3027
<span className="list_published_in">
3128
<Highlight queryHighlight>{source}</Highlight>
3229
</span>

vis/js/templates/listentry/PaperButtons.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { connect } from "react-redux";
44
import useMatomo from "../../utils/useMatomo";
55
import { getPaperPDFClickHandler } from "../../utils/data";
66
import { mapDispatchToListEntriesProps } from "../../utils/eventhandlers";
7+
import Highlight from "../../components/Highlight";
78

89
const PaperButtons = ({
910
paper,
@@ -29,8 +30,8 @@ const PaperButtons = ({
2930
// html template starts here
3031
<div className="paper_buttons_row">
3132
{!!onPDFClick && (
32-
<button className="paper_button" onClick={handlePDFButtonClick}>
33-
<i className="far fa-file-pdf"></i>&nbsp;&nbsp;PDF
33+
<button className="paper_button main" onClick={handlePDFButtonClick}>
34+
<i className="far fa-file-pdf"></i>&nbsp;&nbsp;<Highlight>PDF</Highlight>
3435
</button>
3536
)}
3637
{showCiteButton && (

vis/js/templates/modals/CitePaperModal.jsx

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ const CitePaperModal = ({ open, onClose, paper }) => {
1616

1717
const citationText = paper ? getCitation(paper) : "";
1818

19-
const metadataMissing =
20-
!paper ||
21-
!paper.title ||
22-
!paper.authors_objects ||
23-
paper.authors_objects.length === 0 ||
24-
!paper.year;
25-
2619
return (
2720
// html template starts here
2821
<Modal id="cite_paper_modal" show={open} onHide={onClose}>
@@ -55,24 +48,6 @@ const CitePaperModal = ({ open, onClose, paper }) => {
5548
</div>
5649
<p className="cit-style-desc">{currentStyle.description}</p>
5750
<CopyButton textId={"copy-paper-citation"} textContent={citationText} />
58-
{metadataMissing && paper && (
59-
<p className="cite-paper-warning">
60-
<strong>{loc.cite_metadata_warn_1}</strong>{" "}
61-
{loc.cite_metadata_warn_2}{" "}
62-
<a
63-
href={
64-
paper.list_link.isDoi
65-
? `https://dx.doi.org/${paper.list_link.address}`
66-
: paper.list_link.address
67-
}
68-
target="_blank"
69-
rel="noreferrer"
70-
>
71-
{loc.cite_metadata_warn_3}
72-
</a>
73-
.
74-
</p>
75-
)}
7651
</Modal.Body>
7752
</Modal>
7853
// html template ends here

vis/js/utils/data.js

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -83,54 +83,48 @@ const getParamFilterFunction = (param, field) => {
8383
};
8484
};
8585

86+
const SEARCHED_PROPS = [
87+
"title",
88+
"authors_string",
89+
"published_in",
90+
"year",
91+
"subject_orig",
92+
"tags",
93+
"comments_for_filtering",
94+
"resulttype",
95+
"paper_abstract",
96+
];
97+
8698
/**
8799
* Creates a paper filtering function from the search words.
88100
*
89-
* Function taken from legacy list.js
90-
* @param {Array} search_words array of search words (plaintext strings)
101+
* @param {Array} searchedKeywords array of search keywords (plaintext strings)
91102
*
92-
* @returns {Function} filtering function
103+
* @returns {Function} filtering function that returns true if paper contains all the searched keywords
93104
*/
94-
const getWordFilterFunction = (search_words) => {
95-
return (d) => {
96-
const abstract = getPropertyOrEmptyString(d, "paper_abstract");
97-
const title = getPropertyOrEmptyString(d, "title");
98-
const authors = getPropertyOrEmptyString(d, "authors_string");
99-
const journals = getPropertyOrEmptyString(d, "published_in");
100-
const year = getPropertyOrEmptyString(d, "year");
101-
const keywords = getPropertyOrEmptyString(d, "subject_orig");
102-
const tags = getPropertyOrEmptyString(d, "tags");
103-
const comments = getPropertyOrEmptyString(d, "comments_for_filtering");
104-
const resulttype = getPropertyOrEmptyString(d, "resulttype");
105-
// TODO: make these two properties language-aware
106-
const open_access = d.oa ? "open access" : "";
107-
const free_access = d.free_access ? "free access" : "";
108-
109-
let i = 0;
110-
let word_found = true;
111-
while (word_found && i < search_words.length) {
112-
word_found =
113-
abstract.indexOf(search_words[i]) !== -1 ||
114-
title.indexOf(search_words[i]) !== -1 ||
115-
authors.indexOf(search_words[i]) !== -1 ||
116-
journals.indexOf(search_words[i]) !== -1 ||
117-
year.indexOf(search_words[i]) !== -1 ||
118-
keywords.indexOf(search_words[i]) !== -1 ||
119-
tags.indexOf(search_words[i]) !== -1 ||
120-
comments.indexOf(search_words[i]) !== -1 ||
121-
resulttype.indexOf(search_words[i]) !== -1 ||
122-
open_access.indexOf(search_words[i]) !== -1 ||
123-
free_access.indexOf(search_words[i]) !== -1;
124-
i++;
105+
const getWordFilterFunction = (searchedKeywords) => {
106+
return (paper) => {
107+
const paperKeywords = SEARCHED_PROPS.map((prop) =>
108+
getPropertyOrEmptyString(paper, prop)
109+
);
110+
111+
if (paper.oa) {
112+
paperKeywords.push("open access");
113+
paperKeywords.push("pdf");
125114
}
115+
if (paper.free_access) {
116+
paperKeywords.push("free access");
117+
}
118+
119+
const paperString = paperKeywords.join(" ");
126120

127-
return word_found;
121+
return !searchedKeywords.some((keyword) => !paperString.includes(keyword));
128122
};
129123
};
130124

131125
const getPropertyOrEmptyString = (object, property) => {
132126
if (Object.prototype.hasOwnProperty.call(object, property)) {
133-
return object[property].toString().toLowerCase();
127+
return object[property].toString().toLowerCase().trim();
134128
}
135129

136130
return "";

vis/js/utils/useCitationStyle.js

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ export const availableStyles = [
3838
name: "ACM",
3939
template: "custom-acm",
4040
description: 'ACM SIG Proceedings ("et al." for 3+ authors)',
41+
append: (paper) => {
42+
// feature request from Peter, not an official part of ACM
43+
if (!paper.list_link.isDoi) {
44+
return " " + paper.list_link.address;
45+
}
46+
47+
return "";
48+
},
4149
},
4250
];
4351

@@ -46,6 +54,7 @@ const useCitationStyle = () => {
4654

4755
const getCitation = (paper) => {
4856
// format derived from the example JSON: https://citation.js.org/demo/
57+
// full list of parameters: node_modules/@citation-js/core/lib/plugins/input/csl.js
4958
const cite = new Cite({
5059
id: paper.safe_id,
5160
title: paper.title,
@@ -55,17 +64,65 @@ const useCitationStyle = () => {
5564
})),
5665
issued: [{ "date-parts": paper.year.split("-") }],
5766
"container-title": paper.published_in,
58-
DOI: paper.list_link.isDoi ? paper.list_link.address : undefined,
59-
url: paper.list_link.isDoi ? undefined : paper.list_link.address,
60-
// other possible attributes: "type", "volume", "issue", "page", ???
67+
DOI: paper.list_link.isDoi
68+
? paper.list_link.address.replace(/(https?:\/\/)?(\w+\.)?doi.org\//, "")
69+
: undefined,
70+
URL: paper.list_link.isDoi ? undefined : paper.list_link.address,
71+
// this information could be misleading, so we'll hide it for now:
72+
//source: "Open Knowledge Maps",
73+
type: getType(paper),
6174
});
6275

63-
return cite.format("bibliography", {
76+
let output = cite.format("bibliography", {
6477
template: style.template,
6578
});
79+
80+
if (style.append) {
81+
output += style.append(paper);
82+
}
83+
84+
return output;
6685
};
6786

6887
return [style, setStyle, getCitation];
6988
};
7089

7190
export default useCitationStyle;
91+
92+
// mapping of BASE type to CSL type
93+
const TYPE_TO_TYPE = [
94+
["Journal/newspaper article", "article-journal"],
95+
["Journal/newspaper other content", "article-journal"],
96+
["Journal/newspaper", "periodical"],
97+
["Book", "book"],
98+
["Book part", "chapter"],
99+
["Conference object", "paper-conference"],
100+
["Dataset", "dataset"],
101+
["Manuscript", "manuscript"],
102+
["Map", "map"],
103+
["Moving image/video", "motion_picture"],
104+
["Patent", "patent"],
105+
["Report", "report"],
106+
["Review", "review"],
107+
["Software", "software"],
108+
["Still image", "graphic"],
109+
["Thesis", "thesis"],
110+
["Thesis: bachelor", "thesis"],
111+
["Thesis: doctoral and postdoctoral", "thesis"],
112+
["Thesis: master", "thesis"],
113+
];
114+
115+
const getType = (paper) => {
116+
const types = paper.resulttype;
117+
if (!types || types.length === 0) {
118+
return undefined;
119+
}
120+
121+
for (const entry of TYPE_TO_TYPE) {
122+
if (types.includes(entry[0])) {
123+
return entry[1];
124+
}
125+
}
126+
127+
return undefined;
128+
};

0 commit comments

Comments
 (0)