[Rt-commit] r11145 - in rt/branches/3.8-TESTING: . html/NoAuth/js
jesse at bestpractical.com
jesse at bestpractical.com
Thu Mar 20 17:14:05 EDT 2008
Author: jesse
Date: Thu Mar 20 17:14:05 2008
New Revision: 11145
Modified:
rt/branches/3.8-TESTING/ (props changed)
rt/branches/3.8-TESTING/html/NoAuth/css/autohandler
rt/branches/3.8-TESTING/html/NoAuth/js/autohandler
Log:
r28461 at 31b: jesse | 2008-03-20 17:11:10 -0400
* made it possible to serve out images and other non-canonical datatypes from within css and js packages
Modified: rt/branches/3.8-TESTING/html/NoAuth/css/autohandler
==============================================================================
--- rt/branches/3.8-TESTING/html/NoAuth/css/autohandler (original)
+++ rt/branches/3.8-TESTING/html/NoAuth/css/autohandler Thu Mar 20 17:14:05 2008
@@ -47,7 +47,31 @@
%# END BPS TAGGED BLOCK }}}
<%init>
RT::Interface::Web::StaticFileHeaders();
-$r->content_type('text/css');
+my $type;
+my $file = $m->base_comp->source_file;
+
+if ($file =~ /\.(gif|png|jpe?g)$/i) {
+ $type = "image/$1";
+ $type =~ s/jpg/jpeg/gi;
+
+
+die "file $file not found" unless -f $file && -r _;
+
+$r->content_type($type);
+open my $fh, "<$file" or die "couldn't open file: $!";
+binmode($fh);
+{
+ local $/ = \16384;
+ $m->out($_) while (<$fh>);
+ $m->flush_buffer;
+}
+close $fh;
+$m->abort;
+} else {
+
+$r->content_type('text/css') ;
$m->call_next();
return();
+}
+
</%init>
Modified: rt/branches/3.8-TESTING/html/NoAuth/js/autohandler
==============================================================================
--- rt/branches/3.8-TESTING/html/NoAuth/js/autohandler (original)
+++ rt/branches/3.8-TESTING/html/NoAuth/js/autohandler Thu Mar 20 17:14:05 2008
@@ -47,7 +47,30 @@
%# END BPS TAGGED BLOCK }}}
<%init>
&RT::Interface::Web::StaticFileHeaders();
-$r->content_type('application/x-javascript');
-$m->call_next();
-return();
+
+my $type;
+my $file = $m->base_comp->source_file;
+
+if ($file =~ /\.(gif|png|jpe?g)$/i) {
+ $type = "image/$1";
+ $type =~ s/jpg/jpeg/gi;
+
+
+die "file $file not found" unless -f $file && -r _;
+
+$r->content_type($type);
+open my $fh, "<$file" or die "couldn't open file: $!";
+binmode($fh);
+{
+ local $/ = \16384;
+ $m->out($_) while (<$fh>);
+ $m->flush_buffer;
+}
+close $fh;
+$m->abort;
+} else {
+ $r->content_type('application/x-javascript');
+ $m->call_next();
+ return();
+}
</%init>
More information about the Rt-commit
mailing list