From f55d6cf092bc10a5dc89a42a62bda4c7101306cc Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 15 May 2014 16:56:14 +0200 Subject: [PATCH] Various fixes in path handling when using language suffix --- public/vroom.pl | 24 +++++++++++++++--------- templates/default/error.html.ep | 8 ++++---- templates/default/feedback.html.ep | 2 +- templates/default/feedback_thanks.html.ep | 2 +- templates/default/goodby.html.ep | 4 ++-- templates/default/index.html.ep | 2 +- templates/default/js_include.html.ep | 6 +----- templates/default/public_toolbar.html.ep | 8 ++++---- 8 files changed, 29 insertions(+), 27 deletions(-) diff --git a/public/vroom.pl b/public/vroom.pl index 6a15674..e2b4e90 100755 --- a/public/vroom.pl +++ b/public/vroom.pl @@ -269,6 +269,14 @@ helper get_mtime => sub { return stat($file)->mtime; }; +# Wrapper arround url_for which adds a trailing / if needed +helper get_url => sub { + my $self = shift; + my $url = $self->url_for(shift); + $url .= ($url =~ m/\/$/) ? '' : '/'; + return $url; +}; + # Password protect a room # Takes two args: room name and password # If password is undef: remove the password @@ -340,7 +348,7 @@ post '/feedback' => sub { comment => $comment ], ); - $self->redirect_to($self->url_for('feedback_thanks')); + $self->redirect_to($self->get_url('feedback_thanks')); }; # Route for the thanks after feedback form @@ -391,7 +399,7 @@ post '/create' => sub { # and redirect him on it. else{ $self->session($name => {role => 'owner'}); - $self->redirect_to($self->url_for('/') . $name); + $self->redirect_to($self->get_url('/') . $name); } }; @@ -439,12 +447,12 @@ post '/password/(:room)' => sub { # First check if we got the owner password, and if so, mark this user as owner if ($data->{owner_password} && Crypt::SaltedHash->validate($data->{owner_password}, $pass)){ $self->session($room => {role => 'owner'}); - $self->redirect_to($self->url_for('/') . $room); + $self->redirect_to($self->get_url('/') . $room); } # Then, check if it's the join password elsif ($data->{join_password} && Crypt::SaltedHash->validate($data->{join_password}, $pass)){ $self->session($room => {role => 'participant'}); - $self->redirect_to($self->url_for('/') . $room); + $self->redirect_to($self->get_url('/') . $room); } # Else, it's a wrong password, display an error page else{ @@ -462,7 +470,7 @@ get '/(*room)' => sub { my $room = $self->stash('room'); # Redirect to lower case if ($room ne lc $room){ - $self->redirect_to($self->url_for('/') . lc $room); + $self->redirect_to($self->get_url('/') . lc $room); } $self->delete_rooms; unless ($self->valid_room_name($room)){ @@ -492,14 +500,12 @@ get '/(*room)' => sub { } # Now, if the room is password protected and we're not a participant, nor the owner, lets prompt for the password if ($data->{join_password} && (!$self->session($room) || $self->session($room)->{role} !~ m/^participant|owner$/)){ - my $url = $self->url_for('/'); - $url .= ($url =~ m/\/$/) ? '' : '/'; - return $self->redirect_to($url . 'password/' . $room); + return $self->redirect_to($self->get_url('/password') . $room); } # Set this peer as a simple participant if he has no role yet (shouldn't happen) $self->session($room => {role => 'participant'}) if (!$self->session($room) || !$self->session($room)->{role}); # Short life cookie to negociate a session with the signaling server - $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, path => '/'}); # Add this user to the participants table unless($self->add_participant($room,$self->session('name'))){ return $self->render('error', diff --git a/templates/default/error.html.ep b/templates/default/error.html.ep index ba9e5de..e4fb1bf 100644 --- a/templates/default/error.html.ep +++ b/templates/default/error.html.ep @@ -6,13 +6,13 @@

<%= $msg %>

- <%=l 'BACK_TO_MAIN_MENU' %> + <%=l 'BACK_TO_MAIN_MENU' %> <% if ($err eq 'ERROR_NAME_CONFLICT'){ %> - <%=l 'JOIN_THIS_ROOM' %> + <%=l 'JOIN_THIS_ROOM' %> <% } elsif ($err eq 'WRONG_PASSWORD'){ %> - <%=l 'TRY_AGAIN' %> + <%=l 'TRY_AGAIN' %> <% } elsif ($err eq 'ERROR_ROOM_s_LOCKED'){ %> - <%=l 'AUTH_IF_OWNER' %> + <%=l 'AUTH_IF_OWNER' %> <% } %>
diff --git a/templates/default/feedback.html.ep b/templates/default/feedback.html.ep index ad35c94..2c6ee81 100644 --- a/templates/default/feedback.html.ep +++ b/templates/default/feedback.html.ep @@ -3,7 +3,7 @@ %= include 'public_toolbar'
-
+
<%=l 'GIVE_US_YOUR_FEEDBACK' %> diff --git a/templates/default/feedback_thanks.html.ep b/templates/default/feedback_thanks.html.ep index 574e4b5..d8f280a 100644 --- a/templates/default/feedback_thanks.html.ep +++ b/templates/default/feedback_thanks.html.ep @@ -7,7 +7,7 @@

<%=l 'THANK_YOU' %>

<%=l 'THANKS_FOR_YOUR_FEEDBACK' %>

diff --git a/templates/default/goodby.html.ep b/templates/default/goodby.html.ep index 75c9721..0606eff 100644 --- a/templates/default/goodby.html.ep +++ b/templates/default/goodby.html.ep @@ -7,8 +7,8 @@

<%=l 'THANKS_SEE_YOU_SOON' %>

<%=l 'THANKS_FOR_USING' %>

diff --git a/templates/default/index.html.ep b/templates/default/index.html.ep index 9645833..bb8da42 100644 --- a/templates/default/index.html.ep +++ b/templates/default/index.html.ep @@ -9,7 +9,7 @@ <%=l 'CREATE_ROOM' %> - +
diff --git a/templates/default/js_include.html.ep b/templates/default/js_include.html.ep index 275041c..36386c6 100644 --- a/templates/default/js_include.html.ep +++ b/templates/default/js_include.html.ep @@ -1,9 +1,5 @@ <% foreach my $js (qw(simplewebrtc.bundle.js jquery-1.11.1.min.js bootstrap.min.js notify-combined.min.js jquery.browser.min.js sprintf.js diff --git a/templates/default/public_toolbar.html.ep b/templates/default/public_toolbar.html.ep index 4442069..e676f64 100644 --- a/templates/default/public_toolbar.html.ep +++ b/templates/default/public_toolbar.html.ep @@ -15,16 +15,16 @@