Skip to content

Commit d0f8ddf

Browse files
committed
Merge remote-tracking branch 'upstream/interface-changes-export-new' into interface-changes-export-backend
2 parents 6d08edd + 1f5e428 commit d0f8ddf

27 files changed

Lines changed: 380 additions & 215 deletions

File tree

examples/project_website/data/production.json

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"doc": "doc"
88
},
99
"scripts": {
10-
"test": "jest",
10+
"test": "TZ='Europe/Vienna' jest",
1111
"dev": "webpack --progress --watch --mode=development",
1212
"prod": "webpack --progress",
1313
"start": "webpack serve --progress --mode=development --env publicPath=http://localhost:8080/dist/",

vis/js/components/ContextLine.js

Lines changed: 13 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from "react";
22
import { connect } from "react-redux";
33

44
import ContextLineTemplate from "../templates/ContextLine";
5-
import HoverPopover from "../templates/HoverPopover";
65
import Author from "../templates/contextfeatures/Author";
76
import DocumentTypes from "../templates/contextfeatures/DocumentTypes";
87
import NumArticles from "../templates/contextfeatures/NumArticles";
@@ -15,10 +14,9 @@ import ProjectRuntime from "../templates/contextfeatures/ProjectRuntime";
1514
import LegacySearchLang from "../templates/contextfeatures/LegacySearchLang";
1615
import SearchLang from "../templates/contextfeatures/SearchLang";
1716
import Timestamp from "../templates/contextfeatures/Timestamp";
18-
import MetadataQuality from "../templates/contextfeatures/MetadataQuality";
1917
import Modifier from "../templates/contextfeatures/Modifier";
20-
import { trackMatomoEvent } from "../utils/useMatomo";
2118
import MoreInfoLink from "../templates/contextfeatures/MoreInfoLink";
19+
import MetadataQuality from "../templates/contextfeatures/MetadataQuality";
2220

2321
const defined = (param) => param !== undefined && param !== null;
2422

@@ -29,7 +27,8 @@ const defined = (param) => param !== undefined && param !== null;
2927
*/
3028
class ContextLine extends React.Component {
3129
render() {
32-
const { params, localization, hidden } = this.props;
30+
const { params, localization, hidden, service } = this.props;
31+
const { popoverContainer } = this.props;
3332

3433
if (hidden) {
3534
return null;
@@ -49,7 +48,7 @@ class ContextLine extends React.Component {
4948
openAccessArticlesCount={params.openAccessCount}
5049
articlesCountLabel={localization.articles_label}
5150
>
52-
<Modifier popoverContainer={this.props.popoverContainer} />
51+
<Modifier popoverContainer={popoverContainer} />
5352
</NumArticles>
5453
{defined(params.dataSource) && (
5554
<DataSource
@@ -58,7 +57,10 @@ class ContextLine extends React.Component {
5857
/>
5958
)}
6059
{defined(params.timespan) && <Timespan>{params.timespan}</Timespan>}
61-
{this.renderDocTypes()}
60+
<DocumentTypes
61+
documentTypes={params.documentTypes}
62+
popoverContainer={popoverContainer}
63+
/>
6264
{defined(params.paperCount) && (
6365
<PaperCount
6466
value={params.paperCount}
@@ -84,92 +86,18 @@ class ContextLine extends React.Component {
8486
label={localization.timestamp_label}
8587
/>
8688
)}
87-
{this.renderMetadataQuality()}
89+
<MetadataQuality
90+
quality={params.metadataQuality}
91+
service={service}
92+
popoverContainer={popoverContainer}
93+
/>
8894
{defined(params.searchLanguage) && (
8995
<SearchLang>{params.searchLanguage}</SearchLang>
9096
)}
9197
<MoreInfoLink />
9298
</ContextLineTemplate>
9399
);
94100
}
95-
96-
// TODO refactor this function to a standalone template
97-
renderDocTypes() {
98-
const {
99-
params: { documentTypes },
100-
localization,
101-
popoverContainer,
102-
} = this.props;
103-
104-
if (!documentTypes || documentTypes.length === 0) {
105-
return null;
106-
}
107-
108-
const text = documentTypes.join(", ");
109-
110-
const trackMouseOver = () =>
111-
trackMatomoEvent("Title & Context line", "Hover document types", "Context line");
112-
113-
return (
114-
<>
115-
<span
116-
id="document_types"
117-
className="context_item"
118-
onMouseOver={trackMouseOver}
119-
>
120-
<HoverPopover
121-
id="doctypes-popover"
122-
size="wide"
123-
container={popoverContainer}
124-
content={
125-
<>
126-
{localization.documenttypes_tooltip}
127-
<br />
128-
<br />
129-
{text}
130-
</>
131-
}
132-
>
133-
<DocumentTypes label={localization.documenttypes_label} />
134-
</HoverPopover>
135-
</span>{" "}
136-
</>
137-
);
138-
}
139-
140-
// TODO refactor this function to a standalone template
141-
renderMetadataQuality() {
142-
const {
143-
params: { metadataQuality },
144-
localization,
145-
popoverContainer,
146-
service,
147-
} = this.props;
148-
149-
if (
150-
!metadataQuality ||
151-
(metadataQuality !== "low" && metadataQuality !== "high")
152-
) {
153-
return null;
154-
}
155-
156-
return (
157-
<span className="context_item" id="metadata_quality">
158-
<HoverPopover
159-
id="metadata-quality-popover"
160-
container={popoverContainer}
161-
content={
162-
localization[metadataQuality + "_metadata_quality_desc_" + service]
163-
}
164-
>
165-
<MetadataQuality
166-
quality={metadataQuality}
167-
label={localization[[metadataQuality + "_metadata_quality"]]}
168-
/>
169-
</HoverPopover>
170-
</span>
171-
);
172-
}
173101
}
174102

175103
const mapStateToProps = (state) => ({

vis/js/components/Highlight.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,17 @@ const hyphenateStringSafely = (string) => {
9090
*
9191
* The query term must match the word in the text exactly. Supported boundaries
9292
* are whitespace, period, comma, question mark, exclamation mark, hyphen,
93-
* slash and brackets.
93+
* semicolon, slash and brackets.
9494
*
9595
* The boundary must not be a soft hyphen (that's why we cannot simply use \b).
9696
*
9797
* @param {string} term the term to be matched
9898
* @param {boolean} useLookBehind use ?<= if true, else use \b
9999
*/
100100
export const getQueryTermMatcher = (term, useLookBehind) => {
101-
// this should theoretically work but it does not: [^\w\u00AD]
101+
// this should theoretically work but it does not: [^\w\u00AD] (??? is this still true?)
102102
// this is used instead:
103-
const wordBreakers = "[-\\s.,:?!/()[\\]{}]";
103+
const wordBreakers = "[-\\s.,:;?!/()[\\]{}]";
104104
let lookBehind = `(?<=${wordBreakers}|^)`;
105105
if (!useLookBehind) {
106106
lookBehind = "\\b";

vis/js/dataprocessing/managers/DataManager.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class DataManager {
107107
this.papers.forEach((paper) => {
108108
paper.safe_id = this.__getSafeId(paper);
109109
this.__escapeStrings(paper);
110+
this.__sanitizeTitle(paper);
110111
this.__parseAuthors(paper);
111112
this.__parseCoordinates(paper);
112113
while (blockedCoords[`${paper.x}:${paper.y}`]) {
@@ -135,6 +136,10 @@ class DataManager {
135136
});
136137
}
137138

139+
__sanitizeTitle(paper) {
140+
paper.title = paper.title.trim();
141+
}
142+
138143
__parseAuthors(paper) {
139144
paper.authors_objects = extractAuthors(paper.authors);
140145
paper.authors_list = getAuthorsList(

vis/js/reducers/query.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ const cleanQuery = (query) => {
2020
if (typeof query !== "string") {
2121
return null;
2222
}
23-
24-
let cleanedQuery = query.replace(/\\(.?)/g, "$1");
23+
24+
const cleanedQuery = query.replace(/\\(.?)/g, "$1");
2525

2626
return cleanedQuery;
27-
}
27+
};
2828

2929
/**
3030
* Parses query and returns all its terms.
@@ -41,30 +41,30 @@ const getQueryTerms = (context) => {
4141
return [];
4242
}
4343

44-
const originalQuery = context.query;
45-
46-
// Replace terms within square brackets, as they denote fields in PubMed
47-
const fullQuery = originalQuery.replace(/\[(.*?)\]/g, "");
44+
const cleanedQuery = context.query
45+
// Remove terms within square brackets, as they denote fields in PubMed
46+
.replace(/\[(.*?)\]/g, "")
47+
// Replace different types of quotes
48+
.replace(/[]/g, '"');
4849

4950
// Get all phrases and remove quotes from results
5051
const phraseRegex = /"(.*?)"/g;
51-
let phraseArray = fullQuery.match(phraseRegex);
52+
let phraseArray = cleanedQuery.match(phraseRegex);
5253
if (phraseArray === null) {
5354
phraseArray = [];
5455
}
5556

5657
// Replace backslashed quotes??
57-
// TODO test this one, it seems to be redundant
5858
phraseArray = phraseArray.map((x) => x.replace(/\\"|"/g, ""));
5959

6060
// Remove phrases, and, or, +, -, (, ) from query string
61-
const queryWtPhrases = fullQuery.replace(phraseRegex, " ");
62-
const cleanQuery = queryWtPhrases
61+
const queryWtPhrases = cleanedQuery
62+
.replace(phraseRegex, " ")
6363
.replace(/\band\b|\bor\b|\(|\)/g, "")
6464
.replace(/(^|\s)-|\+/g, " ");
6565

6666
phraseArray = phraseArray.concat(
67-
cleanQuery.trim().replace(/\s+/g, " ").split(" ")
67+
queryWtPhrases.trim().split(/\s+/)
6868
);
6969

7070
// Remove backslashes, colons and empty words

vis/js/templates/ListToggle.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,15 @@ const ListToggle = ({
5050

5151
return (
5252
// html template starts here
53-
<div id="show_hide_button" className="row" onClick={handleClick}>
54-
<div className="col-xs-2"></div>
53+
<div
54+
id="show_hide_button"
55+
className="row"
56+
onClick={handleClick}
57+
title={isShown ? "Hide list" : "Show list"}
58+
>
59+
<div className="col-xs-2">
60+
<i className="fas fa-chevron-down chevron"></i>
61+
</div>
5562
<div className="col-xs-8" id="show_hide_button_label">
5663
<span id="show_hide_label">
5764
<span>
@@ -62,7 +69,9 @@ const ListToggle = ({
6269
</span>
6370
</span>
6471
</div>
65-
<div className="col-xs-2 text-right"></div>
72+
<div className="col-xs-2 text-right">
73+
<i className="fas fa-chevron-down chevron"></i>
74+
</div>
6675
</div>
6776
// html template ends here
6877
);

vis/js/templates/Paper.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,11 @@ class Paper extends React.Component {
211211
<Highlight hyphenated queryHighlight>
212212
{title}
213213
</Highlight>{" "}
214-
(
215-
<Highlight queryHighlight>
216-
{formatPaperDate(year)}
217-
</Highlight>
218-
)
214+
{!!year && (
215+
<Highlight queryHighlight>
216+
{`(${formatPaperDate(year)})`}
217+
</Highlight>
218+
)}
219219
</Hyphenate>
220220
</p>
221221
<p id="details" className={sizeModifierClass}>

vis/js/templates/contextfeatures/DocumentTypes.jsx

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,46 @@
11
import React from "react";
22

3-
const DocumentTypes = (props) => {
3+
import HoverPopover from "../HoverPopover";
4+
import { useLocalizationContext } from "../../components/LocalizationProvider";
5+
import useMatomo from "../../utils/useMatomo";
6+
7+
const DocumentTypes = ({ documentTypes, popoverContainer }) => {
8+
const loc = useLocalizationContext();
9+
const { trackEvent } = useMatomo();
10+
11+
if (!documentTypes || documentTypes.length === 0) {
12+
return null;
13+
}
14+
15+
const text = documentTypes.join(", ");
16+
17+
const trackMouseEnter = () =>
18+
trackEvent("Title & Context line", "Hover document types", "Context line");
19+
420
return (
5-
// html template starts here
6-
<span className="context_moreinfo" {...props}>
7-
{props.label}
8-
</span>
9-
// html template ends here
21+
<>
22+
<span
23+
id="document_types"
24+
className="context_item"
25+
onMouseEnter={trackMouseEnter}
26+
>
27+
<HoverPopover
28+
id="doctypes-popover"
29+
size="wide"
30+
container={popoverContainer}
31+
content={
32+
<>
33+
{loc.documenttypes_tooltip}
34+
<br />
35+
<br />
36+
{text}
37+
</>
38+
}
39+
>
40+
<span className="context_moreinfo">{loc.documenttypes_label}</span>
41+
</HoverPopover>
42+
</span>{" "}
43+
</>
1044
);
1145
};
1246

0 commit comments

Comments
 (0)