Various fixes in path handling when using language suffix

master
Daniel Berteaud 11 years ago
parent 596ef48dcb
commit f55d6cf092
  1. 24
      public/vroom.pl
  2. 8
      templates/default/error.html.ep
  3. 2
      templates/default/feedback.html.ep
  4. 2
      templates/default/feedback_thanks.html.ep
  5. 4
      templates/default/goodby.html.ep
  6. 2
      templates/default/index.html.ep
  7. 6
      templates/default/js_include.html.ep
  8. 8
      templates/default/public_toolbar.html.ep

@ -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',

@ -6,13 +6,13 @@
<h2<%=l 'ERROR_OCCURED' %></h2>
<p><%= $msg %></p>
<div class="btn-group">
<a class="btn btn-primary btn-lg" role="button" href="<%= $self->url_for('/') %>"><%=l 'BACK_TO_MAIN_MENU' %></a>
<a class="btn btn-primary btn-lg" role="button" href="<%= $self->get_url('/') %>"><%=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>
<a class="btn btn-default btn-lg" role="button" href="<%= $self->get_url('/') . $room %>"><%=l 'JOIN_THIS_ROOM' %></a>
<% } elsif ($err eq 'WRONG_PASSWORD'){ %>
<a class="btn btn-default btn-lg" role="button" href="<%= $self->url_for('/password') . '/' . $room %>"><%=l 'TRY_AGAIN' %></a>
<a class="btn btn-default btn-lg" role="button" href="<%= $self->get_url('/password') . '/' . $room %>"><%=l 'TRY_AGAIN' %></a>
<% } elsif ($err eq 'ERROR_ROOM_s_LOCKED'){ %>
<a class="btn btn-default btn-lg" role="button" href="<%= $self->url_for('/password') . '/' . $room %>"><%=l 'AUTH_IF_OWNER' %></a>
<a class="btn btn-default btn-lg" role="button" href="<%= $self->get_url('/password') . '/' . $room %>"><%=l 'AUTH_IF_OWNER' %></a>
<% } %>
</div>
</div>

@ -3,7 +3,7 @@
%= include 'public_toolbar'
<div class="container-fluid">
<div id="feedbackFormContainer" class="well">
<form role="form" action="<%=url_for('/feedback')%>" method="post">
<form role="form" action="<%= $self->get_url('/feedback') %>" method="post">
<legend>
<center>
<%=l 'GIVE_US_YOUR_FEEDBACK' %>

@ -7,7 +7,7 @@
<h2><%=l 'THANK_YOU' %></h2>
<p><%=l 'THANKS_FOR_YOUR_FEEDBACK' %></p>
<div class='btn-group'>
<a class="btn btn-primary btn-lg" role="button" href="<%= $self->url_for('/') %>"><%=l 'BACK_TO_MAIN_MENU' %></a>
<a class="btn btn-primary btn-lg" role="button" href="<%= $self->get_url('/') %>"><%=l 'BACK_TO_MAIN_MENU' %></a>
</div>
</div>
</div>

@ -7,8 +7,8 @@
<h2><%=l 'THANKS_SEE_YOU_SOON' %></h2>
<p><%=l 'THANKS_FOR_USING' %></p>
<div class='btn-group'>
<a class="btn btn-primary btn-lg" role="button" href="<%= $self->url_for('/') %>"><%=l 'BACK_TO_MAIN_MENU' %></a>
<a class="btn btn-default btn-lg" role="button" href="<%= $self->url_for('/feedback') %>"><%=l 'GIVE_US_YOUR_FEEDBACK' %></a>
<a class="btn btn-primary btn-lg" role="button" href="<%= $self->get_url('/') %>"><%=l 'BACK_TO_MAIN_MENU' %></a>
<a class="btn btn-default btn-lg" role="button" href="<%= $self->get_url('/feedback') %>"><%=l 'GIVE_US_YOUR_FEEDBACK' %></a>
</div>
</div>
</div>

@ -9,7 +9,7 @@
<%=l 'CREATE_ROOM' %>
</center>
</h2>
<form id="createRoom" class="form-inline" action="<%= $self->url_for('/create') %>" method="post">
<form id="createRoom" class="form-inline" action="<%= $self->get_url('/create') %>" method="post">
<fieldset>
<div class="control-group">
<div class="input-group input-group-lg">

@ -1,9 +1,5 @@
<script type="text/javascript">
<%
my $url = $self->url_for('/');
$url .= ($url =~ m/\/$/) ? '' : '/';
%>
var rootUrl = '<%= $url %>';
var rootUrl = '<%= $self->get_url('/'); %>';
</script>
<% 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

@ -15,16 +15,16 @@
<div class="collapse navbar-collapse" id="toolBar">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="<%= $self->url_for('/') %>"><%=l 'HOME' %></a>
<a href="<%= $self->get_url('/') %>"><%=l 'HOME' %></a>
</li>
<li>
<a href="<%= $self->url_for('/help') %>"><%=l 'HELP' %></a>
<a href="<%= $self->get_url('/help') %>"><%=l 'HELP' %></a>
</li>
<li>
<a href="<%= $self->url_for('/about') %>"><%=l 'ABOUT' %></a>
<a href="<%= $self->get_url('/about') %>"><%=l 'ABOUT' %></a>
</li>
<li>
<a href="<%= $self->url_for('/feedback') %>"><%=l 'FEEDBACK' %></a>
<a href="<%= $self->get_url('/feedback') %>"><%=l 'FEEDBACK' %></a>
</li>
</ul>
</div>

Loading…
Cancel
Save