Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
d1d20a2
wip
chreman May 5, 2020
f2af18f
Merge branch 'master' into postgresql-container
chreman Sep 29, 2020
abc95c7
persistence wip
chreman Sep 29, 2020
aa3e488
new map id route for persistence API
chreman Sep 29, 2020
2e8283c
map id route test
chreman Sep 29, 2020
c56afa7
wip
chreman Oct 1, 2020
63004db
Merge remote-tracking branch 'upstream/master' into postgresql-container
chreman Oct 1, 2020
73c64d4
map exists route
chreman Oct 2, 2020
3bc7901
write revision route
chreman Oct 2, 2020
f0709a9
create visualization route
chreman Oct 2, 2020
55568d4
persistence error handling
chreman Oct 2, 2020
a147ade
search re-routing
chreman Oct 2, 2020
107d507
separate persistence backend flag
chreman Oct 2, 2020
1a748d1
model updates
chreman Oct 3, 2020
a08d052
services integration
chreman Oct 6, 2020
baf36b1
new commUtil function
chreman Oct 6, 2020
ea834e2
getLatestRevision route
chreman Oct 6, 2020
2d4b890
updated params in data integrations
chreman Oct 6, 2020
073ed91
parameter naming convention
chreman Oct 6, 2020
54d2c85
search api fix
chreman Oct 6, 2020
b145aa3
wip
chreman Oct 8, 2020
2c95477
gsheets update
chreman Oct 8, 2020
309828f
Merge remote-tracking branch 'upstream/master' into postgresql-container
chreman Oct 8, 2020
c9565a2
added VIPER datatypes (unused for now)
chreman Oct 13, 2020
5147d79
coding format
chreman Oct 13, 2020
ad279b2
fix API routing
chreman Oct 13, 2020
4764193
more logging
chreman Oct 14, 2020
1d83d2a
new exists check bugfix
chreman Oct 15, 2020
7cca4fe
persistence test updates
chreman Oct 15, 2020
f88fb63
docs update
chreman Oct 15, 2020
1538b8f
Merge remote-tracking branch 'upstream/master' into postgresql-container
chreman Oct 20, 2020
7163833
attempt correct escaping in query strings
chreman Oct 22, 2020
2667f72
First version of the GSheets example
pkraker Oct 22, 2020
6476180
merge upstream/master
chreman Oct 27, 2020
a6ff30c
activate new persistence route for GSHeets update functionality
chreman Oct 27, 2020
2bdcc48
less logging clutter
chreman Oct 27, 2020
6395bb1
less logging clutter
chreman Oct 27, 2020
4e52447
change default param
chreman Oct 28, 2020
5ab4cb2
fix sha for bootstrap for dropdowns
chreman Oct 28, 2020
8d27a11
first working draft of new endpoint
chreman Nov 1, 2020
6a556e2
Merge branch 'postgresql-container' into covis-automization
chreman Nov 1, 2020
9bed439
php backend local call
chreman Nov 1, 2020
d86c067
robustify validation
chreman Nov 5, 2020
748ddbd
additional context data added
chreman Nov 5, 2020
0bd0cae
additional context fields and backwards compatibility
chreman Nov 5, 2020
e8e548e
Merge remote-tracking branch 'upstream/master' into covis-automization
chreman Nov 5, 2020
23c7a36
integration of extension
chreman Nov 5, 2020
c435373
default params
chreman Nov 5, 2020
c06aca9
Merge remote-tracking branch 'upstream/master' into postgresql-container
chreman Nov 5, 2020
2c9c7a4
default params
chreman Nov 5, 2020
8581357
cleanup
chreman Nov 5, 2020
2e7b8dd
Merge branch 'postgresql-container' into covis-automization
chreman Nov 5, 2020
eab0341
param names
chreman Nov 5, 2020
d001a7c
prefill new knowledge base additional context
chreman Nov 7, 2020
916a0c3
Merge remote-tracking branch 'remotes/origin/covis-automization' into…
pkraker Nov 9, 2020
3e46887
WIP: Add context from map json to index.php
pkraker Nov 9, 2020
7457277
Merge branch 'gsheets-example' into covis-automization
chreman Nov 9, 2020
b2fc155
param naming convention
chreman Nov 9, 2020
1e07ae8
Merge remote-tracking branch 'upstream/master' into postgresql-container
chreman Nov 10, 2020
288aace
fix persistence tests
chreman Nov 10, 2020
063beb2
triple ID testcases
chreman Nov 10, 2020
586e870
example postgresconf added with more restrictive listen
chreman Nov 10, 2020
de0fc7c
revert
chreman Nov 10, 2020
64d7a46
Merge pull request #504 from OpenKnowledgeMaps/covis-automization
chreman Nov 11, 2020
00d7ca9
snapshot wip
chreman Nov 11, 2020
6107db7
Avoids preventing the updateGSheetsMap call when context cannot be re…
pkraker Nov 11, 2020
d895091
postgres security via pg_hba.conf
chreman Nov 11, 2020
7faf237
Merge branch 'postgresql-container' into covis-automization
chreman Nov 11, 2020
220ba7b
Merge remote-tracking branch 'upstream/gsheets-example' into covis-au…
chreman Nov 11, 2020
eadf4da
added getContext api route
chreman Nov 12, 2020
58ffeda
Merge remote-tracking branch 'upstream/master' into gsheets-example
chreman Nov 12, 2020
ec7029a
multiple db wip
chreman Nov 12, 2020
014fc23
add parameter to example
chreman Nov 12, 2020
c7cb699
getContext api route
chreman Nov 12, 2020
a33be0f
Merge pull request #506 from OpenKnowledgeMaps/covis-automization
chreman Nov 12, 2020
5316487
Improved error handling for gsheets example
pkraker Nov 13, 2020
4a7f30d
gsheets api default values
chreman Nov 15, 2020
d9cdfbf
Merge pull request #507 from OpenKnowledgeMaps/covis-automization
chreman Nov 16, 2020
7896872
Update README.md
chreman Nov 17, 2020
40f4811
Merge remote-tracking branch 'upstream/postgresql-container' into pos…
chreman Nov 17, 2020
edcce11
multiple databases wip
chreman Nov 17, 2020
773c113
new way to choose db sessions
chreman Nov 18, 2020
c7fc9e4
Merge remote-tracking branch 'upstream/master' into postgresql-container
chreman Nov 20, 2020
f9ee2d8
Merge branch 'postgresql-container' into covis-automization
chreman Nov 20, 2020
3ff2368
Merge remote-tracking branch 'upstream/gsheets-example' into gsheets-…
chreman Nov 20, 2020
7f59d95
Merge branch 'gsheets-example' into covis-automization
chreman Nov 20, 2020
3970e5c
add database paths to service api calls
chreman Nov 23, 2020
a71d852
Merge branch 'covis-automization' into postgresql-container
chreman Nov 23, 2020
f70ad41
add database paths to service api calls
chreman Nov 23, 2020
7a76d61
cleanup
chreman Nov 23, 2020
598085c
update manage.py
chreman Nov 23, 2020
431c6ef
logging
chreman Nov 23, 2020
d71a7c7
integration cleanup
chreman Nov 23, 2020
a466c12
integration cleanup
chreman Nov 23, 2020
ae5415c
add title and activate snapshots
chreman Nov 30, 2020
6ab9788
bugfix
chreman Dec 1, 2020
9d6386e
additional rights
chreman Dec 1, 2020
210600e
config cleanup
chreman Dec 2, 2020
276803a
Merge remote-tracking branch 'upstream/master' into postgresql-container
chreman Dec 2, 2020
ce80641
cleanup
chreman Dec 2, 2020
15aa916
Merge remote-tracking branch 'upstream/postgresql-container' into pos…
chreman Dec 2, 2020
6bc7b51
Merge branch 'covis-automization' into postgresql-container
chreman Dec 2, 2020
f11c83c
automatic map title in gsheets-example
chreman Dec 2, 2020
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
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@ version: '3.7'

