diff --git a/README.md b/README.md index 248bc20..e7e5991 100644 --- a/README.md +++ b/README.md @@ -181,9 +181,7 @@ server { # If you want to log the remote port of the image senders, you'll need that proxy_set_header X-Remote-Port $remote_port; - # Lutim reads this header and understands that the current session is actually HTTPS. - # Enable it if you run a HTTPS server (in this case, don't forgot to change the listen port above) - #proxy_set_header X-Forwarded-Proto https; + proxy_set_header X-Forwarded-Proto $scheme; # We expect the downsteam servers to redirect to the right hostname, so don't do any rewrites here. proxy_redirect off; @@ -191,6 +189,8 @@ server { } ``` +If you use Lutim under a subdirectory like `/lutim/`, change the `prefix` configuration option and prefix the nginx locations with `/lutim` (or whatever you choose). + ## Cron jobs Lutim have commands which can be used in cron jobs. diff --git a/lib/Lutim.pm b/lib/Lutim.pm index d574bd9..f113094 100644 --- a/lib/Lutim.pm +++ b/lib/Lutim.pm @@ -65,8 +65,8 @@ sub startup { $headers->add('Content-Disposition' => $dl.';filename='.$filename); $c->res->content->headers($headers); - $c->app->log->debug($key); if ($key) { + $c->app->log->debug($key); $asset = $c->decrypt($key, $path); } else { $asset = Mojo::Asset::File->new(path => $path); @@ -78,19 +78,6 @@ sub startup { } ); - $self->helper( - index_url => sub { - my $c = shift; - my $to_abs = shift; - - my $url = $c->url_for('index'); - $url = $url->to_abs() if (defined($to_abs) && $to_abs); - - $url =~ s#([^/])$#$1/#; - return $url; - } - ); - $self->helper( ip => sub { my $c = shift; diff --git a/lib/Mounter.pm b/lib/Mounter.pm index 4956688..ac977a0 100644 --- a/lib/Mounter.pm +++ b/lib/Mounter.pm @@ -13,12 +13,16 @@ sub startup { { file => File::Spec->catfile($Bin, '..' ,'lutim.conf'), default => { - url_sub_dir => '/' + prefix => '/' } } ); - $self->plugin('Mount' => {$config->{url_sub_dir} => File::Spec->catfile($Bin, '..', 'script', 'application')}); + $config->{prefix} = $config->{url_sub_dir} if (defined($config->{url_sub_dir}) && $config->{prefix} eq '/'); + + $self->app->log->warn('"url_sub_dir" configuration option is deprecated. Use "prefix" instead. "url_sub_dir" will be removed in the future') if (defined($config->{url_sub_dir})); + + $self->plugin('Mount' => {$config->{prefix} => File::Spec->catfile($Bin, '..', 'script', 'application')}); } 1; diff --git a/lutim.conf.template b/lutim.conf.template index f0c2906..52af1fb 100644 --- a/lutim.conf.template +++ b/lutim.conf.template @@ -99,9 +99,9 @@ # URL sub-directory in which you want Lutim to be accessible # example: you want to have Lutim under https://example.org/lutim/ - # => set url_sub_dir to '/lutim' or to '/lutim/', it doesn't matter + # => set prefix to '/lutim' or to '/lutim/', it doesn't matter # optional, defaut is / - #url_sub_dir => '/', + #prefix => '/', ########################## # Lutim cron jobs settings diff --git a/templates/about.html.ep b/templates/about.html.ep index 511597c..a86c3e2 100644 --- a/templates/about.html.ep +++ b/templates/about.html.ep @@ -7,7 +7,7 @@

<%= l('Drag and drop an image in the appropriate area or use the traditional way to send files and Lutim will provide you four URLs. One to view the image, an other to directly download it, one you can use on social networks and a last to delete the image when you want.') %>

<%= l('You can, optionally, request that the image(s) posted on Lutim to be deleted at first view (or download) or after the delay selected from those proposed.') %>

<%= l('Is it really free (as in free beer)?') %>

-

<%== l('Yes, it is! On the other side, if you want to support the developer, you can do it via Flattr or with BitCoin.', url_for('index')->to_abs()) %>

+

<%== l('Yes, it is! On the other side, if you want to support the developer, you can do it via Flattr or with BitCoin.', url_for('/')->to_abs()) %>

<%= l('Is it really anonymous?') %>

<%= l('Yes, it is! On the other side, for legal reasons, your IP address will be stored when you send an image. Don\'t panic, it is normally the case of all sites on which you send files!') %>

<%= l('The IP address of the image\'s sender is retained for a delay which depends of the administrator\'s choice (for the official instance, which is located in France, it\'s one year).') %>

@@ -36,5 +36,5 @@
  • Laura Arjona Reina (https://wiki.debian.org/LauraArjona), <%= l('spanish translation') %> - <%= link_to url_for('index') => ( class => "btn btn-primary btn-lg" ) => begin %><%= l('Back to homepage') %><% end%> + <%= link_to url_for('/') => ( class => "btn btn-primary btn-lg" ) => begin %><%= l('Back to homepage') %><% end%> diff --git a/templates/index.html.ep b/templates/index.html.ep index 122ff20..2425725 100644 --- a/templates/index.html.ep +++ b/templates/index.html.ep @@ -15,9 +15,9 @@ % }
    % # Display image informations - % my $url = index_url(1).stash('short'); + % my $url = url_for('/'.stash('short'))->to_abs(); <%= stash('filename') %> -    <%= l('Tweet it!') %> +