Skip to content

Commit bf52d18

Browse files
Merge pull request #742 from OpenKnowledgeMaps/themes-overviews
Themes overviews
2 parents abf1adf + 5c49cee commit bf52d18

7 files changed

Lines changed: 56 additions & 20 deletions

File tree

server/services/searchBASE.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
$precomputed_id = (isset($_POST["unique_id"]))?($_POST["unique_id"]):(null);
1212

1313
$params_array = array("from", "to", "document_types", "sorting", "min_descsize");
14-
$optional_get_params = ["repo", "coll", "vis_type", "q_advanced", "lang_id"];
14+
$optional_get_params = ["repo", "coll", "vis_type", "q_advanced", "lang_id", "custom_title"];
1515

1616
function filterEmptyString($value)
1717
{

server/workers/api/src/apis/request_validators.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class SearchParamSchema(Schema):
3232
repo_name = fields.Str()
3333
coll = fields.Str()
3434
list_size = fields.Int()
35+
custom_title = fields.Str()
3536

3637

3738
@pre_load

vis/js/components/Heading.js

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

4+
45
import {
56
BasicTitle,
67
ProjectTitle,
@@ -19,7 +20,7 @@ const Heading = ({
1920
headingParams,
2021
streamgraph,
2122
q_advanced,
22-
// customTitle,
23+
service,
2324
}) => {
2425
if (zoomed) {
2526
const label = streamgraph
@@ -41,13 +42,11 @@ const Heading = ({
4142

4243
let queryString = queryConcatenator([query, q_advanced])
4344

44-
// console.log("customTitle", headingParams.customTitle)
45-
4645
return (
4746
// html template starts here
4847
<div className="heading-container">
4948
<h4 className="heading">
50-
{renderTitle(localization, queryString, headingParams)}
49+
{renderTitle(localization, queryString, headingParams, service)}
5150
</h4>
5251
</div>
5352
// html template ends here
@@ -62,10 +61,11 @@ const mapStateToProps = (state) => ({
6261
headingParams: state.heading,
6362
streamgraph: state.chartType === STREAMGRAPH_MODE,
6463
q_advanced: state.q_advanced.text,
65-
// context: state,
66-
// customTitle: state.heading.customTitle,
64+
// get source BASE or PubMed
65+
service: state.contextLine.dataSource,
6766
});
6867

68+
6969
export default connect(mapStateToProps)(Heading);
7070

7171
// This should probably make its way to a more global config
@@ -75,7 +75,8 @@ const MAX_LENGTH_CUSTOM = 100;
7575
/**
7676
* Renders the title for the correct setup.
7777
*/
78-
const renderTitle = (localization, query, headingParams) => {
78+
const renderTitle = (localization, query, headingParams, service) => {
79+
7980
if (headingParams.presetTitle) {
8081
return <BasicTitle title={headingParams.presetTitle} />;
8182
}
@@ -104,10 +105,18 @@ const renderTitle = (localization, query, headingParams) => {
104105
);
105106
}
106107

108+
// this condition for BASE service and custom title if its value exists in config params
109+
if (service === "BASE") {
110+
if (headingParams.customTitle) {
111+
return <StandardTitle label={label} title={headingParams.customTitle}/>;
112+
}
113+
}
114+
107115
return <StandardTitle label={label} title={query} />;
108116
}
109117

110-
return <BasicTitle title={localization.default_title} />;
118+
119+
return <BasicTitle title={localization.default_title} />;
111120
};
112121

113122
const renderViperTitle = (title, acronym, projectId) => {

vis/js/reducers/heading.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ const context = (state = {}, action) => {
55

66
switch (action.type) {
77
case "INITIALIZE":
8-
// console.log("action", action)
9-
// console.log("params", action.contextObject.params)
10-
// console.log("custom_title", action.contextObject.params.custom_title)
118
return {
129
title: action.contextObject.params
1310
? action.contextObject.params.title
@@ -19,22 +16,22 @@ const context = (state = {}, action) => {
1916
? action.contextObject.params.project_id
2017
: undefined,
2118
presetTitle: action.configObject.title,
22-
titleStyle: getTitleStyle(action.configObject),
19+
// Todo: set titleStyle = "custom" if custom_title exists
20+
titleStyle: action.contextObject.params.custom_title ? 'custom' : getTitleStyle(action.configObject),
2321
titleLabelType: getTitleLabelType(action.configObject),
24-
customTitle: action.configObject.custom_title,
25-
// customTitle: action.contextObject.params.custom_title,
22+
customTitle: action.configObject.custom_title ? action.configObject.custom_title : action.contextObject.params.custom_title,
2623
};
2724
default:
2825
return state;
2926
}
3027
};
3128

3229
const getTitleStyle = (config) => {
30+
3331
if (config.create_title_from_context) {
3432
if (config.create_title_from_context_style) {
3533
return config.create_title_from_context_style;
3634
}
37-
3835
return "standard";
3936
}
4037

vis/js/templates/modals/CitationModal.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { formatString, removeEmbedParam } from "../../utils/string";
1111
import CopyButton from "../CopyButton";
1212
import useMatomo from "../../utils/useMatomo";
1313
import { queryConcatenator } from "../../utils/data";
14+
import {unescapeHTML} from "../../utils/unescapeHTMLentities.js";
1415

1516
const CitationModal = ({
1617
open,
@@ -20,6 +21,7 @@ const CitationModal = ({
2021
customTitle,
2122
timestamp,
2223
q_advanced,
24+
titleStyle,
2325
}) => {
2426
const loc = useLocalizationContext();
2527
const { trackEvent } = useMatomo();
@@ -37,7 +39,7 @@ const CitationModal = ({
3739
customQuery = customQuery.substr(0, 100) + "[..]";
3840
}
3941
if (customTitle) {
40-
customQuery = customTitle;
42+
customQuery = unescapeHTML(customTitle);
4143
}
4244

4345
const date = getDateFromTimestamp(timestamp);
@@ -88,9 +90,10 @@ const mapStateToProps = (state) => ({
8890
isStreamgraph: state.chartType === STREAMGRAPH_MODE,
8991
query: state.query.text,
9092
customTitle:
91-
state.heading.titleStyle === "custom" ? state.heading.customTitle : null,
93+
state.heading.titleStyle === "custom" ? state.heading.customTitle : null,
9294
timestamp: state.misc.timestamp,
9395
q_advanced: state.q_advanced.text,
96+
titleStyle: state.heading.titleStyle
9497
});
9598

9699
const mapDispatchToProps = (dispatch) => ({

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ import { Modal } from "react-bootstrap";
44
import AboutSoftware from "./AboutSoftware";
55
import DataSource from "./DataSource";
66
import { queryConcatenator } from "../../../../utils/data";
7+
import {unescapeHTML} from "../../../../utils/unescapeHTMLentities.js";
8+
9+
710

811
const StandardKMInfo = ({
912
serviceName,
1013
serviceDesc,
1114
serviceLogo,
12-
params: { query, customTitle, repo_name, q_advanced },
15+
params: {query, customTitle, repo_name, q_advanced},
1316
}) => {
1417
let queryString = queryConcatenator([query, q_advanced])
18+
19+
customTitle = unescapeHTML(customTitle)
20+
1521
return (
1622
// html template starts here
1723
<>
@@ -46,7 +52,7 @@ const StandardKMInfo = ({
4652
{!!customTitle && (
4753
<p>
4854
This map has a custom title and was created using the following
49-
query: <strong className="hs-strong">{query}</strong>
55+
query: <strong className="hs-strong">{queryString}</strong>
5056
</p>
5157
)}
5258
<p>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export const unescapeHTML = (string) => {
2+
let entityMap = {
3+
"&amp;": "&",
4+
"&lt;": "<",
5+
"&gt;": ">",
6+
"&quot;": '"',
7+
"&#34;": '"',
8+
"&#39;": "'",
9+
"&#x2F;": "/",
10+
"&#x60;": "`",
11+
"&#x3D;": "=",
12+
};
13+
14+
return String(string).replace(
15+
/(&amp;|&lt;|&gt;|&quot;|&#34;|&#39;|&#x2F;|&#x60;|&#x3D;)/g,
16+
function (s) {
17+
return entityMap[s];
18+
}
19+
);
20+
};

0 commit comments

Comments
 (0)