diff --git a/lib/Vroom/Constants.pm b/lib/Vroom/Constants.pm new file mode 100644 index 0000000..be7ebab --- /dev/null +++ b/lib/Vroom/Constants.pm @@ -0,0 +1,156 @@ +package Vroom::Constants; + +use strict; +use warnings; +use base 'Exporter'; + +our @EXPORT = qw/COMPONENTS MOH JS_STRINGS/; + +# Components used to generate the credits part +use constant COMPONENTS => { + "SimpleWebRTC" => { + url => 'http://simplewebrtc.com/' + }, + "Mojolicious" => { + url => 'http://mojolicio.us/' + }, + "jQuery" => { + url => 'http://jquery.com/' + }, + "notify.js" => { + url => 'http://notifyjs.com/' + }, + "jQuery-browser-plugin" => { + url => 'https://github.com/gabceb/jquery-browser-plugin' + }, + "jQuery-tinytimer" => { + url => 'https://github.com/odyniec/jQuery-tinyTimer' + }, + "jQuery-etherpad-lite" => { + url => 'https://github.com/ether/etherpad-lite-jquery-plugin' + }, + "sprintf.js" => { + url => 'http://hexmen.com/blog/2007/03/printf-sprintf/' + }, + "node.js" => { + url => 'http://nodejs.org/' + }, + "Bootstrap" => { + url => 'http://getbootstrap.com/' + }, + "MariaDB" => { + url => 'https://mariadb.org/' + }, + "SignalMaster" => { + url => 'https://github.com/andyet/signalmaster/' + }, + "rfc5766-turn-server" => { + url => 'https://code.google.com/p/rfc5766-turn-server/' + }, + "FileSaver" => { + url => 'https://github.com/eligrey/FileSaver.js' + }, + "WPZOOM Developer Icon Set" => { + url => 'https://www.iconfinder.com/search/?q=iconset%3Awpzoom-developer-icon-set' + }, + "Bootstrap Switch" => { + url => 'http://www.bootstrap-switch.org/' + } +}; + +# Music on hold used +# Used to generate credits +use constant MOH => { + "Papel Secante" => { + author => "Angel Gaitan", + author_url => "http://angelgaitan.bandcamp.com/", + licence => "Creative Commons BY-SA", + licence_url => "http://creativecommons.org/licenses/by-sa/3.0" + }, + "Overjazz" => { + author => "Funkyproject", + author_url => "http://www.funkyproject.fr", + licence => "Creative Commons BY-SA", + licence_url => "http://creativecommons.org/licenses/by-sa/3.0" + }, + "Polar Express" => { + author => "Koteen", + author_url => "http://?.?", + licence => "Creative Commons BY-SA", + licence_url => "http://creativecommons.org/licenses/by-sa/3.0" + }, + "Funky Goose" => { + author => "Pepe Frias", + author_url => "http://www.pepefrias.tk/", + licence => "Creative Commons BY-SA", + licence_url => "http://creativecommons.org/licenses/by-sa/3.0" + }, + "I got my own" => { + author => "Reole", + author_url => "http://www.reolemusic.com/", + licence => "Creative Commons BY-SA", + licence_url => "http://creativecommons.org/licenses/by-sa/3.0" + } +}; + +# List of strings needed on client side +use constant JS_STRINGS => qw( + ERROR_MAIL_INVALID + ERROR_OCCURRED + ERROR_NAME_INVALID + CANT_SHARE_SCREEN + SCREEN_SHARING_ONLY_FOR_CHROME + SCREEN_SHARING_CANCELLED + EVERYONE_CAN_SEE_YOUR_SCREEN + SCREEN_UNSHARED + MIC_MUTED + MIC_UNMUTED + CAM_SUSPENDED + CAM_RESUMED + SET_YOUR_NAME_TO_CHAT + ROOM_LOCKED_BY_s + ROOM_UNLOCKED_BY_s + PASSWORD_PROTECT_ON_BY_s + PASSWORD_PROTECT_OFF_BY_s + OWNER_PASSWORD_CHANGED_BY_s + OWNER_PASSWORD_REMOVED_BY_s + SCREEN_s + TO_INVITE_SHARE_THIS_URL + NO_SOUND_DETECTED + DISPLAY_NAME_TOO_LONG + s_IS_MUTING_YOU + s_IS_MUTING_s + s_IS_UNMUTING_YOU + s_IS_UNMUTING_s + s_IS_SUSPENDING_YOU + s_IS_SUSPENDING_s + s_IS_RESUMING_YOU + s_IS_RESUMING_s + s_IS_PROMOTING_YOU + s_IS_PROMOTING_s + s_IS_KICKING_s + MUTE_PEER + SUSPEND_PEER + PROMOTE_PEER + KICK_PEER + YOU_HAVE_MUTED_s + YOU_HAVE_UNMUTED_s + CANT_MUTE_OWNER + YOU_HAVE_SUSPENDED_s + YOU_HAVE_RESUMED_s + CANT_SUSPEND_OWNER + CANT_PROMOTE_OWNER + YOU_HAVE_KICKED_s + CANT_KICK_OWNER + REMOVE_THIS_ADDRESS + DISPLAY_NAME_REQUIRED + A_ROOM_ADMIN + A_PARTICIPANT + PASSWORDS_DO_NOT_MATCH + WAIT_WITH_MUSIC + DATA_WIPED + ROOM_DATA_WIPED_BY_s +); + + +1; diff --git a/vroom.pl b/vroom.pl index 3c2e784..3f270d7 100755 --- a/vroom.pl +++ b/vroom.pl @@ -5,10 +5,11 @@ # Copyright 2014 Firewall Services # Daniel Berteaud -use lib '../lib'; +use lib 'lib'; use Mojolicious::Lite; use Mojolicious::Plugin::Mail; use Mojolicious::Plugin::Database; +use Vroom::Constants; use Crypt::SaltedHash; use MIME::Base64; use File::stat; @@ -17,93 +18,6 @@ use Etherpad::API; use Session::Token; use Config::Simple; -# List The different components we rely on. -# Used to generate thanks on the about template -our $components = { - "SimpleWebRTC" => { - url => 'http://simplewebrtc.com/' - }, - "Mojolicious" => { - url => 'http://mojolicio.us/' - }, - "jQuery" => { - url => 'http://jquery.com/' - }, - "notify.js" => { - url => 'http://notifyjs.com/' - }, - "jQuery-browser-plugin" => { - url => 'https://github.com/gabceb/jquery-browser-plugin' - }, - "jQuery-tinytimer" => { - url => 'https://github.com/odyniec/jQuery-tinyTimer' - }, - "jQuery-etherpad-lite" => { - url => 'https://github.com/ether/etherpad-lite-jquery-plugin' - }, - "sprintf.js" => { - url => 'http://hexmen.com/blog/2007/03/printf-sprintf/' - }, - "node.js" => { - url => 'http://nodejs.org/' - }, - "Bootstrap" => { - url => 'http://getbootstrap.com/' - }, - "MariaDB" => { - url => 'https://mariadb.org/' - }, - "SignalMaster" => { - url => 'https://github.com/andyet/signalmaster/' - }, - "rfc5766-turn-server" => { - url => 'https://code.google.com/p/rfc5766-turn-server/' - }, - "FileSaver" => { - url => 'https://github.com/eligrey/FileSaver.js' - }, - "WPZOOM Developer Icon Set" => { - url => 'https://www.iconfinder.com/search/?q=iconset%3Awpzoom-developer-icon-set' - }, - "Bootstrap Switch" => { - url => 'http://www.bootstrap-switch.org/' - } -}; - -# MOH authors for credits -our $musics = { - "Papel Secante" => { - author => "Angel Gaitan", - author_url => "http://angelgaitan.bandcamp.com/", - licence => "Creative Commons BY-SA", - licence_url => "http://creativecommons.org/licenses/by-sa/3.0" - }, - "Overjazz" => { - author => "Funkyproject", - author_url => "http://www.funkyproject.fr", - licence => "Creative Commons BY-SA", - licence_url => "http://creativecommons.org/licenses/by-sa/3.0" - }, - "Polar Express" => { - author => "Koteen", - author_url => "http://?.?", - licence => "Creative Commons BY-SA", - licence_url => "http://creativecommons.org/licenses/by-sa/3.0" - }, - "Funky Goose" => { - author => "Pepe Frias", - author_url => "http://www.pepefrias.tk/", - licence => "Creative Commons BY-SA", - licence_url => "http://creativecommons.org/licenses/by-sa/3.0" - }, - "I got my own" => { - author => "Reole", - author_url => "http://www.reolemusic.com/", - licence => "Creative Commons BY-SA", - licence_url => "http://creativecommons.org/licenses/by-sa/3.0" - } -}; - app->log->level('info'); # Read conf file, and set default values my $cfg = new Config::Simple(); @@ -139,64 +53,6 @@ $config->{'daemon.backend'} ||= 'hypnotoad'; # Set log level app->log->level($config->{'log.level'}); -our @js_locales = qw( - ERROR_MAIL_INVALID - ERROR_OCCURRED - ERROR_NAME_INVALID - CANT_SHARE_SCREEN - SCREEN_SHARING_ONLY_FOR_CHROME - SCREEN_SHARING_CANCELLED - EVERYONE_CAN_SEE_YOUR_SCREEN - SCREEN_UNSHARED - MIC_MUTED - MIC_UNMUTED - CAM_SUSPENDED - CAM_RESUMED - SET_YOUR_NAME_TO_CHAT - ROOM_LOCKED_BY_s - ROOM_UNLOCKED_BY_s - PASSWORD_PROTECT_ON_BY_s - PASSWORD_PROTECT_OFF_BY_s - OWNER_PASSWORD_CHANGED_BY_s - OWNER_PASSWORD_REMOVED_BY_s - SCREEN_s - TO_INVITE_SHARE_THIS_URL - NO_SOUND_DETECTED - DISPLAY_NAME_TOO_LONG - s_IS_MUTING_YOU - s_IS_MUTING_s - s_IS_UNMUTING_YOU - s_IS_UNMUTING_s - s_IS_SUSPENDING_YOU - s_IS_SUSPENDING_s - s_IS_RESUMING_YOU - s_IS_RESUMING_s - s_IS_PROMOTING_YOU - s_IS_PROMOTING_s - s_IS_KICKING_s - MUTE_PEER - SUSPEND_PEER - PROMOTE_PEER - KICK_PEER - YOU_HAVE_MUTED_s - YOU_HAVE_UNMUTED_s - CANT_MUTE_OWNER - YOU_HAVE_SUSPENDED_s - YOU_HAVE_RESUMED_s - CANT_SUSPEND_OWNER - CANT_PROMOTE_OWNER - YOU_HAVE_KICKED_s - CANT_KICK_OWNER - REMOVE_THIS_ADDRESS - DISPLAY_NAME_REQUIRED - A_ROOM_ADMIN - A_PARTICIPANT - PASSWORDS_DO_NOT_MATCH - WAIT_WITH_MUSIC - DATA_WIPED - ROOM_DATA_WIPED_BY_s -); - # Create etherpad api client if required our $ec = undef; if ($config->{'etherpad.uri'} =~ m/https?:\/\/.*/ && $config->{'etherpad.api_key'} ne ''){ @@ -956,8 +812,8 @@ any '/' => sub { get '/about' => sub { my $self = shift; $self->stash( - components => $components, - musics => $musics + components => COMPONENTS, + musics => MOH ); } => 'about'; @@ -1105,7 +961,7 @@ post '/create' => sub { get '/localize/:lang' => { lang => 'en' } => sub { my $self = shift; my $strings = {}; - foreach my $string (@js_locales){ + foreach my $string (JS_STRINGS){ $strings->{$string} = $self->l($string); } # Cache the translation