Skip to content

Commit f4dbd6c

Browse files
committed
added content provider info into Headstart
1 parent 834a97f commit f4dbd6c

6 files changed

Lines changed: 49 additions & 7 deletions

File tree

vis/js/components/ContextLine.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ class ContextLine extends React.Component {
5353
</NumArticles>
5454
{defined(params.dataSource) && (
5555
<DataSource
56-
value={params.dataSource}
5756
label={localization.source_label}
57+
source={params.dataSource}
58+
contentProvider={params.contentProvider}
59+
popoverContainer={this.props.popoverContainer}
5860
/>
5961
)}
6062
{defined(params.timespan) && <Timespan>{params.timespan}</Timespan>}

vis/js/reducers/contextLine.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const contextLine = (state = {}, action) => {
3838
typeof config.service_name !== "undefined"
3939
? config.service_name
4040
: config.service_names[context.service],
41+
contentProvider: context.params ? context.params.repo_name : null,
4142
paperCount:
4243
config.create_title_from_context_style === "viper"
4344
? papers.filter((p) => p.resulttype.includes("publication")).length

vis/js/templates/contextfeatures/DataSource.jsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,38 @@
11
import React from "react";
2+
import { shorten } from "../../utils/string";
3+
import HoverPopover from "../HoverPopover";
4+
5+
const MAX_CONTENT_PROVIDER_LENGTH = 20;
6+
7+
const DataSource = ({ label, source, contentProvider, popoverContainer }) => {
8+
if (contentProvider) {
9+
const content = (
10+
shorten(contentProvider, MAX_CONTENT_PROVIDER_LENGTH) + ` via ${source}`
11+
).replace("... via ", "...via ");
12+
13+
return (
14+
// html template starts here
15+
<span id="source" className="context_item">
16+
{label}:{" "}
17+
<HoverPopover
18+
id="doctypes-popover"
19+
container={popoverContainer}
20+
content={`${contentProvider} (via ${source})`}
21+
>
22+
<span className="context_moreinfo">{content}</span>
23+
</HoverPopover>
24+
</span>
25+
// html template ends here
26+
);
27+
}
228

3-
const DataSource = ({ label, value }) => {
429
return (
530
// html template starts here
631
<span
732
id="source"
833
className="context_item"
934
dangerouslySetInnerHTML={{
10-
__html: `${label}: ${value}`,
35+
__html: `${label}: ${source}`,
1136
}}
1237
></span>
1338
// html template ends here

vis/js/templates/modals/infomodal/subcomponents/DataSource.jsx

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

3-
const DataSource = ({ source, description, logo }) => {
3+
const DataSource = ({ source, contentProvider, description, logo }) => {
4+
const getDataSource = () => {
5+
if (!contentProvider) {
6+
return <strong>{source}</strong>;
7+
}
8+
9+
return (
10+
<>
11+
{contentProvider} (via {source})
12+
</>
13+
);
14+
};
15+
416
return (
517
// html template starts here
618
<>
719
<h3>Data source</h3>
820
<p>
9-
The data is taken from <strong>{source}</strong>. {description}
21+
The data is taken from {getDataSource()}. {description}
1022
</p>
1123
{!!logo && <p className="datasource-logo">{logo}</p>}
1224
</>

vis/js/templates/modals/infomodal/subcomponents/StandardKMInfo.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const StandardKMInfo = ({
88
serviceName,
99
serviceDesc,
1010
serviceLogo,
11-
params: { query, customTitle },
11+
params: { query, customTitle, repo_name },
1212
}) => {
1313
return (
1414
// html template starts here
@@ -72,6 +72,7 @@ const StandardKMInfo = ({
7272
{!!serviceName && (
7373
<DataSource
7474
source={serviceName}
75+
contentProvider={repo_name}
7576
description={serviceDesc}
7677
logo={serviceLogo}
7778
/>

vis/js/templates/modals/infomodal/subcomponents/StandardSGInfo.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const StandardSGInfo = ({
88
serviceName,
99
serviceDesc,
1010
serviceLogo,
11-
params: { query, customTitle },
11+
params: { query, customTitle, repo_name },
1212
}) => {
1313
return (
1414
// html template starts here
@@ -44,6 +44,7 @@ const StandardSGInfo = ({
4444
{!!serviceName && (
4545
<DataSource
4646
source={serviceName}
47+
contentProvider={repo_name}
4748
description={serviceDesc}
4849
logo={serviceLogo}
4950
/>

0 commit comments

Comments
 (0)