summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2019-08-16 09:49:53 +0000
committergebele <gebele@in-silico.ch>2019-08-16 09:49:53 +0000
commit270bddf5081671cd1905d6cce6eb3659159f573a (patch)
tree86dd2db590b86185cce8f52cefb2b7fba0fb9623
parent74332693fed1d5ecb695dd6ae0c2fc611d14c4d7 (diff)
change hostname method
-rw-r--r--application.rb3
-rw-r--r--lib/model.rb2
-rw-r--r--views/batch.haml10
-rw-r--r--views/error.haml2
-rw-r--r--views/faq.haml2
-rw-r--r--views/layout.haml6
-rw-r--r--views/model_details.haml4
-rw-r--r--views/neighbors.haml2
-rw-r--r--views/predict.haml6
-rw-r--r--views/prediction.haml4
-rw-r--r--views/upload.haml6
11 files changed, 25 insertions, 22 deletions
diff --git a/application.rb b/application.rb
index 064c488..d6cf0f8 100644
--- a/application.rb
+++ b/application.rb
@@ -40,6 +40,9 @@ configure :production, :development do
end
before do
+ # use this hostname method instead to('/')
+ # allowes to set https for xhr requests
+ $host_with_port = request.host =~ /localhost/ ? request.host_with_port : request.host
$paths = [
"api",
"compound",
diff --git a/lib/model.rb b/lib/model.rb
index 55172b0..dfc779c 100644
--- a/lib/model.rb
+++ b/lib/model.rb
@@ -145,7 +145,7 @@ post "/api/model/:id/?" do
@task.save
end#main task
tid = @task.id.to_s
- return 202, "//#{ENV['VIRTUAL_HOST']}/task/#{tid}".to_json
+ return 202, "//#{$host_with_port}/task/#{tid}".to_json
else
halt 400, "No accepted content type"
end
diff --git a/views/batch.haml b/views/batch.haml
index 4e1df05..6bc2354 100644
--- a/views/batch.haml
+++ b/views/batch.haml
@@ -3,12 +3,12 @@
window.addEventListener('unload', ktpid, false);
function ktpid() {
var client = new XMLHttpRequest();
- client.open("GET", '//#{ENV['VIRTUAL_HOST']}/prediction/task?ktpid=#{@pid}', false);
+ client.open("GET", '//#{$host_with_port}/prediction/task?ktpid=#{@pid}', false);
client.setRequestHeader("Content-Type", "application/json");
client.send(null);
};
%div.card
- %a.btn.btn-outline-info{:href => "//#{ENV['VIRTUAL_HOST']}/predict?tpid=#{@pid}"}
+ %a.btn.btn-outline-info{:href => "//#{$host_with_port}/predict?tpid=#{@pid}"}
%span.fa.fa-caret-left{:aria=>{:hidden=>"true"}}
New Prediction
%div.card.bg-light
@@ -29,10 +29,10 @@
%h5.card-title="#{m.endpoint} (#{m.species})"
#pager{:id=>idx}
%div.col-6
- %a.btn.btn-outline-info.btn-sm.disabled{:id => "detailsbutton_#{idx}", :data=>{:toggle=>"collapse"}, :href=>"javascript:void(0)", :onclick=>"pagePredictions('//#{ENV['VIRTUAL_HOST']}/prediction/task/?predictions=#{task}','#{model}','#{idx}','#{@compounds_size}')"}
+ %a.btn.btn-outline-info.btn-sm.disabled{:id => "detailsbutton_#{idx}", :data=>{:toggle=>"collapse"}, :href=>"javascript:void(0)", :onclick=>"pagePredictions('//#{$host_with_port}/prediction/task/?predictions=#{task}','#{model}','#{idx}','#{@compounds_size}')"}
%span.fa.fa-caret-right
Details
- %a.btn.btn-outline-info.btn-sm.disabled{:id => "downbutton_#{idx}", :href=>"//#{ENV['VIRTUAL_HOST']}/predict/batch/download?tid=#{task}", :title=>"download"}
+ %a.btn.btn-outline-info.btn-sm.disabled{:id => "downbutton_#{idx}", :href=>"//#{$host_with_port}/predict/batch/download?tid=#{task}", :title=>"download"}
%span.fa.fa-download
CSV
%p{:id=>"est_#{idx}"}
@@ -40,7 +40,7 @@
%img.h2{:src=>"/images/wait30trans.gif", :id=>"circle_#{idx}", :class=>"circle", :alt=>"wait", :style=>"display:none;"}
:javascript
$(document).ready(function() {
- taskProgress('#{idx}','#{timer}','//#{ENV['VIRTUAL_HOST']}/prediction/task/?turi=#{task}');
+ taskProgress('#{idx}','#{timer}','//#{$host_with_port}/prediction/task/?turi=#{task}');
});
#data-container.card.d-none.table-responsive{:id=>idx}
:javascript
diff --git a/views/error.haml b/views/error.haml
index b1adee9..d00b578 100644
--- a/views/error.haml
+++ b/views/error.haml
@@ -1,5 +1,5 @@
%div.card
- %a.btn.btn-warning{:href => "//#{ENV['VIRTUAL_HOST']}/predict"}
+ %a.btn.btn-warning{:href => "//#{$host_with_port}/predict"}
%i.fa.fa-caret-left
Back
%div.card-body
diff --git a/views/faq.haml b/views/faq.haml
index b058de8..8c0e604 100644
--- a/views/faq.haml
+++ b/views/faq.haml
@@ -1,5 +1,5 @@
%div.card
- %a.btn.btn-warning{:href => "//#{ENV['VIRTUAL_HOST']}/predict"}
+ %a.btn.btn-warning{:href => "//#{$host_with_port}/predict"}
%i.fa.fa-caret-left
Back
%div.card-body
diff --git a/views/layout.haml b/views/layout.haml
index 790c647..8547e13 100644
--- a/views/layout.haml
+++ b/views/layout.haml
@@ -37,14 +37,14 @@
Problems, bugs, ideas for improvements ? Please report at our
%a{:href => 'https://github.com/opentox/lazar-gui/issues', :rel => "external"} issue tracker
, check out the
- %a{:href=> "//#{ENV['VIRTUAL_HOST']}/predict/faq"} FAQ
+ %a{:href=> "//#{$host_with_port}/predict/faq"} FAQ
page or send us an email.
%a{ :href=>"mailto:info@in-silico.ch?subject=[lazar v#{@version}]", :target=>"_top"}
%span.fa.fa-envelope
[version: #{@version}]
%p
A graphical overview of the service API can be found
- %a{:href => "//#{ENV['VIRTUAL_HOST']}/api", :rel => "external"} here.
+ %a{:href => "//#{$host_with_port}/api", :rel => "external"} here.
Please cite
%a{ :href=>"https://doi.org/10.3389/fphar.2013.00038", :rel=>"external"}
%img{ :src=>"https://zenodo.org/badge/DOI/10.3389/zenodo.10.3389.svg", :alt=>"DOI"}
@@ -66,7 +66,7 @@
&copy;
%a{:href => 'http://www.in-silico.ch', :rel => "external"} <i style="font-family: serife">in silico</i> toxicology gmbh 2004 - #{Time.now.year.to_s}
|
- %a{:href => "//#{ENV['VIRTUAL_HOST']}/predict/license", :rel => "external"} GPL3 License
+ %a{:href => "//#{$host_with_port}/predict/license", :rel => "external"} GPL3 License
%supporters.row
%div.card-body.text-center
%div.card-title
diff --git a/views/model_details.haml b/views/model_details.haml
index 1fcc624..ab58035 100644
--- a/views/model_details.haml
+++ b/views/model_details.haml
@@ -13,7 +13,7 @@
= data_entries.count/3
%br
= "Training dataset:\t"
- %a{:href=>"//#{ENV['VIRTUAL_HOST']}/predict/dataset/#{training_dataset.name}"}
+ %a{:href=>"//#{$host_with_port}/predict/dataset/#{training_dataset.name}"}
= training_dataset.name
%div.card.bg-light
@@ -190,7 +190,7 @@
%div.card.bg-light
%div.card-body
%h6.card-title QMRF:
- %a.btn.btn-outline-info{:href=>"//#{ENV['VIRTUAL_HOST']}/predict/report/#{model.id}", :id=>"report#{model.id}", :style=>"font-size:small;"}
+ %a.btn.btn-outline-info{:href=>"//#{$host_with_port}/predict/report/#{model.id}", :id=>"report#{model.id}", :style=>"font-size:small;"}
%span.fa.fa-download
XML
%br
diff --git a/views/neighbors.haml b/views/neighbors.haml
index 687f0ab..e67c664 100644
--- a/views/neighbors.haml
+++ b/views/neighbors.haml
@@ -34,7 +34,7 @@
/ Compound
- c = Compound.find(neighbor)
%td
- %a.btn.btn-link{:href => "#details#{j+1}", data: { toggle: "modal", remote: "//#{ENV['VIRTUAL_HOST']}/prediction/#{CGI.escape(c.id.to_s)}/details", :id=>"link#{j+1}#{count}"}}
+ %a.btn.btn-link{:href => "#details#{j+1}", data: { toggle: "modal", remote: "//#{$host_with_port}/prediction/#{CGI.escape(c.id.to_s)}/details", :id=>"link#{j+1}#{count}"}}
= embedded_svg(c.svg, :title=>"click for details")
/ Measured Activity
diff --git a/views/predict.haml b/views/predict.haml
index 966ffd2..7dedf63 100644
--- a/views/predict.haml
+++ b/views/predict.haml
@@ -1,7 +1,7 @@
%link{ :href=>"/jsme/jsa.css", :rel=>"stylesheet", :property=>"stylesheet"}
%script{:src=>"/jsme/jsme.nocache.js"}
// whole site content needs to be in one form. Input and checkboxes are proofed by js functions.
-%form{:name => "form", :action => "//#{ENV['VIRTUAL_HOST']}/predict", :method => "post", :enctype => "multipart/form-data", :onsubmit => "return !!(showcircle())" }
+%form{:name => "form", :action => "//#{$host_with_port}/predict", :method => "post", :enctype => "multipart/form-data", :onsubmit => "return !!(showcircle())" }
%fieldset#top.card.bg-light
#insert.card-body
%h2.card-title 1. Draw a chemical structure
@@ -20,7 +20,7 @@
%br
%span.btn.btn-file{:style=>"background-color:white;"}
%input.form-control-file{:type=>"file", :name=> "fileselect", :id=>"fileselect", :accept=>"text/csv"}
- %a.btn.btn-outline-info{:href => "//#{ENV['VIRTUAL_HOST']}/predict/help", :rel => "external", :style=>"margin-left: 1em;"} Help
+ %a.btn.btn-outline-info{:href => "//#{$host_with_port}/predict/help", :rel => "external", :style=>"margin-left: 1em;"} Help
%fieldset#middle.card.bg-light
#models.card-body
@@ -37,7 +37,7 @@
%label{:for => "selection[#{model.species.gsub(/\s+/, "_")}]"}
= model.species
%span.col-6
- %a.btn.btn-outline-info{:role=>"button", :data=>{:toggle=>"collapse"}, :href=>"#details#{model.id}", :aria=>{:expanded=>"false", :controls=>"details#{model.id}"}, :onclick=>"loadDetails('#{model.id}','//#{ENV['VIRTUAL_HOST']}/predict/modeldetails/#{model.id}')", :id => "link#{model.id}", :style=>"font-size:small;"}
+ %a.btn.btn-outline-info{:role=>"button", :data=>{:toggle=>"collapse"}, :href=>"#details#{model.id}", :aria=>{:expanded=>"false", :controls=>"details#{model.id}"}, :onclick=>"loadDetails('#{model.id}','//#{$host_with_port}/predict/modeldetails/#{model.id}')", :id => "link#{model.id}", :style=>"font-size:small;"}
%span.fa.fa-caret-right
Details | Validation
%img.h2{:src=>"/images/wait30trans.gif", :id=>"circle#{model.id}", :class=>"circle#{model.id}", :alt=>"wait", :style=>"display:none;"}
diff --git a/views/prediction.haml b/views/prediction.haml
index 19f5caf..44d5fa8 100644
--- a/views/prediction.haml
+++ b/views/prediction.haml
@@ -1,5 +1,5 @@
%div.card
- %a.btn.btn-outline-info{:href => "//#{ENV['VIRTUAL_HOST']}/predict"}
+ %a.btn.btn-outline-info{:href => "//#{$host_with_port}/predict"}
%span.fa.fa-caret-left
New Prediction
%div.card.bg-light
@@ -10,7 +10,7 @@
%tbody
%tr
%td.align-items-center{:id=>"compound"}
- %a.btn.btn-link{:href => "#details0", data: { toggle: "modal", remote: "//#{ENV['VIRTUAL_HOST']}/prediction/#{@compound.id}/details", :id=>"link01"}}
+ %a.btn.btn-link{:href => "#details0", data: { toggle: "modal", remote: "//#{$host_with_port}/prediction/#{@compound.id}/details", :id=>"link01"}}
= embedded_svg(@compound.svg, :title=>"click for details")
%p= @compound.smiles
- if @compound.cid && @compound.cid != "0"
diff --git a/views/upload.haml b/views/upload.haml
index 159f7a5..54faa5c 100644
--- a/views/upload.haml
+++ b/views/upload.haml
@@ -1,5 +1,5 @@
%div.card
- %a.btn.btn-outline-info{:href => "//#{ENV['VIRTUAL_HOST']}/predict"}
+ %a.btn.btn-outline-info{:href => "//#{$host_with_port}/predict"}
%span.fa.fa-caret-left{:aria=>{:hidden=>"true"}}
New Prediction
%div.card.bg-light{:id=>"uploadDataset"}
@@ -9,7 +9,7 @@
:javascript
$(document).ready(function() {
var aClient = new HttpClient();
- aClient.post('//#{ENV['VIRTUAL_HOST']}/predict', 'models=#{@models}&batchfile=#{@filename}', function(res1) {
+ aClient.post('//#{$host_with_port}/predict', 'models=#{@models}&batchfile=#{@filename}', function(res1) {
var contentType = res1.getResponseHeader('content-type');
if (contentType == "application/json"){
var response = JSON.parse(res1.responseText);
@@ -17,7 +17,7 @@
var response = res1.responseText;
}
if (res1.status == 200 && response['models'] && response['dataset_id']){
- aClient.post('//#{ENV['VIRTUAL_HOST']}/predict', 'models='+response['models']+'&dataset_id='+response['dataset_id'], function(res2) {
+ aClient.post('//#{$host_with_port}/predict', 'models='+response['models']+'&dataset_id='+response['dataset_id'], function(res2) {
$("body").html(res2.responseText);
});
}