Subversion Repositories wimsdev

Rev

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