Subversion Repositories wimsdev

Rev

Rev 13084 | Rev 13733 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11480 schaersvoo 1
#!/usr/bin/perl
6236 bpr 2
 
3
use strict "vars";
4
use strict "subs";
5
use locale;
6
use warnings;
13732 bpr 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
 
6236 bpr 27
$/ = undef;
28
##{
29
##  last if (/^$/);
30
##  if  (/^(.*)$/)   { $dir=$1 }
13732 bpr 31
##};
6236 bpr 32
 
33
my $char="---";
34
 
35
for my $f (glob("*/*.css.template")) {
12580 obado 36
  print "\nGeneration de $f";
13732 bpr 37
  my $f1= $f; $f1 =~ s/.template//; my $f2 = "$f1.tmp.css";
8867 bpr 38
  my @f3=split("/",$f1);
39
  my $f3=$f3[0];
13732 bpr 40
  my $TEXT ="/*! generated from $f - do not modify directly */\n";
8867 bpr 41
  my %colors;
6236 bpr 42
  open(IN,"$f");
43
  while (<IN> ) {
13732 bpr 44
   my $line=$_;
45
   $line =~ s/#[^\n]+//g;
46
   $line =~ s/--- (.*) ---/treate($1)/ge;
47
   $TEXT .= $line;
6236 bpr 48
 }
13732 bpr 49
 close IN;
6236 bpr 50
 $TEXT .= "\n";
8867 bpr 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;
8883 bpr 62
 for my $k (keys %{$colors}) {
8867 bpr 63
   $TEXT =~ s/color: *$k/color:$colors{$k}/g;
64
 }
10421 obado 65
 
13732 bpr 66
 out("$f2" ,$TEXT);
8867 bpr 67
 $/ = undef;
7557 obado 68
 system("java -jar yuicompressor $f2 -o $f1 -v; rm $f2");
6236 bpr 69
}
70
 
8867 bpr 71
sub t { my ($c1,$c2,$L)=@_; $L->{$c1}=$c2};
10421 obado 72
 
13732 bpr 73
sub treate { my ($c)= @_;
8757 bpr 74
  return if ((!$c) || ($c =~ /#/));
13084 obado 75
  # print "\ntraitement du fichier $c";
6236 bpr 76
  open(INN, $c);
13732 bpr 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";
6636 bpr 83
};
6236 bpr 84
 
13732 bpr 85
sub out { my ($bloc, $text) = @_;
7565 bpr 86
  open  (OUT, ">$bloc") || warn "Creation du bloc $bloc impossible";
13732 bpr 87
  print OUT $text; close OUT;
7565 bpr 88
}