word/edit: subpage alias to writer functionality
[sheet.git] / writer.plp
index 05e14659e3fb2769ec44d08a6776f675509e4978..84dc4a8a2b66795ca574173d6e9d96fd6dd6b7d3 100644 (file)
@@ -18,6 +18,7 @@ my $db = eval {
 } or Abort('Database error', 501, $@);
 
 my $user = eval {
+       my $rootpath = ($ENV{REQUEST_URI} // '/writer') =~ s{(?<!^)/.+}{}r;
        if (defined $post{username}) {
                $cookie{login} = EncodeURI(join ':', @post{qw( username pass )});
        }
@@ -26,7 +27,7 @@ my $user = eval {
                if (AddCookie(CGI::Cookie->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);
@@ -71,6 +72,7 @@ my %lang = (
        en => ["\N{REGIONAL INDICATOR SYMBOL LETTER G}\N{REGIONAL INDICATOR SYMBOL LETTER B}", 'english'],
        eo => ['<span style="color:green">★</span>', 'esperanto'],
        ru => ["\N{REGIONAL INDICATOR SYMBOL LETTER R}\N{REGIONAL INDICATOR SYMBOL LETTER U}", 'русский'],
+       la => ["\N{PUSHPIN}", 'latin'],
 );
 my @wordcols = pairkeys
 my %wordcol = (
@@ -172,6 +174,7 @@ elsif (defined $post{form}) {{
                                prio  => undef,
                        );
                        $subrow{wptitle} = $1 if $subrow{form} =~ s/\h*\[(.*)\]$//; # [Link] shorthand
+                       $subrow{alt} = [split m{/}, $1] if $subrow{form} =~ s{/(\S.*)}{}; # /alternates shorthand
                        $db->insert(word => \%subrow);
                        delete $fields{$field};
                }