From e24a09c638a103745a9b7b7e557d3222de2d1275 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Fri, 2 Jul 2021 18:54:30 +0200 Subject: [PATCH] word/edit: subpage alias to writer functionality --- common.inc.plp | 4 ++-- word.plp | 5 +++++ writer.plp | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) 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); -- 2.30.0