Skip to content

Commit 3347aaa

Browse files
committed
streamgraph snapshot bugfix
1 parent ba22b26 commit 3347aaa

5 files changed

Lines changed: 42 additions & 56 deletions

File tree

local_dev/config_local_headstart.ini

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ preprocessing_dir = "/var/www/html/dev/server/preprocessing/"
77
# Full path to the images directory for the client. Needs to be in the public_html/www directory. Make sure that your webserver has write access to this directory.
88
images_path = "/var/www/html/dev/server/paper_preview/"
99
# Host of the client visualization
10-
host = "localhost/"
10+
host = "dev-searchflow-1/"
1111
# Relative path to the client visualization. Needs to be in the public_html/www directory.
1212
vis_path = "headstart"
1313
# Relative path to the client REST services. Needs to be in the public_html/www directory.
@@ -20,19 +20,21 @@ api_flavor = "dev"
2020

2121
[snapshot]
2222
# Set to 1 to enable snapshot feature, 0 to disable
23-
snapshot_enabled = 0
23+
snapshot_enabled = 1
2424
# Absolute path to node binary
25-
node_path = "/path/to/node"
25+
node_path = "/usr/local/nvm/versions/node/v10.17.0/bin/node"
2626
# Absolute paths to node_modules folder, where puppeteer is installed
27-
nodemodules_path = "/path/to/node_modules"
27+
nodemodules_path = "/usr/local/nvm/versions/node/v10.17.0/lib/node_modules/"
2828
# Absolute path to getChartSVG.js
29-
getsvg_path = "/path/to/getChartSVG.js"
29+
getsvg_path = "/var/www/html/headstart/server/services/getChartSVG.js"
3030
# Absolute path to the directory, where the snapshots are stored. Webserver must have write access to this directory
31-
storage_path = "/path/to/storage/"
31+
storage_path = "/var/www/html/snapshots/"
3232
# PHP File responsible for rendering the bubble in a way to be snapshotted. Relative path to general host
33-
snapshot_php = "server/services/snapshot/headstart_snapshot.php"
33+
snapshot_php = "headstart/server/services/snapshot/headstart_snapshot.php"
3434
# snapshot_local_protocol fallback for non-server environments
3535
snapshot_local_protocol = "http://"
36+
# Size of thumbnail width
37+
snapshot_width = "1200px"
3638

3739
[connection]
3840
# PostgreSQL database

local_dev/searchflow-container/Dockerfile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@ MAINTAINER Chris Kittel "christopher.kittel@openknowledgemaps.org"
55
RUN a2enmod rewrite
66
RUN apt-get update && apt-get install -y curl libsqlite3-dev php7.4-sqlite libonig-dev libxml2-dev
77
RUN docker-php-ext-install pdo pdo_sqlite mbstring xml fileinfo
8+
# for puppeteer
9+
RUN apt-get install -y 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 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
10+
ENV NVM_DIR /usr/local/nvm
11+
ENV NODE_VERSION 10.17.0
12+
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.24.1/install.sh | bash \
13+
&& . $NVM_DIR/nvm.sh \
14+
&& nvm install $NODE_VERSION \
15+
&& nvm alias default $NODE_VERSION \
16+
&& nvm use default
817

9-
RUN sed -i 's#AllowOverride [Nn]one#AllowOverride All#' /etc/apache2/apache2.conf
10-
RUN mkdir /var/www/localstorage
11-
COPY test.sqlite /var/www/localstorage/local.sqlite
12-
RUN chown -R www-data:www-data /var/www/localstorage
18+
ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
19+
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
20+
ENV NPM_PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin/npm
21+
RUN $NPM_PATH install -g puppeteer@^2.0.0 --unsafe-perm=true --allow-root
22+
23+
RUN sed -i 's#AllowOverride [Nn]one#AllowOverride All#' /etc/apache2/apache2.conf

server/classes/headstart/preprocessing/Snapshot.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,9 @@ public function __construct($ini_array, $query, $id, $service, $service_name, $v
1010
"query" => $query,
1111
"file" => $id,
1212
"service_name" => $service_name,
13-
"service" => $service
13+
"service" => $service,
14+
"vis_type" => $vis_type
1415
);
15-
if ($service_name == "LinkedCat") {
16-
$post_data["vis_type"] = $vis_type;
17-
$post_data["service_name"] = "linkedcat";
18-
}
19-
if ($service == "linkedcat_authorview") {
20-
$post_data["vis_mode"] = "authors";
21-
$post_data["service"] = "linkedcat";
22-
$post_data["service_name"] = "linkedcat";
23-
}
24-
if ($service == "linkedcat_browseview") {
25-
$post_data["vis_mode"] = "browse";
26-
$post_data["service"] = "linkedcat";
27-
$post_data["service_name"] = "linkedcat";
28-
}
2916
$url_postfix = http_build_query($post_data);
3017