services:

pgsql:
image: 'postgres:12.2-alpine'
restart: always
environment:
POSTGRES_USER: "${POSTGRES_USER}"
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
volumes:
- db-data:/var/lib/postgresql/data
- ./server/workers/pg_hba.conf:/var/lib/postgresql/data/pg_hba.conf
ports:
- '127.0.0.1:5432:5432'

pgadmin:
image: 'dpage/pgadmin4'
ports:
- '127.0.0.1:54323:80'
env_file:
- .env

api:
build:
context: server
Expand Down Expand Up @@ -107,3 +126,5 @@ services:

volumes:
redis:
db-data:
driver: local
6 changes: 6 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
POSTGRES_DB=postgres
POSTGRES_USER=headstart
POSTGRES_PASSWORD=password
PGADMIN_DEFAULT_EMAIL=email@domain.org
PGADMIN_DEFAULT_PASSWORD=password
PGADMIN_VOLUME=/path/to/pgadminworkingdir
11 changes: 11 additions & 0 deletions examples/gsheets/config.example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
$SITE_URL = "//localhost/covis/";
$HEADSTART_PATH = "../../";
$SHEET_ID = "";
$DEBUG = false;
$PIWIK_ENABLED = false;
$GA_ENABLED = false;
$GA_CODE = "XX-00000000-0";
$COOKIE_DOMAIN = "";
$PERSISTENCE_BACKEND = "api";
?>
56 changes: 56 additions & 0 deletions examples/gsheets/data-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
var data_config = {
tag: "visualization",
mode: "gsheets",
persistence_backend: "api",

bubble_min_scale: 1.1,
bubble_max_scale: 1.1,

paper_min_scale: 1,

input_format: "json",
use_area_uri: true,
preview_type: "pdf",
use_hypothesis: true,

show_multiples: false,
show_dropdown: false,
show_intro: false,
show_list:true,
is_force_papers: true,
is_title_clickable: false,
show_infolink: true,
show_infolink_areas: false,

show_context: true,
create_title_from_context: true,
show_context_timestamp: true,
show_loading_screen: true,

scale_toolbar: false,

content_based: true,
is_evaluation: true,
evaluation_service: ["matomo"],

is_force_areas: true,
area_force_alpha: 0.03,
papers_force_alpha: 0.2,

language: "eng_gsheets",

sort_options: ["year", "title", "area"],
filter_options: ["all", "open_access"],

show_keywords: true,
hide_keywords_overview: false,
show_tags: true,
show_comments: true,
show_resulttype: true,

sort_menu_dropdown: true,
filter_menu_dropdown: true,

embed_modal: true,
share_modal: false
};
231 changes: 231 additions & 0 deletions examples/gsheets/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
<!DOCTYPE html>
<?php
include 'config.php';

