- $HTML::Mason::Commands::r->path_info($path);
-
- # grab the query arguments
- my %args;
- for (split /&/, ($uri->query||'')) {
- my ($k, $v) = /^(.*?)=(.*)$/
- or die "Unable to parse query parameter '$_'";
-
- for ($k, $v) { s/%(..)/chr hex $1/ge }
-
- # no value yet, simple key=value
- if (!exists $args{$k}) {
- $args{$k} = $v;
- }
- # already have key=value, need to upgrade it to key=[value1, value2]
- elsif (!ref($args{$k})) {
- $args{$k} = [$args{$k}, $v];
- }
- # already key=[value1, value2], just add the new value
- else {
- push @{ $args{$k} }, $v;
- }
+ # Try the static handler first for non-Mason CSS, JS, etc.
+ my $res = RT::Interface::Web::Handler->GetStatic($path);
+ if ($res->is_success) {
+ RT->Logger->debug("Fetched '$path' from the static handler");
+ $content = $res->decoded_content;
+ $content_type = $res->headers->content_type;
+ } else {
+ # Try it through Mason instead...
+ $HTML::Mason::Commands::r->path_info($path);
+
+ # grab the query arguments
+ my %args = map { $_ => [ map {Encode::decode("UTF-8",$_)}
+ $uri->query_param($_) ] } $uri->query_param;
+ # Convert empty and single element arrayrefs to a non-ref scalar
+ @$_ < 2 and $_ = $_->[0]
+ for values %args;
+
+ $RT::Logger->debug("Running component '$path'");
+ $content = RunComponent($path, %args);
+
+ $content_type = $HTML::Mason::Commands::r->content_type;