Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4a92762
refactor: remove the "Find out more" link
andreishket Jun 4, 2025
3ef9311
refactor: remove the "Find out more" link localization
andreishket Jun 4, 2025
2c3c8d0
refactor: upgrade PHP version in the dockerfile
andreishket Jun 6, 2025
ad686ba
regactor: update the APIClient
andreishket Jun 6, 2025
aebfcd2
refactor: additional check before utf8_encode
andreishket Jun 6, 2025
5f69603
fix: deprecation warning during a pdf openning
andreishket Jun 6, 2025
d5fee19
refactor: remove deprecated utf8_encode
andreishket Jun 6, 2025
6910bac
Merge pull request #805 from OpenKnowledgeMaps/refactor/remove-find-o…
andreishket Jun 20, 2025
ad4929e
Merge pull request #807 from OpenKnowledgeMaps/refactor/upgrade-php-t…
andreishket Jun 20, 2025
d9c8533
disabled superfluous debug logging
chreman Jun 25, 2025
25242e5
Merge pull request #809 from OpenKnowledgeMaps/logging-cleanup
chreman Jun 25, 2025
647db57
Merge pull request #808 from OpenKnowledgeMaps/dev
chreman Jun 27, 2025
88107ae
disabled superfluous debug logging
chreman Jun 27, 2025
1281895
Merge pull request #810 from OpenKnowledgeMaps/logging-cleanup
chreman Jun 27, 2025
28b4569
Merge pull request #811 from OpenKnowledgeMaps/dev
chreman Jun 27, 2025
7410099
refactor: formatting commit
andreishket Jul 1, 2025
51541db
refactor: checkBrowserVersion as private method
andreishket Jul 1, 2025
143ea68
refactor: supported browsers in the separate list
andreishket Jul 1, 2025
a612855
refactor: new supported browsers and warning message
andreishket Jul 1, 2025
c548f08
refactor: more clear function name
andreishket Jul 1, 2025
a11eefe
fix: Edge browser name
andreishket Jul 1, 2025
685691b
refactor: warning message
andreishket Jul 7, 2025
3ad9654
feat: recomendations in the warning message
andreishket Jul 10, 2025
1a40c82
Merge pull request #812 from OpenKnowledgeMaps/feat/edge-and-opera-in…
andreishket Jul 10, 2025
dedbfa4
Merge pull request #813 from OpenKnowledgeMaps/dev
chreman Jul 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions local_dev/searchflow-container/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM php:8.0-apache
FROM php:8.2-apache

LABEL maintainer="Chris Kittel <christopher.kittel@openknowledgemaps.org>"

RUN a2enmod rewrite

RUN apt-get update && apt-get install -y \
curl libsqlite3-dev php7.4-sqlite libonig-dev libxml2-dev \
curl libsqlite3-dev libonig-dev libxml2-dev \
gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 \
libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 \
libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 \
Expand Down
31 changes: 17 additions & 14 deletions server/classes/headstart/library/APIClient.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
<?php

namespace headstart\library;

use Exception;

require_once dirname(__FILE__) . '/CommUtils.php';

