Subversion Repositories wimsdev

Rev

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