diff --git a/README.md b/README.md index 45c3d3c..42298b2 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Dexter is a Mojolicious webapp that handles the generation of index pages under ## Setup Dexter depends on these Perl modules: * Cwd +* Encode * Readonly * File::Path * File::Spec @@ -35,6 +36,7 @@ Dexter needs to know about two directories you want it to use: ### Other * `$MAX_REQUEST_SIZE`: The maximum size of POST requests that Dexter will process. +* `$FS_ENCODING`: The character encoding that the underlying filesystem uses to store filenames. The default value of `UTF-8` is most likely correct. ## License Dexter is released under Version 3 of the GNU Affero General Public License (see `LICENSE`). The default font- JetBrainsMono from NerdFonts- is released under Version 1.1 of the SIL Open Font License (see `app/public/.assets/FONT-LICENSE`). diff --git a/app/dexter.pl b/app/dexter.pl index 1a8bcab..19b402c 100755 --- a/app/dexter.pl +++ b/app/dexter.pl @@ -4,6 +4,9 @@ use Module::Installed::Tiny qw(module_installed); use Mojolicious::Lite -signatures; +use Encode::Locale; +use Encode; + use Readonly; use Cwd; @@ -34,6 +37,7 @@ Readonly::Hash my %MEANING_OF_HTTP_CODE => ( Readonly my $ROOT_DIRECTORY => 'public'; Readonly my $SOCKET_DIRECTORY => '/var/www/run'; Readonly my $TEMP_DIRECTORY => '/tmp/dexter'; +Readonly my $FS_ENCODING => 'UTF-8'; Readonly my $MAX_REQUEST_SIZE => $GIGABYTE; mkdir $TEMP_DIRECTORY; @@ -469,21 +473,22 @@ sub get_file_with_name ($name) { } my %file = ( - name => $name, - device => $device, - inode => $inode, - mode => $mode, - nlink => $nlink, - uid => $uid, - gid => $gid, - rdev => $rdev, - size => $size, - atime => $atime, - mtime => $mtime, - ctime => $ctime, - blksize => $blksize, - blocks => $blocks, - type => $type, + name => $name, + name_dec => Encode::decode($FS_ENCODING, $name), + device => $device, + inode => $inode, + mode => $mode, + nlink => $nlink, + uid => $uid, + gid => $gid, + rdev => $rdev, + size => $size, + atime => $atime, + mtime => $mtime, + ctime => $ctime, + blksize => $blksize, + blocks => $blocks, + type => $type, ); return \%file; diff --git a/app/templates/index.html.ep b/app/templates/index.html.ep index d8b718b..f3ac339 100644 --- a/app/templates/index.html.ep +++ b/app/templates/index.html.ep @@ -2,14 +2,14 @@ - Index of <%= $c->req->url->path->to_string %> + Index of <%= $c->req->url->path->to_route %>
-

Index of <%= $c->req->url->path->to_string %>

+

Index of <%= $c->req->url->path->to_route %>

@@ -64,8 +64,8 @@ % foreach my $file (@$FILES) {
- - <%= $file->{name} %> + + <%= $file->{name_dec} %> % if ( permission_available_at_path('MOVE', $file->{name}) ) { @@ -73,7 +73,7 @@  ✎ 
- +
@@ -83,7 +83,7 @@  ✖ 
- +
% }