Changeset 455 for veekun/branches

Show
Ignore:
Timestamp:
08/26/08 01:44:56 (19 months ago)
Author:
eevee
Message:

Changed stylesheet templates to spit out single static versions on app startup, rather than being generated on every damn request. (#361)

Location:
veekun/branches/layout2
Files:
2 added
1 removed
3 modified

Legend:

Unmodified
Added
Removed
  • veekun/branches/layout2/lib/Vee.pm

    r440 r455  
    66use warnings; 
    77 
     8use File::Path; 
    89use Image::Size; 
    910use LWP::UserAgent; 
     
    105106} 
    106107 
     108{ 
     109    ### Generate static stylesheets 
     110 
     111    # Old hack for IE6 that I no longer care about in the fluff CSS 
     112    my $glass_sub = sub { "url(/images/bg-fade.png) $_[0] fixed left bottom no-repeat" }; 
     113    my $tmpl_dir   = Vee->path_to('templates', 'style'); 
     114    my $static_dir = Vee->path_to('root', 'style'); 
     115    opendir my($dh), $tmpl_dir; 
     116    while (my $style = readdir $dh) { 
     117        next if $style =~ /^[.]/; 
     118        next if not -d "$tmpl_dir/$style"; 
     119 
     120        # Load the list of colors 
     121        my $colors_file = "$tmpl_dir/$style/colors.yml"; 
     122        next if not -f $colors_file; 
     123        my $sheet_colors = eval { YAML::LoadFile($colors_file) }; 
     124        if ($@) { 
     125            warn "Error loading colors for $style style: $@"; 
     126            next; 
     127        } 
     128 
     129        for my $colorscheme (keys %{$sheet_colors}) { 
     130            mkpath("$static_dir/$style/$colorscheme"); 
     131            for my $file (glob("$tmpl_dir/$style/*.tt")) { 
     132                (my $filename = $file) =~ s{.*/}{}smx; 
     133                (my $filename_css = $filename) =~ s{tt \z}{css}smx; 
     134                Vee->view->template->process( 
     135                    "style/$style/$filename", { 
     136                        skip_wrapper     => 1, 
     137                        glass_background => $glass_sub, 
     138                        %{ $sheet_colors->{$colorscheme} }, 
     139                    }, 
     140                    "$static_dir/$style/$colorscheme/$filename_css", 
     141                ); 
     142            } 
     143        } 
     144    } 
     145    closedir $dh; 
     146 
     147} 
     148 
    107149=head1 METHODS 
    108150 
  • veekun/branches/layout2/root/style

    • Property svn:ignore set to
      fluff
      slick
  • veekun/branches/layout2/templates/wrapper.tt

    r453 r455  
    1313<link rel="shortcut icon" type="image/png" href="/images/favicon.png"/> 
    1414<link rel="stylesheet" type="text/css" href="/style/reset.css"/> 
    15 <link rel="stylesheet" type="text/css" href="/style/slick/blue/global"/> 
     15<link rel="stylesheet" type="text/css" href="/style/slick/blue/global.css"/> 
    1616[% FOREACH css IN extra_css %] 
    17 <link rel="stylesheet" type="text/css" href="/style/slick/blue/[% css %]"/> 
     17<link rel="stylesheet" type="text/css" href="/style/slick/blue/[% css %].css"/> 
    1818[% END %] 
    1919[% extra_headers.join("\n") %]