function curl_get_contents($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}

function checkReturn($object, $field, $default = "") {
if(isset($object[$field])) {
return $object[$field];
} else {
return $default;
}
}

function addScheme($url, $scheme = 'http://') {
return parse_url($url, PHP_URL_SCHEME) === null ?
$scheme . $url : $url;
}

$protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https:' : 'http:';
$headstart_url = $protocol . $SITE_URL . $HEADSTART_PATH;
$context_json = curl_get_contents($headstart_url . "server/services/getContext.php?vis_id=$SHEET_ID&persistence_backend=$PERSISTENCE_BACKEND&revision_context=true");
$context = json_decode($context_json, true);

$topic = checkReturn($context, "topic");
$main_curator_name = checkReturn($context, "main_curator_name");
$main_curator_email = checkReturn($context, "main_curator_email");
$project_name = checkReturn($context, "project_name");
$project_website_raw = checkReturn($context, "project_website", null);
$project_website = ($project_website_raw !== null)?(addScheme($project_website_raw)):(null);
?>
<html>

<head>
<link type="text/css" rel="stylesheet" href="map.css">
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>

<title>Knowledge Map of <?php echo $topic ?></title>
</head>

<body class="knowledge-map" style="margin:0px; padding:0px; height:100%;">
<div id="visualization" class="headstart"></div>
<div id="errors" class="errors-container"></div>
<div id="reload" class="reload-button"><i class="fas fa-redo"></i><span id="reload-text"> An update is available <br><a id="reload" class="dismiss-reload">reload now</a> or <a id="dismiss-reload" class="dismiss-reload">do it later</a></span></div>
<script type="text/javascript">