class APIClient {
private array $ini_array;
private string $database;
private string $base_route;
private array $settings;

public function __construct($ini_array) {

$this->load_configs($ini_array);
}

public function load_configs($ini_array) {
public function load_configs(array $ini_array): void {
$this->ini_array = $ini_array;
$this->settings = $this->ini_array["general"];
$this->database = $this->ini_array["connection"]["database"];
Expand All @@ -21,46 +27,44 @@ public function load_configs($ini_array) {

public function call_api($endpoint, $payload) {
$route = $this->base_route . $endpoint;

try {
$res = CommUtils::call_api($route, $payload);

if ($res["httpcode"] != 200) {
$res["route"] = $route;
$res = $this->handle_api_errors($res);
}

return $res;
}
catch (Exception $e) {
error_log("Error in APIClient: " . $e);
$res = array("status"=>"error",
"httpcode"=>500,
"reason"=>array("unexpected data processing error"));
$res = array("status"=>"error", "httpcode"=>500, "reason"=>array("unexpected data processing error"));
return $res;
}
finally {
}
}

public function call_persistence($endpoint, $payload) {
$route = $this->base_route . "persistence/" . $endpoint . "/" . $this->database;

try {
$res = CommUtils::call_api($route, $payload);

if ($res["httpcode"] != 200) {
$res["route"] = $route;
$res = $this->handle_api_errors($res);
}

return $res;
}
catch (Exception $e) {
// what happens here is instead of bubbling the error up,
// it is caught and we fake a response that looks like an error
// fake a response that looks like an error
// because of the hardcoded reason we loose the original error information
$res = array("status"=>"error",
"httpcode"=>500,
"reason"=>array("unexpected data processing error"));
$res = array("status"=>"error", "httpcode"=>500, "reason"=>array("unexpected data processing error"));
return $res;
}
finally {
}
}

public function handle_api_errors($res) {
Expand All @@ -85,5 +89,4 @@ public function handle_api_errors($res) {
error_log(("Trying to handle API errors: " . print_r($res, true)));
return $res;
}

}
2 changes: 1 addition & 1 deletion server/services/getPDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function extractValidPdfUrls(array $revision_data, string $paper_id, string $vis

$inner_data = json_decode($revision_data["data"], true);
$documents_raw = $inner_data["documents"] ?? null;
$documents = json_decode($documents_raw, true);
$documents = $documents_raw !== null ? json_decode($documents_raw, true) : null;

if (strtolower($vis_type) == 'timeline') {
$inner_data = json_decode($inner_data["data"]);
Expand Down
28 changes: 26 additions & 2 deletions server/services/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,35 @@ function packParamsJSON($params_array, $post_params)
return json_encode($output_array);
}

function encode_string(string $str, string $to_encoding = 'UTF-8'): string {
// Defining constants with known encodings and default one
$DEFAULT_ENCODING = 'ISO-8859-1';
$ENCODINGS = [
'UTF-8',
'Windows-1251',
'ISO-8859-1',
'ASCII',
'KOI8-R',
'CP866'
];

// Trying to define the received string encoding
$str_encoding = mb_detect_encoding($str, $ENCODINGS, true);

// If the received string encoding is unknown the default one will be used
if ($str_encoding === false) {
$str_encoding = $DEFAULT_ENCODING;
}

// Converting encoding and returning updated string back
return mb_convert_encoding($str, $to_encoding, $str_encoding);
}

function utf8_converter($array)
{
array_walk_recursive($array, function (&$item, $key) {
if (!mb_detect_encoding($item, 'utf-8', true)) {
$item = utf8_encode($item);
if ($item !== null && !mb_detect_encoding($item, 'utf-8', true)) {
$item = encode_string($item);
}
});

Expand Down
39 changes: 27 additions & 12 deletions vis/js/HeadstartRunner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class HeadstartRunner {
}

async run() {
this.checkBrowserVersion();
this.checkIsSupportedBrowser();
this.renderReact();
this.addBackButtonListener();
this.backendData = await this.fetchData();
Expand All @@ -65,16 +65,29 @@ class HeadstartRunner {
this.addWindowResizeListener();
}

checkBrowserVersion() {
private checkIsSupportedBrowser() {
const SUPPORTED = [
"Chrome",
"Firefox",
"Safari",
"Microsoft Edge",
"Opera",
] as const;

const browser = Bowser.getParser(window.navigator.userAgent);
// TODO use proper browser filtering https://www.npmjs.com/package/bowser#filtering-browsers
if (
!["chrome", "firefox", "safari"].includes(browser.getBrowserName(true))
) {
const browserName = browser.getBrowserName(true);

const isSupportedBrowser = SUPPORTED.map((browserName) =>
browserName.toLowerCase()
).includes(browserName);

if (!isSupportedBrowser || !browserName) {
alert(
"You are using an unsupported browser. " +
"This visualization was successfully tested " +
"with the latest versions of Chrome, Firefox and Safari."
"with the latest versions of " +
"Chrome, Firefox, Safari, Edge and Opera. " +
"We strongly recommend using one of these browsers."
);
}
}
Expand Down Expand Up @@ -160,10 +173,7 @@ class HeadstartRunner {
addWindowResizeListener() {
window.addEventListener("resize", () => {
const chart = getChartSize(this.config);
const list = getListSize(
this.config,
chart.size
);
const list = getListSize(this.config, chart.size);
this.store.dispatch(updateDimensions(chart, list));
});
}
Expand Down Expand Up @@ -195,7 +205,12 @@ class HeadstartRunner {
elem?.dispatchEvent(event);
}

rescaleMap(scaleBy: string, baseUnit: string, isContentBased: boolean, initialSort: string) {
rescaleMap(
scaleBy: string,
baseUnit: string,
isContentBased: boolean,
initialSort: string
) {
this.config.scale_by = scaleBy;
this.config.base_unit = baseUnit;
this.config.content_based = isContentBased;
Expand Down
6 changes: 1 addition & 5 deletions vis/js/components/Toolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-nocheck

import React from "react";
import { connect } from "react-redux";
import ScaleToolbar from "../templates/ScaleToolbar";
Expand All @@ -14,8 +13,7 @@ const Toolbar = ({
scaleBaseUnit,
scaleValue,
showCredit,
onInfoClick,
onScaleChange
onScaleChange,
}) => {
if (showScaleToolbar) {
const handleScaleChange = (newScaleBy: string) => {
Expand All @@ -34,7 +32,6 @@ const Toolbar = ({
explanations={scaleExplanations}
value={scaleValue}
showCredit={showCredit}
onInfoClick={onInfoClick}
onChange={handleScaleChange}
/>
</div>
Expand All @@ -55,7 +52,6 @@ const mapStateToProps = (state) => ({
});

const mapDispatchToProps = (dispatch) => ({
onInfoClick: () => dispatch(openInfoModal()),
onScaleChange: (value, baseUnit, contentBased, sort) =>
dispatch(scaleMap(value, baseUnit, contentBased, sort)),
});
Expand Down
5 changes: 0 additions & 5 deletions vis/js/i18n/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export interface Localization {
citations: string;
social: string;
references: string;
scale_by_infolink_label: string;
metrics_label: string;
researcher_details_label: string;
scale_by_explanation: string;
Expand Down Expand Up @@ -398,7 +397,6 @@ export const localization: {
citations: "citations",
social: "social media mentions",
references: "references outside academia",
scale_by_infolink_label: "Find out more",
metrics_label: "Metrics",
researcher_details_label: "Researcher details",
scale_by_explanation:
Expand Down Expand Up @@ -456,7 +454,6 @@ export const localization: {
citations: "citations",
social: "social media mentions",
references: "references outside academia",
scale_by_infolink_label: "Find out more",
metrics_label: "Metrics",
researcher_details_label: "Researcher details",
scale_by_explanation:
Expand Down Expand Up @@ -500,10 +497,8 @@ export const localization: {
publication: "papers",
dataset: "datasets",
items: "items",
scale_by_infolink_label: "notes on use of metrics",
// citations_count_label: "citations",
social_media_count_label: " social media mentions",
references_count_label: "references outside academia",
// scale_by_infolink_label: 'Find out more'
},
};
52 changes: 24 additions & 28 deletions vis/js/templates/ScaleToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const ScaleToolbar = ({
explanations,
showCredit,
onChange,
onInfoClick,
}) => {
const localization = useLocalizationContext();
const { trackEvent } = useMatomo();
Expand All @@ -22,12 +21,6 @@ const ScaleToolbar = ({
trackEvent("Added components", "Rescale map", labels[id]);
};

const handleInfoClick = (event) => {
event.preventDefault();
onInfoClick();
trackEvent("Added components", "Open more info modal", "Toolbar");
};

return (
<div className="scale-toolbar btn-group dropup">
<div className="dropdown">
Expand All @@ -36,20 +29,31 @@ const ScaleToolbar = ({
noCaret
title={
<>
<span style={{
maxWidth: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center'
}}>
<span
style={{
maxWidth: "100%",
display: "flex",
justifyContent: "center",
alignItems: "center",
}}
>
<span>{localization.scale_by_label}</span>
<span id="curr-filter-type" className="truncate-text" style={{
minWidth: '0px',
marginLeft: "3px"
}}>{labels[value]}</span>
<i className="fas fa-chevron-down chevron" style={{
marginLeft: "3px",
}}/>
<span
id="curr-filter-type"
className="truncate-text"
style={{
minWidth: "0px",
marginLeft: "3px",
}}
>
{labels[value]}
</span>
<i
className="fas fa-chevron-down chevron"
style={{
marginLeft: "3px",
}}
/>
</span>
</>
}
Expand All @@ -69,14 +73,6 @@ const ScaleToolbar = ({
</div>
<div className="context-scale-toolbar">
<span id="curr-scale-explanation">{explanations[value]}</span>
<a
id="infolink"
className="scale-infolink"
onClick={handleInfoClick}
href="#"
>
{localization.scale_by_infolink_label}
</a>
</div>
{showCredit && (
<div id="credit">
Expand Down
2 changes: 1 addition & 1 deletion vis/js/templates/modals/CitationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const CitationModal = ({
);
};

const mapStateToProps = (state) => (console.log('state here', state),{
const mapStateToProps = (state) => ({
open: state.modals.openCitationModal,
isStreamgraph: state.chartType === STREAMGRAPH_MODE,
query: state.query.text,
Expand Down
2 changes: 1 addition & 1 deletion vis/js/templates/modals/ResearcherInfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const getResearcherInfoTemplate = (service, isStreamgraph, modalType) => {
case "orcid":
return ResearcherInfo;
default:
console.log(`${service} is not a valid service for the ResearcherInfoModal`);
// console.log(`${service} is not a valid service for the ResearcherInfoModal`);
return null;
}
};
Expand Down
2 changes: 1 addition & 1 deletion vis/js/templates/modals/ResearcherMetricsInfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const getResearcherInfoTemplate = (service: string, isStreamgraph: boolean, moda
case "orcid":
return ResearcherMetricsInfo;
default:
console.log(`${service} is not a valid service for the ResearcherInfoModal`);
// console.log(`${service} is not a valid service for the ResearcherInfoModal`);
return null;
}
};
Expand Down