[Jifty-commit] r1207 - in jifty/trunk: lib/Jifty share/web/templates/__jifty/css

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu Jun 8 01:48:01 EDT 2006


Author: trs
Date: Thu Jun  8 01:48:00 2006
New Revision: 1207

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Web.pm
   jifty/trunk/share/web/templates/__jifty/css/dhandler

Log:
 r12777 at zot:  tom | 2006-06-08 01:47:30 -0400
 Better choices for DevelMode and generating the CSS (though the cache doesn't work at the moment because Jifty->web is not persistant across requests)


Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm	(original)
+++ jifty/trunk/lib/Jifty/Web.pm	Thu Jun  8 01:48:00 2006
@@ -21,7 +21,8 @@
 use vars qw/$SERIAL/;
 
 __PACKAGE__->mk_accessors(
-    qw(next_page request response session temporary_current_user cached_css cached_css_digest)
+    qw(next_page request response session temporary_current_user
+       cached_css cached_css_digest cached_css_mtime)
 );
 
 =head1 METHODS
@@ -977,14 +978,22 @@
 =cut
 
 sub include_css {
-    my $self = shift;
+    my $self      = shift;
     
-    $self->generate_css;
+    if ( Jifty->config->framework('DevelMode') ) {
+        Jifty->web->out(
+            '<link rel="stylesheet" type="text/css" '
+            . 'href="/static/css/main.css" />'
+        );
+    }
+    else {
+        $self->generate_css;
     
-    Jifty->web->out(
-        '<link rel="stylesheet" type="text/css" href="/__jifty/css/'
-        . $self->cached_css_digest . '.css" />'
-    );
+        Jifty->web->out(
+            '<link rel="stylesheet" type="text/css" href="/__jifty/css/'
+            . $self->cached_css_digest . '.css" />'
+        );
+    }
     
     return '';
 }
@@ -999,17 +1008,19 @@
 sub generate_css {
     my $self = shift;
     
-    if (not $self->cached_css_digest
+    if (not defined $self->cached_css_digest
             or Jifty->config->framework('DevelMode'))
     {
-        $self->cached_css(
-            CSS::Squish->concatenate(
-                Jifty->config->framework('Web')->{'StaticRoot'}
-                    . '/css/main.css'
-            )
-        );
+        Jifty->log->info("Generating CSS...");
+        
+        my $css = CSS::Squish->concatenate(
+                        Jifty->config->framework('Web')->{'StaticRoot'}
+                            . '/css/main.css'
+                  );
         
-        $self->cached_css_digest( md5_hex( $self->cached_css ) );
+        $self->cached_css( $css );
+        $self->cached_css_digest( md5_hex( $css ) );
+        $self->cached_css_mtime( time );
     }
 }
 

Modified: jifty/trunk/share/web/templates/__jifty/css/dhandler
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/css/dhandler	(original)
+++ jifty/trunk/share/web/templates/__jifty/css/dhandler	Thu Jun  8 01:48:00 2006
@@ -1,6 +1,11 @@
 <%init>
 $r->content_type("text/css");
 Jifty->web->generate_css;
+
+use HTTP::Date qw();
+$r->header_out('Last-Modified'
+                    => HTTP::Date::time2str( Jifty->web->cached_css_mtime ));
+
 Jifty->web->out( Jifty->web->cached_css );
 return;
 </%init>


More information about the Jifty-commit mailing list