3118
$node_path = $ini_array["snapshot"]["node_path"];
@@ -44,14 +31,20 @@ public function __construct($ini_array, $query, $id, $service, $service_name, $v
4431

4532
$url = "{$host}{$snap_php}?{$url_postfix}";
4633
$this->cmd = "{$node_path} {$getsvg} \"{$url}\" {$storage}{$post_data['file']}.png {$nodemodules}";
34+
// Use 2>&1 to redirect both standard output and standard error to the same file
35+
$this->cmd .= ' 2>&1';
36+
error_log("Snapshot command");
37+
error_log($this->cmd);
4738
}
4839

4940
public function takeSnapshot() {
5041
if (substr(php_uname(), 0, 7) == "Windows"){
5142
pclose(popen("start /B ". $this->cmd, "r"));
5243
}
5344
else {
54-
exec($this->cmd . " &");
45+
$output = shell_exec($this->cmd . " &");
46+
error_log("Snapshot output");
47+
error_log($output);
5548
}
5649
}
5750
}

server/services/getChartSVG.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function timeout(ms) {
1010
const page = await browser.newPage();
1111
await page.setViewport({width: 1920, height: 1080})
1212
await page.goto(process.argv[2], {waitUntil: 'networkidle2'});
13-
await timeout(2000)
13+
await timeout(3000)
1414
await page.screenshot({path: process.argv[3], clip: { x: 0, y: 0, width: 1150, height: 1080 }});
1515
browser.close();
1616

server/services/snapshot/headstart_snapshot.php

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,15 @@
1818
data_config.server_url = window.location.href.replace(/[^/]*$/, '') + "../../";
1919
data_config.show_context = true;
2020
data_config.create_title_from_context= true;
21-
data_config.options = options_<?php echo htmlspecialchars($_GET['service']); ?>.dropdowns;
22-
if (<?php echo json_encode($_GET['service']) ?> === "linkedcat" ||
23-
<?php echo json_encode($_GET['service']) ?> === "linkedcat_authorview" ||
24-
<?php echo json_encode($_GET['service']) ?> === "linkedcat_browseview") {
25-
if(<?php echo json_encode(isset($_GET['vis_mode']) ? $_GET['vis_mode'] : "") ?> === "authors") {
26-
data_config.is_authorview = true;
27-
}
28-
if(<?php echo json_encode(isset($_GET['vis_type']) ? $_GET['vis_type'] : "") ?> === "timeline") {
29-
data_config.is_streamgraph = true;
30-
//data_config.embed_modal = false;
31-
data_config.show_area = false;
32-
33-
if(<?php echo json_encode(isset($_GET['vis_mode']) ? $_GET['vis_mode'] : "") ?> === "authors") {
34-
data_config.intro = "";
35-
} else {
36-
data_config.intro = "";
37-
}
38-
} else {
39-
if (<?php echo json_encode(isset($_GET['vis_type']) ? $_GET['vis_type'] : "") ?> === "overview") {
40-
if(<?php echo json_encode(isset($_GET['vis_mode']) ? $_GET['vis_mode'] : "") ?> === "authors") {
41-
data_config.intro = "";
42-
} else if (<?php echo json_encode(isset($_GET['vis_mode']) ? $_GET['vis_mode'] : "") ?> === "browse") {
43-
data_config.intro = "";
44-
} else {
45-
data_config.intro = "";
46-
}
47-
}
48-
}
21+
data_config.intro = "";
22+
if(<?php echo json_encode(isset($_GET['vis_type']) ? $_GET['vis_type'] : "") ?> === "timeline") {
23+
data_config.is_streamgraph = true;
24+
//data_config.embed_modal = false;
25+
data_config.show_area = false;
26+
} else {
27+
data_config.options = options_<?php echo htmlspecialchars($_GET['service']); ?>.dropdowns;
4928
}
29+
console.log(data_config);
5030
</script>
5131
<script type="text/javascript" src="../../../dist/headstart.js"></script>
5232
<link type="text/css" rel="stylesheet" href="../../../dist/headstart.css"></link>

0 commit comments

Comments
 (0)