diff --git a/dataexplorer/Dockerfile b/dataexplorer/Dockerfile
index 0a60e71..582a003 100755
--- a/dataexplorer/Dockerfile
+++ b/dataexplorer/Dockerfile
@@ -55,6 +55,7 @@ RUN R -e "install.packages(c('JADE'), repos='http://cran.rstudio.com/')" && \
ADD ./ /srv/shiny-server
RUN rm -rf /var/lib/apt/lists/* && \
+ cp /srv/shiny-server/conf/shiny-server.conf /etc/shiny-server/shiny-server.conf && \
cp /srv/shiny-server/conf/launch-server.sh /usr/local/bin && \
chmod 755 /usr/local/bin/launch-server.sh
diff --git a/dataexplorer/Rsrc/Init_UI.R b/dataexplorer/Rsrc/Init_UI.R
index d66e7fc..503bd3f 100644
--- a/dataexplorer/Rsrc/Init_UI.R
+++ b/dataexplorer/Rsrc/Init_UI.R
@@ -13,11 +13,14 @@
#----------------------------------------------------
apiKeyModal <- function(failed = FALSE) {
modalDialog(
- passwordInput("authkey", "Enter the API Key", width = '400px', placeholder = '' ),
+ tags$table(tags$tr(
+ tags$td(passwordInput("authkey", "Enter the API Key", width = '400px', placeholder = '' )),
+ tags$td(tags$img(id='eyeapikey', src = "eye-close.png", width=30, onclick="javascript:eyetoggle();"))
+ )),
if (failed)
div(tags$b("Invalid API Key", style = "color: red;")),
footer = tagList(
- modalButton("Cancel"), actionButton("okApiKey", "OK")
+ modalButton("Cancel"), actionButton("okApiKey", "Submit")
)
)
}
diff --git a/dataexplorer/Rsrc/libs.R b/dataexplorer/Rsrc/libs.R
index 11b9e76..cbea633 100644
--- a/dataexplorer/Rsrc/libs.R
+++ b/dataexplorer/Rsrc/libs.R
@@ -25,7 +25,7 @@ dsname <- ''
dcname <- ''
# ws : Web service connection variables
-# 1: API key mode
+# 1: API key mode : 0 => no API key, 1 => API key in query string, 2 => API key in HTTP header
# 2: dataset shortname
# 3: API Key
# 4: API URL
@@ -138,27 +138,26 @@ getAbout <- function () {
# Get 'infos.md' content
getInfos <- function (ws) {
T <- httr_get(ws, paste0('infos/', ws[2]))
- if (!is.wsError() && !is.wsNoAuth()) {
+ if (!is.wsError() && !is.wsNoAuth() && ws[1]>0) {
# Images
- P <- na.omit(str_extract(T, pattern="@@IMAGE@@/[^\\.]+\\.(png|jpg)"))
+ P <- na.omit(str_extract(T, pattern="https?:[^:]+\\.(png|jpg)"))
if (length(P)>0) for (i in 1:length(P)) {
- I <- base64_enc(httr_get(ws, paste0('image/', ws[2], '/', gsub('@@IMAGE@@/','',P[i])), mode='raw'))
+ I <- base64_enc(httr_get(ws, paste0('image/', ws[2], '/', basename(P[i])), mode='raw'))
T <- gsub( P[i], paste0('data:image/png;base64,',I), T )
}
# PDF - markdown link style
- P <- na.omit(str_extract(T, pattern="\\[[^\\]]+\\]\\(@@PDF@@/[^\\.]+\\.pdf\\)"))
+ P <- na.omit(str_extract(T, pattern="\\[[^\\]]+\\]\\(https?:[^:]+\\.pdf\\)"))
if (length(P)>0) for (i in 1:length(P)) {
- V <- as.vector(simplify2array(strsplit(gsub('@@PDF@@','',gsub('(\\[|\\]|\\(|\\))','',P[i])),'/')))
- urlapi <- paste0(ws[4],'pdf/',ws[2],'/',V[2])
- href <- paste0("",V[1],"")
+ V <- as.vector(simplify2array(strsplit(gsub('(\\[|\\]|\\(|\\))',',',P[i]),',')))
+ V <- V[ V != "" ]
+ href <- paste0("",V[1],"")
T <- gsub(P[i], href, T, fixed=TRUE)
}
# PDF - normal link style
- P <- na.omit(str_extract(T, pattern="@@PDF@@/[^\\.]+\\.pdf"))
+ P <- na.omit(str_extract(T, pattern="[^']https?:[^:]+\\.pdf"))
if (length(P)>0) for (i in 1:length(P)) {
- V <- gsub('@@PDF@@/','',P[1])
- urlapi <- paste0(ws[4],'pdf/',ws[2],'/', V)
- href <- paste0("",V,"")
+ urlapi <- substring(P[i],2)
+ href <- paste0(substring(P[i],1,1), "",basename(urlapi),"")
T <- gsub(P[i], href, T, fixed=TRUE)
}
}
diff --git a/dataexplorer/conf/shiny-server.conf b/dataexplorer/conf/shiny-server.conf
new file mode 100644
index 0000000..6822c12
--- /dev/null
+++ b/dataexplorer/conf/shiny-server.conf
@@ -0,0 +1,24 @@
+# Instruct Shiny Server to run applications as the user "shiny"
+run_as shiny;
+http_keepalive_timeout 120;
+
+# Define a server that listens on port 3838
+server {
+ listen 3838;
+
+ # Define a location at the base URL
+ location / {
+ # disable application idle timeouts
+ app_idle_timeout 0;
+
+ # Host the directory of Shiny Apps stored in this directory
+ site_dir /srv/shiny-server;
+
+ # Log all Shiny output to files in this directory
+ log_dir /var/log/shiny-server;
+
+ # When a user visits the base URL rather than a particular application,
+ # an index of the applications available in this directory will be shown.
+ directory_index on;
+ }
+}
diff --git a/dataexplorer/ui.R b/dataexplorer/ui.R
index ab0e124..3dab6aa 100755
--- a/dataexplorer/ui.R
+++ b/dataexplorer/ui.R
@@ -10,7 +10,7 @@ meta <- tags$head(
'),
tags$script(type="text/javascript", src = "js/google-analytics.js"),
tags$script(type="text/javascript",src = "js/d3.min.js"),
- tags$script(type="text/javascript",src = "js/getip.js"),
+ tags$script(type="text/javascript",src = "js/utils.js"),
tags$link(rel = "stylesheet", type = "text/css", href = "custom.css")
)
diff --git a/dataexplorer/www/custom.css b/dataexplorer/www/custom.css
index 5eed48c..22fd7c1 100755
--- a/dataexplorer/www/custom.css
+++ b/dataexplorer/www/custom.css
@@ -23,6 +23,11 @@ p {
display: none;
}
+#eyeapikey {
+ vertical-align: bottom;
+ cursor: pointer;
+}
+
.jlink {cursor: pointer;}
.dropdown , .dropdown h2 {
diff --git a/dataexplorer/www/eye-close.png b/dataexplorer/www/eye-close.png
new file mode 100644
index 0000000..a2f634d
Binary files /dev/null and b/dataexplorer/www/eye-close.png differ
diff --git a/dataexplorer/www/eye-open.png b/dataexplorer/www/eye-open.png
new file mode 100644
index 0000000..6be8892
Binary files /dev/null and b/dataexplorer/www/eye-open.png differ
diff --git a/dataexplorer/www/js/getip.js b/dataexplorer/www/js/utils.js
similarity index 76%
rename from dataexplorer/www/js/getip.js
rename to dataexplorer/www/js/utils.js
index d092ca8..c8bef66 100644
--- a/dataexplorer/www/js/getip.js
+++ b/dataexplorer/www/js/utils.js
@@ -1,11 +1,39 @@
-// Get IP Client
-// https://stackoverflow.com/questions/391979/how-to-get-clients-ip-address-using-javascript
+// Get a PDF through the API
+// apikey, ipclient : global variables
+var openPDF = function(url) {
+ $.ajax({
+ url: url,
+ cache: false,
+ xhrFields: { responseType: 'blob' },
+ headers: { "x-api-key": apikey, 'x-forwarded-for': ipclient },
+ success: function(blob) {
+ var link=document.createElement('a');
+ link.href=window.URL.createObjectURL(blob);
+ link.type = 'application/pdf';
+ link.target='_blank';
+ link.click();
+ }
+ });
+}
+
+// Toggle input of the API Key, from 'password' to 'text' and vice-versa
+var eyetoggle = function() {
+ if ( $('#eyeapikey').attr('src') === 'eye-close.png' ) {
+ $('#eyeapikey').attr('src','eye-open.png');
+ $('#authkey').get(0).type = 'text';
+ } else {
+ $('#eyeapikey').attr('src','eye-close.png');
+ $('#authkey').get(0).type = 'password';
+ }
+}
+// Send IP to Shiny Server
var sendIP = function(theip) {
Shiny.onInputChange("ipclient", theip);
console.log(theip);
}
+// Convert data to JSON
var toJSON = function( data ) {
json = data.trim().split('\n').reduce(function(obj, pair) {
pair = pair.split('=');
@@ -14,6 +42,11 @@ var toJSON = function( data ) {
return json;
}
+// Get IP Client
+// https://stackoverflow.com/questions/391979/how-to-get-clients-ip-address-using-javascript
+
+// When the shiny session is initialized
+// => Get IP Client, then send it to Shiny Server
$( document ).on("shiny:sessioninitialized", function(event) {
$.ajax({
@@ -40,20 +73,3 @@ $( document ).on("shiny:sessioninitialized", function(event) {
})
-// Get a PDF through the API
-// apikey, ipclient : global variables
-var openPDF = function(url) {
- $.ajax({
- url: url,
- cache: false,
- xhrFields: { responseType: 'blob' },
- headers: { "x-api-key": apikey, 'x-forwarded-for': ipclient },
- success: function(blob) {
- var link=document.createElement('a');
- link.href=window.URL.createObjectURL(blob);
- link.type = 'application/pdf';
- link.target='_blank';
- link.click();
- }
- });
-}
diff --git a/getData/www/inc/infos.inc b/getData/www/inc/infos.inc
index b0c6fa9..c39fa6d 100755
--- a/getData/www/inc/infos.inc
+++ b/getData/www/inc/infos.inc
@@ -66,6 +66,8 @@ do {
}
$INFOS_TEXT = file_get_contents($ENV['DATADIR']."/$dataset/infos.md");
+ $INFOS_TEXT = preg_replace('/@@IMAGE@@/', $GETDATA_URL_PROXY."image/$dataset", $INFOS_TEXT);
+ $INFOS_TEXT = preg_replace('/@@PDF@@/', $GETDATA_URL_PROXY."pdf/$dataset", $INFOS_TEXT);
} while (0);
diff --git a/getData/www/infos b/getData/www/infos
index 3999ef5..94a0d21 100755
--- a/getData/www/infos
+++ b/getData/www/infos
@@ -13,4 +13,5 @@ ini_set("include_path", ".:/usr/share/php");
include ('inc/config.inc');
include ('inc/infos.inc');
+
?>