package Ernad::Css; use strict; use warnings; use Carp qw(confess); use Data::Dumper; use Ernad::Erimp; use Krichel::File; sub file { my $do_test=shift; our $e=$main::e or confess "I have no erimp."; my $impna=$e->{'impna'}; if(not defined($impna)) { confess "I need the impna\n"; } ## make sure we have an css_dir my $css_dir=$e->{'dir'}->{'css'} // confess "I need a css_dir."; if(not -d $css_dir) { mkpath($css_dir); } ## the output file to write to my $out_file=$e->{'dir'}->{'css'}."/$impna.css"; if(not -f $out_file) { system("touch $out_file"); } if(not -w $out_file) { confess "I have no permission to write $out_file"; } if($do_test) { $out_file=$e->{'dir'}->{'css'}."/$impna.test.css"; } ## looking for the input my $style_dir=$e->{'dir'}->{'style'}; ## the CSS file name, typically css.xml my $css_file_name=$e->{'const'}->{'css_file'}.$e->{'const'}->{'xml_ext'}; my $css_file=$style_dir.'/'.$css_file_name; if(not -f $css_file) { die "I can't find the file css file $css_file."; } &Krichel::File::prepare($out_file); my $out=$e->{'t'}->t($css_file,$e->{'const'}->{'make_css_file'},$out_file); if($out) { return $out_file; } return ''; } 1;