%# Parts that positively cannot be assembled in improper order will be.
% if ($out =~ /empty_archives/) {
<&|/l&>The archive is currently empty.&>
% }
% if (!$RT::Guest) {
<&|/l&>Post an article&>
% }
% $action =~ s/^\s*\|\s*//;
<% $action |n %>
% if ($out !~ /empty_archives/) {
% }
<%INIT>
our ($Get, $Post, $ua, $wws);
use Encode;
my $args = { map { $_ => Encode::encode_utf8($ARGS{$_}) } grep /^[_a-z]/, keys %ARGS };
$args->{quiet} = 1;
$RT::BaseURL = "/Foundry/Project/Forum/List.html";
my $out;
my $action;
my $list_name = $1 if $r->path_info =~ m{/wws/[^/]+/([^/]+)};
$session{LastListName} = $list_name ||= $session{LastListName};
if ($r->path_info =~ m{^/wws(.*)}) {
    require URI;
    my $url = URI->new('http:');
    $url->query_form(%$args, not_a_sniffer => 1);
    $out = $Get->("$1?" . $url->query);
    if ($m->notes('RV') =~ m{^\s*()\s*$}m) {
	$action = " | $1";
	$action =~ s{\bHREF="(/wws[^>]*>)}{HREF="$RT::BaseURL$1}gi;
	$action =~ s/onClick=".*?"//;
    }
    if ($r->path_info =~ m{^/wws/arc/}) {
	# Guess encoding for inline attachments without an explicit charset
	$out =~ s{
	    ((?:[\x80-\xff](?:[\x40-\xff]|[\x80-\xff][\x80-\xff]))+)
	}{
	    my $raw = Encode::encode('latin1', $1);
	    my $rv;
	    eval { $rv = Encode::decode('utf8', $raw, Encode::FB_CROAK()); 1 }
	      or eval { $rv = Encode::decode('big5', $raw, Encode::FB_CROAK()); 1 }
	      or $rv = $raw;
	    $rv;
	}exg;
    }
}
else {
    $out = $Post->( "", scalar $m->request_args );
}
my $PostURL = $1 if ($out =~ m{HREF="([^"]+/compose_mail/[^"]+)"});
unless ($out =~ s/.*//s) {
    $m->comp('/Foundry/Project/Forum/index.html', Queue => 1, %ARGS);
}
%INIT>