Changeset 609 in genapp
- Timestamp:
- Jan 23, 2016, 12:11:13 PM (6 years ago)
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
bin/genapp.pl
r599 r609 875 875 `$cmd`; 876 876 } 877 # include_additional_files 878 foreach my $k ( keys %include_additional_files ) { 879 my $fo = "output/$l/" . $include_additional_files{ $k }; 880 $warn .= "duplicate output for $fo\n" if $created{ $fo }++; 881 mkdir_for_file( $fo ); 882 my $cmd = "cp $k $fo\n"; 883 $created .= "$fo\n"; 884 `$cmd`; 885 } 886 877 887 # copy over add/* 878 888 if ( -d "$gap/languages/$l/add" ) -
etc/perl/genapp_util.pl
r599 r609 201 201 undef %global_file_replace_cache; 202 202 undef %global_file_replace_style_cache; 203 undef %include_additional_files; 203 204 204 205 sub replace_file_json_walk { … … 250 251 if ( $type =~ /^(doc|docx)$/ ) { 251 252 # print "now include as html from abiword\n"; 252 my $uf = $f; 253 $uf =~ s/ /\\ /g; 253 my $uf = $file; 254 $file =~ s/\.json$//; 255 $file =~ s/^.*\///; 256 my $cmd = "doc2html.pl $file '$f'\n"; 257 print $cmd; 254 258 my $fh; 255 open $fh, " abiword --to=html --to-name=fd://1 --exp-props='html-markup: html4; html-images: embed' $uf 2> /dev/null |" || die "$0: error reading include file $f\n";259 open $fh, "doc2html.pl $file '$f' |"; 256 260 my @l = <$fh>; 257 261 close $fh; 258 my $res = join '', @l; 259 ( my $style ) = $res =~ /<style type="text\/css">((.|\n)*)<\/style>/m; 260 ( my $body ) = $res =~ /<body>((.|\n)*)<\/body>/m; 262 263 my $od = $l[ 0 ]; 264 chomp $od; 265 my $utag = $l[ 1 ]; 266 chomp $utag; 267 print "od is '$od'\nutag is '$utag'\n"; 268 269 open $fh, "$od/$utag.html"; 270 my @l = <$fh>; 271 close $fh; 272 my $body = join '', @l; 273 274 open $fh, "$od/$utag.css"; 275 my @l = <$fh>; 276 close $fh; 277 my $style = join '', @l; 278 279 if ( -e "$od/${utag}_files" ) { 280 my @fs = `cd $od/${utag}_files; ls -1`; 281 grep chomp, @fs; 282 grep s/^/${utag}_files\//, @fs; 283 # print join "\n", @fs; 284 # print "\n"; 285 foreach my $k ( @fs ) { 286 $include_additional_files{ "$od/$k" } = "files/$k"; 287 $body =~ s/$k/files\/$k/g; 288 } 289 #foreach my $k ( keys %include_additional_files ) { 290 # print "\$include_additional_files{ $k } = $include_additional_files{$k}\n"; 291 #} 292 } 293 261 294 # escape single quotes, remove newlines 262 295 $body =~ s/'/\\'/g; … … 266 299 $global_file_replace_cache{ $f } = $body; 267 300 $global_file_replace_cache_style{ $file } .= $style; 301 302 # print "style is:----------------------------------------\n$style\n----------------------------------------\n"; 303 # print "body is:----------------------------------------\n$body\n----------------------------------------\n"; 304 305 if ( !length( $global_file_replace_cache{ $f } ) ) { 306 $warn .= "Included file $f appears to be empty after abiword processing\n"; 307 } 308 309 if ( 0 ) { # old way 310 my $uf = $f; 311 $uf =~ s/ /\\ /g; 312 my $fh; 313 open $fh, "abiword --to=html --to-name=fd://1 --exp-props='html-markup: html4; html-images: embed' $uf 2> /dev/null |" || die "$0: error reading include file $f\n"; 314 my @l = <$fh>; 315 close $fh; 316 my $res = join '', @l; 317 ( my $style ) = $res =~ /<style type="text\/css">((.|\n)*)<\/style>/m; 318 ( my $body ) = $res =~ /<body>((.|\n)*)<\/body>/m; 319 # escape single quotes, remove newlines 320 $body =~ s/'/\\'/g; 321 $body =~ s/\n/ /g; 322 $style =~ s/'/\\'/g; 323 $style =~ s/\n/ /g; 324 $global_file_replace_cache{ $f } = $body; 325 $global_file_replace_cache_style{ $file } .= $style; 268 326 # print "style is:\n$style\n"; 269 327 # print "in walk global_file_replace_cache_style:\n" . Dumper( %global_file_replace_cache_style ); 270 $$hash{ $k } = $body; 271 if ( !length( $global_file_replace_cache{ $f } ) ) { 272 $warn .= "Included file $f appears to be empty after abiword processing\n"; 328 $$hash{ $k } = $body; 329 if ( !length( $global_file_replace_cache{ $f } ) ) { 330 $warn .= "Included file $f appears to be empty after abiword processing\n"; 331 } 273 332 } 274 333 }
Note: See TracChangeset
for help on using the changeset viewer.