From 7487895a4a4a7dee8c2d03d721f13d2007b7aba3 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 14 Jul 2015 00:25:41 +0200 Subject: [PATCH] Make etherpad::API optional --- vroom.pl | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/vroom.pl b/vroom.pl index 975abd8..717ece3 100755 --- a/vroom.pl +++ b/vroom.pl @@ -16,7 +16,6 @@ use Digest::HMAC_SHA1 qw(hmac_sha1); use MIME::Base64; use File::stat; use File::Basename; -use Etherpad::API; use Session::Token; use Email::Valid; use Protocol::SocketIO::Handshake; @@ -42,14 +41,21 @@ foreach my $dir (qw/assets/){ # Create etherpad api client if enabled our $ec = undef; +my $etherpad = eval { require Etherpad::API }; if ($config->{'etherpad.uri'} =~ m/https?:\/\/.*/ && $config->{'etherpad.api_key'} ne ''){ - $ec = Etherpad::API->new({ - url => $config->{'etherpad.uri'}, - apikey => $config->{'etherpad.api_key'} - }); - if (!$ec->check_token){ - app->log->info("Can't connect to Etherpad-Lite API, check your API key and uri"); - $ec = undef; + if ($etherpad){ + import Etherpad::API; + $ec = Etherpad::API->new({ + url => $config->{'etherpad.uri'}, + apikey => $config->{'etherpad.api_key'} + }); + 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"); } }