Subversion Repositories wimsdev

Rev

Rev 13733 | Rev 13738 | 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.  
  8. my $wimsconf="../../log/wims.conf";
  9. my $wimsdefault="../../public_html/bases/sys/defaults.conf";
  10. my %listcolor;
  11. open(IN, "$wimsconf");
  12. while (<IN>) {
  13.   chomp;
  14.   for my $t ("ref_bgcolor","ref_button_bgcolor","ref_button_help_bgcolor" ) {
  15.     if (/$t/) { $listcolor{$t}=$_; $listcolor{$t} =~ s/$t=//;}
  16.   }
  17. };
  18. close(IN);
  19. open(IN, "$wimsdefault");
  20. while (<IN>) {
  21.   for  my $t ("ref_bgcolor","ref_button_bgcolor","ref_button_help_bgcolor" ) {
  22.     if (/$t/ && !$listcolor{$t}) {
  23.       $listcolor{$t}=$_; $listcolor{$t} =~ s/DF_$t=//;}
  24.   }
  25. };
  26. close(IN);
  27.  
  28. $/ = undef;
  29. ##{
  30. ##  last if (/^$/);
  31. ##  if  (/^(.*)$/)   { $dir=$1 }
  32. ##};
  33.  
  34. my $char="---";
  35.  
  36. for my $f (glob("*/*.css.template")) {
  37.   print "\nGeneration de $f";
  38.   my $f1= $f; $f1 =~ s/.template//; my $f2 = "$f1.tmp.css";
  39.   my @f3=split("/",$f1);
  40.   my $f3=$f3[0];
  41.   my $TEXT ="/*! generated from $f - do not modify directly */\n";
  42.   my %colors;
  43.   open(IN,"$f");
  44.   while (<IN> ) {
  45.    my $line=$_;
  46.    $line =~ s/#[^\n]+//g;
  47.    $line =~ s/--- (.*) ---/treate($1)/ge;
  48.    $TEXT .= $line;
  49.  }
  50.  close IN;
  51.  $TEXT .= "\n";
  52.  # lecture de oefcolors
  53.  my $fc="$f3/oefcolors";
  54.  if (!(-e $fc)) { $fc="oefcolors" };
  55.  open(INN, "$fc");
  56.  $/ = "\n";
  57.  while(<INN>) {
  58.   if( /!set (\w+)=(\w+)/) { $colors{$1}=$2;}
  59.  }
  60.  close INN;
  61.  ## remplacement des couleurs oef
  62.  my $colors=\%colors;
  63.  for my $k (keys %{$colors}) {
  64.    $TEXT =~ s/color: *$k/color:$colors{$k}/g;
  65.  }
  66.  
  67.  out("$f2" ,$TEXT);
  68.  $/ = undef;
  69.  system("java -jar yuicompressor $f2 -o $f1 -v; rm $f2");
  70. }
  71.  
  72. sub t { my ($c1,$c2,$L)=@_; $L->{$c1}=$c2};
  73.  
  74. sub treate { my ($c)= @_;
  75.   return if ((!$c) || ($c =~ /#/));
  76.   # print "\ntraitement du fichier $c";
  77.   open(INN, $c);
  78.   my $text = <INN>;
  79.   close(INN);
  80.   for my $a (keys %listcolor){
  81.     $text=~ s/__wims_$a/$listcolor{$a}/g;
  82.   }
  83.   "\n/*! from $c */\n$text";
  84. };
  85.  
  86. sub out { my ($bloc, $text) = @_;
  87.   open  (OUT, ">$bloc") || warn "Creation du bloc $bloc impossible";
  88.   print OUT $text; close OUT;
  89. }
  90.