[Rt-commit] r17491 - in rt/3.8/branches/3.8.2-releng: lib/RT/Interface share/html/NoAuth/RichText share/html/NoAuth/js

falcone at bestpractical.com falcone at bestpractical.com
Wed Dec 31 12:17:59 EST 2008


Author: falcone
Date: Wed Dec 31 12:17:59 2008
New Revision: 17491

Modified:
   rt/3.8/branches/3.8.2-releng/lib/RT/Interface/Web.pm
   rt/3.8/branches/3.8.2-releng/share/html/NoAuth/RichText/dhandler
   rt/3.8/branches/3.8.2-releng/share/html/NoAuth/css/web2/images/dhandler
   rt/3.8/branches/3.8.2-releng/share/html/NoAuth/js/autohandler

Log:
* document SendStaticFile and use it in more of the *handlers

Modified: rt/3.8/branches/3.8.2-releng/lib/RT/Interface/Web.pm
==============================================================================
--- rt/3.8/branches/3.8.2-releng/lib/RT/Interface/Web.pm	(original)
+++ rt/3.8/branches/3.8.2-releng/lib/RT/Interface/Web.pm	Wed Dec 31 12:17:59 2008
@@ -239,6 +239,14 @@
 
 =head2 SendStaticFile 
 
+Takes a File => path and a Type => Content-type
+
+If Type isn't provided and File is an image, it will
+figure out a sane Content-type, otherwise it will
+send application/octet-stream
+
+Will set caching headers using StaticFileHeaders
+
 =cut
 
 sub SendStaticFile {

Modified: rt/3.8/branches/3.8.2-releng/share/html/NoAuth/RichText/dhandler
==============================================================================
--- rt/3.8/branches/3.8.2-releng/share/html/NoAuth/RichText/dhandler	(original)
+++ rt/3.8/branches/3.8.2-releng/share/html/NoAuth/RichText/dhandler	Wed Dec 31 12:17:59 2008
@@ -51,8 +51,6 @@
 my $file = dirname($m->current_comp->source_file) . '/FCKeditor/' . $arg;
 return $m->decline unless -f $file && -r _;
 
-&RT::Interface::Web::StaticFileHeaders();
-
 my $suffix = $1 if $file =~ /([^.]+)$/;
 
 my $type = {qw(
@@ -65,14 +63,7 @@
     png     image/png
 )}->{$suffix} || 'application/octet-stream';
 
-$r->content_type($type);
-open my $fh, '<:utf8', $file or die "couldn't open file: $!";
-binmode($fh);
-{
-    local $/ = \16384;
-    $m->out($_) while (<$fh>);
-    $m->flush_buffer;
-}
-close $fh;
+RT::Interface::Web->SendStaticFile( File => $file, Type => $type );
+
 $m->abort;
 </%INIT>

Modified: rt/3.8/branches/3.8.2-releng/share/html/NoAuth/css/web2/images/dhandler
==============================================================================
--- rt/3.8/branches/3.8.2-releng/share/html/NoAuth/css/web2/images/dhandler	(original)
+++ rt/3.8/branches/3.8.2-releng/share/html/NoAuth/css/web2/images/dhandler	Wed Dec 31 12:17:59 2008
@@ -1,25 +1,8 @@
 <%INIT>
-&RT::Interface::Web::StaticFileHeaders();
 use File::Basename;
 my $arg = $m->dhandler_arg;
 my $file = dirname($m->current_comp->source_file) . '/source/'. $arg;
+RT::Interface::Web->SendStaticFile( File => $file );
 
-my $type = "application/octet-stream";
-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;
 </%INIT>

Modified: rt/3.8/branches/3.8.2-releng/share/html/NoAuth/js/autohandler
==============================================================================
--- rt/3.8/branches/3.8.2-releng/share/html/NoAuth/js/autohandler	(original)
+++ rt/3.8/branches/3.8.2-releng/share/html/NoAuth/js/autohandler	Wed Dec 31 12:17:59 2008
@@ -46,29 +46,14 @@
 %# 
 %# END BPS TAGGED BLOCK }}}
 <%init>
-&RT::Interface::Web::StaticFileHeaders();
 
 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;
+    RT::Interface::Web->SendStaticFile( File => $file );
 } else {
+    &RT::Interface::Web::StaticFileHeaders();
     $r->content_type('application/x-javascript');
     $m->call_next();
     return();


More information about the Rt-commit mailing list