[Jifty-commit] r1190 - in jifty/trunk: lib/Jifty
share/web/templates/__jifty share/web/templates/__jifty/css
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Wed Jun 7 18:07:47 EDT 2006
Author: trs
Date: Wed Jun 7 18:07:44 2006
New Revision: 1190
Added:
jifty/trunk/share/web/templates/__jifty/css/
jifty/trunk/share/web/templates/__jifty/css/dhandler
- copied, changed from r1186, /jifty/trunk/share/web/templates/__jifty/styles.css
Removed:
jifty/trunk/share/web/templates/__jifty/styles.css
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Web.pm
Log:
r12762 at zot: tom | 2006-06-07 18:06:33 -0400
The generated one-file CSS is now memory-cached in Jifty::Web and is requested
based on a digest of the content
Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm (original)
+++ jifty/trunk/lib/Jifty/Web.pm Wed Jun 7 18:07:44 2006
@@ -14,12 +14,14 @@
use Jifty::Everything;
use CGI::Cookie;
use XML::Writer;
+use CSS::Squish;
+use Digest::MD5 qw(md5_hex);
use base qw/Class::Accessor::Fast Jifty::Object/;
use vars qw/$SERIAL/;
__PACKAGE__->mk_accessors(
- qw(next_page request response session temporary_current_user)
+ qw(next_page request response session temporary_current_user cached_css cached_css_digest)
);
=head1 METHODS
@@ -974,8 +976,38 @@
=cut
sub include_css {
- Jifty->web->out('<link rel="stylesheet" type="text/css" href="/__jifty/styles.css" />');
+ my $self = shift;
+
+ $self->generate_css;
+
+ Jifty->web->out(
+ '<link rel="stylesheet" type="text/css" href="/__jifty/css/'
+ . $self->cached_css_digest . '.css" />'
+ );
+
return '';
}
+=head3 generate_css
+
+Checks if the compressed CSS is generated, and if it isn't, generates
+and caches it.
+
+=cut
+
+sub generate_css {
+ my $self = shift;
+
+ if (not $self->cached_css_digest) {
+ $self->cached_css(
+ CSS::Squish->concatenate(
+ Jifty->config->framework('Web')->{'StaticRoot'}
+ . '/css/main.css'
+ )
+ );
+
+ $self->cached_css_digest( md5_hex( $self->cached_css ) );
+ }
+}
+
1;
Copied: jifty/trunk/share/web/templates/__jifty/css/dhandler (from r1186, /jifty/trunk/share/web/templates/__jifty/styles.css)
==============================================================================
--- /jifty/trunk/share/web/templates/__jifty/styles.css (original)
+++ jifty/trunk/share/web/templates/__jifty/css/dhandler Wed Jun 7 18:07:44 2006
@@ -1,11 +1,6 @@
<%init>
-use CSS::Squish;
-
$r->content_type("text/css");
-
-Jifty->web->out(
- CSS::Squish->concatenate(
- Jifty->config->framework('Web')->{StaticRoot} . "/css/main.css"
- )
-);
+Jifty->web->generate_css;
+Jifty->web->out( Jifty->web->cached_css );
+return;
</%init>
More information about the Jifty-commit
mailing list