function displayErrors(errors) {
if(errors.length > 0) {
$("#errors").addClass("show-errors")

let errors_info =
$("<p/>", {
id: "errors-info"
, class: "errors-info"
, html: '<i id="expand-icon" class="fa fa-plus-circle expand-icon" aria-hidden="true"/> The following errors were detected in the data sheet:</i>'
});
$("#errors").append(errors_info);

let errors_table =
$("<table/>", {
id: "errors-table"
, class: "errors-table errors-table-hidden"
});

$("#errors").append(errors_table);

$("<tr/>", {
id: "top-row"
, class: "top-row"
}).appendTo("#errors-table");

for (let field of ["Row", "Column", "Details"]) {
$("<th/>", {
class: "error-row-top"
, text: field
}).appendTo("#top-row");

}

for (let error_num in errors) {
let current_id = "error-row-" + error_num;
$("<tr/>", {
id: current_id
, class: "error-row-entry"
}).appendTo("#errors-table")

for (let field of ["row", "column", "reason"]) {
$("<td/>", {
id: "error-row-row"
, class: "error-row-entry"
, text: errors[error_num][field]
}).appendTo("#" + current_id)
}
}

}

$("#errors-info").on("click", function () {
$("#errors-table").toggleClass("errors-table-hidden");
$("#expand-icon").toggleClass("fa-minus-circle");
});
}

function updateCheck(context) {
let last_update = (typeof context !== "undefined" && context.hasOwnProperty("last_update"))?(context.last_update):("");

$.getJSON("<?php echo $headstart_url ?>server/services/GSheetUpdateAvailable.php?vis_id=<?php echo $SHEET_ID ?>&persistence_backend=<?php echo $PERSISTENCE_BACKEND ?>&gsheet_last_updated=" + encodeURIComponent(last_update),
function(output) {
if (output.update_available) {
$("#reload").addClass("show-reload-button");
$("#reload-text").removeClass("hide-reload-text");
window.clearInterval(check_update);
}
});
}

<?php if(isset($DEBUG) && $DEBUG === true): ?>
function updateMap() {
$.getJSON("<?php echo $headstart_url ?>server/services/updateGSheetsMap.php?q=covis&sheet_id=<?php echo $SHEET_ID ?>",
function(output) {
});
}

var update_map = window.setInterval(updateMap, 45000);
<?php endif; ?>

let elem = document.getElementById('visualization');
var check_update = null;

elem.addEventListener('headstart.data.loaded', function(e) {
let errors = e.detail.data.errors;
displayErrors(errors);
check_update = window.setInterval(updateCheck, 6000, e.detail.data.context);

});

</script>
<script type="text/javascript" src="data-config.js"></script>
<script type="text/javascript" src="<?php echo $headstart_url ?>dist/headstart.js"></script>
<link type="text/css" rel="stylesheet" href="<?php echo $headstart_url ?>dist/headstart.css"></link>
<script>

data_config.server_url = "<?php echo $headstart_url ?>server/";
data_config.files = [{
title: 'CoVis'
, file: "<?php echo $SHEET_ID; ?>"
}]

data_config.service_name= '<span class="backlink"><a href="https://docs.google.com/spreadsheets/d/<?php echo $SHEET_ID ?>/edit#gid=0" class="underline" target="_blank" >Spreadsheet</a></span>';

