Make etherpad::API optional

master
Daniel Berteaud 9 years ago
parent e67ad9abf8
commit 7487895a4a
  1. 22
      vroom.pl

@ -16,7 +16,6 @@ use Digest::HMAC_SHA1 qw(hmac_sha1);
use MIME::Base64; use MIME::Base64;
use File::stat; use File::stat;
use File::Basename; use File::Basename;
use Etherpad::API;
use Session::Token; use Session::Token;
use Email::Valid; use Email::Valid;
use Protocol::SocketIO::Handshake; use Protocol::SocketIO::Handshake;
@ -42,14 +41,21 @@ foreach my $dir (qw/assets/){
# Create etherpad api client if enabled # Create etherpad api client if enabled
our $ec = undef; our $ec = undef;
my $etherpad = eval { require Etherpad::API };
if ($config->{'etherpad.uri'} =~ m/https?:\/\/.*/ && $config->{'etherpad.api_key'} ne ''){ if ($config->{'etherpad.uri'} =~ m/https?:\/\/.*/ && $config->{'etherpad.api_key'} ne ''){
$ec = Etherpad::API->new({ if ($etherpad){
url => $config->{'etherpad.uri'}, import Etherpad::API;
apikey => $config->{'etherpad.api_key'} $ec = Etherpad::API->new({
}); url => $config->{'etherpad.uri'},
if (!$ec->check_token){ apikey => $config->{'etherpad.api_key'}
app->log->info("Can't connect to Etherpad-Lite API, check your API key and uri"); });
$ec = undef; if (!$ec->check_token){
app->log->info("Can't connect to Etherpad-Lite API, check your API key and uri");
$ec = undef;
}
}
else{
app->log->info("Etherpad::API not found, disabling Etherpad-Lite support");
} }
} }

Loading…
Cancel
Save