Skip to content

Commit 677fd03

Browse files
authored
Merge pull request #853 from OpenKnowledgeMaps/snapshot-bugfixes
Snapshot bugfixes
2 parents 6fe93fc + 383780e commit 677fd03

10 files changed

Lines changed: 56 additions & 5 deletions

File tree

server/classes/headstart/preprocessing/Snapshot.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ public function __construct($ini_array, $query, $id, $service, $service_name, $v
2828
$snap_php = $ini_array["snapshot"]["snapshot_php"];
2929
$storage = $ini_array["snapshot"]["storage_path"];
3030
$nodemodules = $ini_array["snapshot"]["nodemodules_path"];
31+
$chrome_executable_path = $ini_array["snapshot"]["chrome_executable_path"];
3132

3233
$url = "{$host}{$snap_php}?{$url_postfix}";
33-
$this->cmd = "{$node_path} {$getsvg} \"{$url}\" {$storage}{$post_data['file']}.png {$nodemodules}";
34+
$this->cmd = "{$node_path} {$getsvg} \"{$url}\" {$storage}{$post_data['file']}.png {$nodemodules} {$chrome_executable_path}";
3435
}
3536

3637
public function takeSnapshot() {

server/preprocessing/conf/config.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ storage_path = "/path/to/storage/"
3232
snapshot_php = "server/services/snapshot/headstart_snapshot.php"
3333
# snapshot_local_protocol fallback for non-server environments
3434
snapshot_local_protocol = "http://"
35+
# chrome executable path (optional, only needed if puppeteer cannot find chrome automatically)
36+
chrome_executable_path = "/path/to/chrome"
3537

3638

3739
[connection]

server/services/getChartSVG.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ function timeout(ms) {
77

88
(async() => {
99
try {
10-
const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] });
10+
const browser = await puppeteer.launch({
11+
headless: true,
12+
args: ['--no-sandbox', '--disable-setuid-sandbox'],
13+
executablePath: process.argv[5]
14+
});
1115
await timeout(1000)
1216
const page = await browser.newPage();
1317
await timeout(1000)

server/services/search.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ function search(
221221
} else {
222222
$vis_type = "overview";
223223
}
224+
if (isset($post_params["vis_type"]) && $post_params["vis_type"] == "geomap") {
225+
$vis_type = "geomap";
226+
}
224227
$snapshot = new \headstart\preprocessing\Snapshot($ini_array, $query, $unique_id, $service, $repo2snapshot[$service], $vis_type);
225228
$snapshot->takeSnapshot();
226229
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var data_config = {
2+
tag: "visualization",
3+
mode: "search_repos",
4+
5+
service: "base",
6+
7+
title: "",
8+
base_unit: "citations",
9+
use_area_uri: true,
10+
show_multiples: false,
11+
show_dropdown: false,
12+
preview_type: "pdf",
13+
sort_options: ["relevance", "title", "authors", "year"],
14+
is_force_areas: true,
15+
language: "eng_pubmed",
16+
area_force_alpha: 0.015,
17+
show_list: true,
18+
content_based: true,
19+
url_prefix: "https://www.base-search.net/Record/",
20+
21+
show_context: true,
22+
create_title_from_context: true,
23+
context_most_relevant_tooltip: true,
24+
25+
doi_outlink: true,
26+
filter_menu_dropdown: true,
27+
sort_menu_dropdown: true,
28+
filter_options: ["all", "open_access"],
29+
//show number of open access documents in context
30+
show_context_oa_number: false,
31+
32+
visualization_type: "geomap", // Used in the reducer named "chartType" to determine the visualization type: overview, timeline, geomap
33+
};

server/services/snapshot/data-config_base.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ var data_config = {
2828
filter_options: ["all", "open_access"],
2929
//show number of open access documents in context
3030
show_context_oa_number: false,
31+
32+
visualization_type: "overview", // Used in the reducer named "chartType" to determine the visualization type: overview, timeline, geomap
3133
};

server/services/snapshot/data-config_openaire.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ var data_config = {
6464
cited_by_tweeters_count: 'tweets',
6565
'readers.mendeley': 'readers'
6666
},
67-
67+
visualization_type: "overview", // Used in the reducer named "chartType" to determine the visualization type: overview, timeline, geomap
6868
};

server/services/snapshot/data-config_orcid.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ var data_config = {
2828
filter_options: ["all", "open_access"],
2929
//show number of open access documents in context
3030
show_context_oa_number: false,
31+
visualization_type: "overview", // Used in the reducer named "chartType" to determine the visualization type: overview, timeline, geomap
3132
};

server/services/snapshot/data-config_pubmed.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ var data_config = {
3434
filter_menu_dropdown: true,
3535
sort_menu_dropdown: true,
3636
filter_options: ["all", "open_access"],
37+
visualization_type: "overview", // Used in the reducer named "chartType" to determine the visualization type: overview, timeline, geomap
3738
};

server/services/snapshot/headstart_snapshot.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<script type="text/javascript" src="data-config_<?php echo htmlspecialchars($_GET['service']) ?>.js"></script>
1212
<script src="../../../../js/search_options.js"></script>
1313
<script>
14+
vis_type = <?php echo json_encode(isset($_GET['vis_type']) ? $_GET['vis_type'] : "overview") ?>;
1415
data_config.files = [{
1516
title: <?php echo json_encode($_GET['query']) ?>,
1617
file: <?php echo json_encode($_GET['file']) ?>
@@ -19,13 +20,16 @@
1920
data_config.show_context = true;
2021
data_config.create_title_from_context= true;
2122
data_config.intro = "";
22-
if(<?php echo json_encode(isset($_GET['vis_type']) ? $_GET['vis_type'] : "") ?> === "timeline") {
23-
data_config.is_streamgraph = true;
23+
if (vis_type === "timeline") {
24+
data_config.visualization_type = "timeline";
2425
//data_config.embed_modal = false;
2526
data_config.show_area = false;
2627
} else {
2728
data_config.options = options_<?php echo htmlspecialchars($_GET['service']); ?>.dropdowns;
2829
}
30+
if (vis_type === "geomap") {
31+
data_config.visualization_type = "geomap";
32+
}
2933
</script>
3034

3135
<?php include "../../../dist/headstart.php"; ?>

0 commit comments

Comments
 (0)