Fetch downtime calendar on server side

Change-Id: I15fbe6b42489fa233dc0e17c31910e8a06444a3c
diff --git a/Makefile.PL b/Makefile.PL
index 8d5319d..160fbf1 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -18,6 +18,7 @@
     },
     PREREQ_PM      => {
         'Inline::C'                               => '0.82',
+        'LWP::Simple'                             => 0,
         'Getopt::Std'                             => 0,
         'Getopt::Long'                            => 0,
         'Log::Any'                                => '1.701',
diff --git a/lib/IDS/DeReKoVecs/Read.pm b/lib/IDS/DeReKoVecs/Read.pm
index f63b8c8..4887210 100644
--- a/lib/IDS/DeReKoVecs/Read.pm
+++ b/lib/IDS/DeReKoVecs/Read.pm
@@ -1,5 +1,6 @@
 use utf8;
 package IDS::DeReKoVecs::Read;
+use LWP::Simple;
 use strict;
 use warnings;
 use Config;
@@ -25,8 +26,16 @@
 use Mojo::JSON qw(decode_json encode_json to_json);
 use Exporter qw(import);
 
-our @EXPORT = qw(init_net load_sprofiles getCollocationAssociation getClassicCollocatorsCached getSimilarProfiles getSimilarProfilesCached getBiggestMergedDifferences filter_garbage get_neighbours getWordNumber dump_vecs dump_for_numpy cos_similarity_as_json);
+our @EXPORT = qw(init_net load_sprofiles getDowntimeCalendar getCollocationAssociation getClassicCollocatorsCached getSimilarProfiles getSimilarProfilesCached getBiggestMergedDifferences filter_garbage get_neighbours getWordNumber dump_vecs dump_for_numpy cos_similarity_as_json);
 
+sub getDowntimeCalendar {
+  my ($url) = @_;
+  if ($url =~ m/^\s*$/) {
+    return "";
+  }
+  my $calendar = LWP::Simple::get($url);
+  return $calendar;
+}
 
 sub getCollocationAssociation {
   my ($c, $word, $collocate) = @_;
diff --git a/script/derekovecs-server b/script/derekovecs-server
index 7525b0d..e8b1c1b 100755
--- a/script/derekovecs-server
+++ b/script/derekovecs-server
@@ -268,6 +268,18 @@
   $self->render(data => cos_similarity_as_json($w1, $w2), format=>'json');
 };
 
+any '*/getDowntimeCalendar' => sub {
+  my $self = shift;
+  my $calendar = getDowntimeCalendar($DOWNTIME_CALENDAR_URL);
+  $self->render(data => $calendar, format=>'text');
+};
+
+any '/getDowntimeCalendar' => sub {
+  my $self = shift;
+  my $calendar = getDowntimeCalendar($DOWNTIME_CALENDAR_URL);
+  $self->render(data => $calendar, format=>'text');
+};
+
 get '*/img/*' => sub {
 	my $c = shift;
 	my $url = $c->req->url;
@@ -364,8 +376,7 @@
       dedupe               => $dedupe,
       marked               => \%marked,
       lists                => \@lists,
-      collocators          => $res->{syntagmatic},
-      downtime_calendar_url => $DOWNTIME_CALENDAR_URL
+      collocators          => $res->{syntagmatic}
     );
   }
 } => "paradigmaticAndSyntagmaticNbs";
diff --git a/templates/index.html.ep b/templates/index.html.ep
index c8b684d..88ff568 100644
--- a/templates/index.html.ep
+++ b/templates/index.html.ep
@@ -48,7 +48,7 @@
      }
      
      $(document).ready(function() {
-       insertCalendarEvents(document.getElementById('downtimes'), "<%= $downtime_calendar_url %>");
+       insertCalendarEvents(document.getElementById('downtimes'), '/derekovecs/getDowntimeCalendar' );
 
        $('#firstable').hide();
        //Set up a callback to hear back when MathJax is done rendering the equations