Subversion Repositories wimsdev

Rev

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