From: Mischa POSLAWSKY Date: Fri, 2 Jul 2021 16:54:30 +0000 (+0200) Subject: word/edit: subpage alias to writer functionality X-Git-Tag: v1.13~185 X-Git-Url: http://git.shiar.net/sheet.git/commitdiff_plain/e24a09c638a103745a9b7b7e557d3222de2d1275 word/edit: subpage alias to writer functionality --- diff --git a/common.inc.plp b/common.inc.plp index dd41751..f7ca700 100644 --- a/common.inc.plp +++ b/common.inc.plp @@ -47,10 +47,10 @@ BEGIN { our $Dev = $ENV{HTTP_HOST} =~ /\bdev\./; } -our $Request = decode_utf8($ENV{PATH_INFO} =~ s{^/}{}r); +our $Request //= decode_utf8($ENV{PATH_INFO} =~ s{^/}{}r); our $style; -our $showkeys = !exists $get{keys} ? undef : +our $showkeys //= !exists $get{keys} ? undef : ($get{keys} ne '0' && ($get{keys} || 'always')); $header{content_type} = 'text/html; charset=utf-8'; diff --git a/word.plp b/word.plp index 493bde9..a7acea5 100644 --- a/word.plp +++ b/word.plp @@ -1,5 +1,10 @@ <(common.inc.plp)><: +if ($Request and $Request =~ s{^edit/?}{}) { + Include 'writer.plp'; + exit; +} + my $lang = $get{lang} || 'en'; my $wordlist = "data/wordlist.$lang.inc.pl"; my $limit = $get{v} // (exists $get{v} ? 4 : 3); diff --git a/writer.plp b/writer.plp index 256a074..84dc4a8 100644 --- a/writer.plp +++ b/writer.plp @@ -18,6 +18,7 @@ my $db = eval { } or Abort('Database error', 501, $@); my $user = eval { + my $rootpath = ($ENV{REQUEST_URI} // '/writer') =~ s{(?new( -name => 'login', -value => '', - -path => '/writer', + -path => $rootpath, -expires => 'now', )->as_string)) { delete $cookie{login}; @@ -46,7 +47,7 @@ my $user = eval { my $httpcookie = CGI::Cookie->new( -name => 'login', -value => join(':', @{$found}{qw( username pass )}), - -path => '/writer', + -path => $rootpath, ) or die "prepared object is empty\n"; AddCookie($httpcookie->as_string); } or Abort(["Unable to create login cookie", $@], 403);