Subversion Repositories wimsdev

Rev

Rev 8883 | Rev 11480 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #!/usr/bin/perl
  2.  
  3. use strict "vars";
  4. use strict "subs";
  5. use locale;
  6. use warnings;
  7. $/ = undef;
  8.  
  9. ##{
  10. ##  last if (/^$/);
  11. ##  if  (/^(.*)$/)   { $dir=$1 }
  12. ##} ;
  13.  
  14. my $char="---";
  15.  
  16. for my $f (glob("*/*.css.template")) {
  17.   my $f1= $f ; $f1 =~ s/.template// ; my $f2 = "$f1.tmp.css" ;
  18.   my @f3=split("/",$f1);
  19.   my $f3=$f3[0];
  20.   my $TEXT ="/*! generated from $f - do not modify directly */\n" ;
  21.   my %colors;
  22.   open(IN,"$f");
  23.   while (<IN> ) {
  24.    my $line=$_ ;
  25.    $line =~ s/#[^\n]+//g ;
  26.    $line =~ s/--- (.*) ---/treate($1)/ge ;
  27.    $TEXT .= $line ;
  28.  }
  29.  close IN ;
  30.  $TEXT .= "\n";
  31.  # lecture de oefcolors
  32.  my $fc="$f3/oefcolors";
  33.  if (!(-e $fc)) { $fc="oefcolors" };
  34.  open(INN, "$fc");
  35.  $/ = "\n";
  36.  while(<INN>) {
  37.   if( /!set (\w+)=(\w+)/) { $colors{$1}=$2;}
  38.  }
  39.  close INN;
  40.  ## remplacement des couleurs oef
  41.  my $colors=\%colors;
  42.  for my $k (keys %{$colors}) {
  43.    $TEXT =~ s/color: *$k/color:$colors{$k}/g;
  44.  }
  45.  
  46.  out("$f2" ,$TEXT) ;
  47.  $/ = undef;
  48.  system("java -jar yuicompressor $f2 -o $f1 -v; rm $f2");
  49. }
  50.  
  51. sub t { my ($c1,$c2,$L)=@_; $L->{$c1}=$c2};
  52.  
  53. sub treate { my ($c)= @_ ;
  54.   return if ((!$c) || ($c =~ /#/));
  55.   open(INN, $c);
  56.   my $text = <INN> ;
  57.   close(INN) ;
  58.   "\n/*! from $c */\n$text" ;
  59. };
  60.  
  61. sub out { my ($bloc, $text) = @_ ;
  62.   open  (OUT, ">$bloc") || warn "Creation du bloc $bloc impossible";
  63.   print OUT $text ; close OUT ;
  64. }
  65.