Add a join button on conflict error

Cleanup stash handling for the error template, and add a button to join the room
Should fix #12
master
Daniel Berteaud 11 years ago
parent 9911506d1d
commit 3b99238cbf
  1. 1
      lib/Vroom/I18N/en.pm
  2. 1
      lib/Vroom/I18N/fr.pm
  3. 46
      public/vroom.pl
  4. 9
      templates/default/error.html.ep

@ -27,6 +27,7 @@ our %Lexicon = (
"THANKS_SEE_YOU_SOON" => "Thanks and see you soon", "THANKS_SEE_YOU_SOON" => "Thanks and see you soon",
"THANKS_FOR_USING" => "Thank you for using VROOM, we hope you enjoyed your meeting", "THANKS_FOR_USING" => "Thank you for using VROOM, we hope you enjoyed your meeting",
"BACK_TO_MAIN_MENU" => "Back to main menu", "BACK_TO_MAIN_MENU" => "Back to main menu",
"JOIN_THIS_ROOM" => "Join this room",
"CREATE_ROOM" => "Create a new room", "CREATE_ROOM" => "Create a new room",
"ROOM_NAME" => "Room name", "ROOM_NAME" => "Room name",
"RANDOM_IF_EMPTY" => "If you let this field empty, a random name will be given to the room", "RANDOM_IF_EMPTY" => "If you let this field empty, a random name will be given to the room",

@ -30,6 +30,7 @@ our %Lexicon = (
"THANKS_FOR_USING" => "Nous vous remmercions de votre confiance, et espérons que " . "THANKS_FOR_USING" => "Nous vous remmercions de votre confiance, et espérons que " .
"vous avez passé une agréable réunion.", "vous avez passé une agréable réunion.",
"BACK_TO_MAIN_MENU" => "Retour au menu principal", "BACK_TO_MAIN_MENU" => "Retour au menu principal",
"JOIN_THIS_ROOM" => "Rejoindre ce salon",
"CREATE_ROOM" => "Créer un salon", "CREATE_ROOM" => "Créer un salon",
"ROOM_NAME" => "Nom du salon", "ROOM_NAME" => "Nom du salon",
"RANDOM_IF_EMPTY" => "Si vous laissez ce champs vide, un nom aléatoire sera donné au salon", "RANDOM_IF_EMPTY" => "Si vous laissez ce champs vide, un nom aléatoire sera donné au salon",

@ -240,16 +240,22 @@ post '/create' => sub {
my $name = $self->param('roomName') || lc guid_string(); my $name = $self->param('roomName') || lc guid_string();
$self->login; $self->login;
unless ($self->valid_room_name($name)){ unless ($self->valid_room_name($name)){
$self->stash(msg => $self->l('ERROR_NAME_INVALID')); return $self->render('error',
return $self->render('error'); room => $name,
msg => $self->l('ERROR_NAME_INVALID'),
err => 'ERROR_NAME_INVALID'
);
} }
$self->delete_rooms; $self->delete_rooms;
if ($self->create_room($name,$self->session('name'))){ unless ($self->create_room($name,$self->session('name'))){
$self->redirect_to('/'.$name); return $self->render('error',
room => $name,
msg => $self->l('ERROR_NAME_CONFLICT'),
err => 'ERROR_NAME_CONFLICT'
);
} }
else{ else{
$self->stash(msg => $self->l('ERROR_NAME_CONFLICT')); $self->redirect_to('/'.$name);
$self->render('error');
} }
}; };
@ -273,26 +279,38 @@ get '/(*room)' => sub {
# Not auth yet, probably a guest # Not auth yet, probably a guest
$self->login; $self->login;
unless ($self->valid_room_name($room)){ unless ($self->valid_room_name($room)){
$self->stash(msg => 'ERROR_NAME_INVALID'); return $self->render('error',
return $self->render('error'); msg => $self->l('ERROR_NAME_INVALID'),
err => 'ERROR_NAME_INVALID',
room => $room
);
} }
my $data = $self->get_room($room); my $data = $self->get_room($room);
unless ($data){ unless ($data){
$self->stash(msg => sprintf ($self->l("ERROR_ROOM_s_DOESNT_EXIST"), $room)); return $self->render('error',
return $self->render('error'); err => 'ERROR_ROOM_s_DOESNT_EXIST',
msg => sprintf ($self->l("ERROR_ROOM_s_DOESNT_EXIST"), $room),
room => $room
);
} }
$self->cookie(vroomsession => encode_base64($self->session('name') . ':' . $data->{name} . ':' . $data->{token}, ''), {expires => time + 60}); $self->cookie(vroomsession => encode_base64($self->session('name') . ':' . $data->{name} . ':' . $data->{token}, ''), {expires => time + 60});
my @participants = $self->get_participants($room); my @participants = $self->get_participants($room);
if ($data->{'locked'}){ if ($data->{'locked'}){
unless (($self->session('name') eq $data->{'owner'}) || (grep { $_ eq $self->session('name') } @participants )){ unless (($self->session('name') eq $data->{'owner'}) || (grep { $_ eq $self->session('name') } @participants )){
$self->stash(msg => sprintf($self->l("ERROR_ROOM_s_LOCKED"), $room)); return $self->render('error',
return $self->render('error'); msg => sprintf($self->l("ERROR_ROOM_s_LOCKED"), $room),
err => 'ERROR_ROOM_s_LOCKED',
room => $room
);
} }
} }
# Add this user to the participants table # Add this user to the participants table
unless($self->add_participant($room,$self->session('name'))){ unless($self->add_participant($room,$self->session('name'))){
$self->stash(msg => $self->l('ERROR_OCCURED')); return $self->render('error',
return $self->render('error'); msg => $self->l('ERROR_OCCURED'),
err => 'ERROR_OCCURED',
room => $room
);
} }
$self->stash(locked => $data->{locked} ? 'checked':'', $self->stash(locked => $data->{locked} ? 'checked':'',
turnPassword => $data->{token}); turnPassword => $data->{token});

@ -4,8 +4,13 @@
<div class="container-fluid"> <div class="container-fluid">
<div class="jumbotron alert-danger"> <div class="jumbotron alert-danger">
<h1><%=l 'ERROR_OCCURED' %></h1> <h1><%=l 'ERROR_OCCURED' %></h1>
<p><%=l "$msg" %></p> <p><%= $msg %></p>
<p><a class="btn btn-primary btn-lg" role="button" href="<%= $self->url_for('/') %>"><%=l 'BACK_TO_MAIN_MENU' %></a></p> <div class="btn-group">
<a class="btn btn-primary btn-lg" role="button" href="<%= $self->url_for('/') %>"><%=l 'BACK_TO_MAIN_MENU' %></a>
<% if ($err eq 'ERROR_NAME_CONFLICT'){ %>
<a class="btn btn-default btn-lg" role="button" href="<%= $self->url_for('/') . $room %>"><%=l 'JOIN_THIS_ROOM' %></a>
<% } %>
</div>
</div> </div>
</div> </div>
%= include 'footer' %= include 'footer'

Loading…
Cancel
Save