data_config.intro = {
title: "About this knowledge map"
, body: "<p>Knowledge maps provide an instant overview of a topic by showing the main areas at a glance and resources related to each area. This makes it possible to easily identify useful, pertinent information.</p><p>Research areas are displayed as bubbles. By clicking on one of the bubbles, you can inspect the resources assigned to it. The size of the bubbles is relative to the number of resources assigned to it. Closeness of bubbles implies subject similarity. The closer two bubbles, the closer they are subject-wise. Centrality of bubbles implies subject similarity with the rest of the map, not importance. The closer a bubble is to the center, the closer it is subject-wise to all the other bubbles in the map. </p><h3>Content</h3><p>The content of this knowledge map is curated by <a class='link-popup' href='mailto:<?php echo $main_curator_email ?>'><?php echo $main_curator_name ?></a> as part of <?php if ($project_website !== null) { echo "<a href='" . $project_website . "' target='_blank' class='link-popup'>" . $project_name . "</a>"; } else { echo $project_name; } ?>. Resources are collected and annotated in <a href='https://docs.google.com/spreadsheets/d/<?php echo $SHEET_ID ?>/edit#gid=0' class='link-popup' target='_blank'>a spreadsheet</a>, which is then transformed into the knowledge map.</p><h3>Software</h3><p>The knowledge map is based on the award-winning software developed by Open Knowledge Maps. For more information and the ability to create knowledge maps based on 250+ million documents, please see <a target='_blank' class='link-popup' href='https://openknowledgemaps.org/'>openknowledgemaps.org</a>. To get in touch, please e-mail us at <a target='_blank' class='link-popup' href='mailto:info@openknowledgemaps.org'>info@openknowledgemaps.org</a></p><h3>Rights</h3><p>The curator(s) are solely responsible for the content of the knowledge map. Unless otherwise noted, all content is licensed under a <a class='link-popup' href='http://creativecommons.org/licenses/by/4.0/' target='_blank'>Creative Commons Attribution 4.0 International License</a>. The spreadsheet is made available under <a target='_blank' class='link-popup' href='https://creativecommons.org/share-your-work/public-domain/cc0/'>CC0 (Public Domain Dedication)</a>. The knowledge mapping software is open source and hosted on <a class='link-popup' href='https://github.com/OpenKnowledgeMaps/Headstart' target='_blank'>Github</a>.</p>"
};

$(document).ready(function () {
headstart.start();
})

</script>

<script>
var calcDivHeight = function () {

let height = $(window).height();
let width = $(window).width();
let calculated_height = 0;
let calculation_method = "";

if(height <= 730 || width < 904 || (width >= 985 && width < 1070)) {
calculation_method = "Height calculation min_height";
calculated_height = 689;
} else if (width >= 904 && width <= 984) {
calculation_method = "Height calculation no. 1";
calculated_height = 670 + (width - 904);
} else if (height >= 890 && width >= 1070 && width < 1400) {
calculation_method = "Height calculation no. 2";
calculated_height = 670 + (width - 1070)/2;
} else if (width >= 1441 && height >= 1053) {
calculation_method = "Height calculation large";
calculated_height = 1000;
} else if (height >= 988 && height < 1053 && width >= 1404 && width < 1435) {
calculation_method = "Height calculation no. 3";
calculated_height = 670 + (width - 1170);
} else {
calculation_method = "Height calculation default";
calculated_height = $(window).height() - $("header").outerHeight();
}

<?php if(isset($DEBUG) && $DEBUG === true): ?>
console.log("Height: " +height);
console.log("Width: " +width);
console.log("Calculation method: " +calculation_method);
console.log("Calculated height: " +calculated_height);
<?php endif; ?>

return calculated_height;
}

$(document).ready( function () {
$(window).on("resize", function () {
let div_height = calcDivHeight();
$("#visualization").css("height", div_height + "px")
});
$(window).trigger('resize');

$("#reload").on("click", function () {
location.reload();
});

$("#dismiss-reload").on("click", function (event) {
$("#reload-text").addClass("hide-reload-text");
event.stopPropagation()
});
});
</script>

</body>

</html>
Loading