|
Revision 4196, 1.3 kB
(checked in by takayama, 3 months ago)
|
|
* Set svn keywords
|
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | |
|---|
| 6 | my $copyright; |
|---|
| 7 | my $year = (localtime(time))[5] + 1900; |
|---|
| 8 | |
|---|
| 9 | if (($ENV{BUILD_PACKAGE} || 'MTOS') ne 'MTOS') { |
|---|
| 10 | $copyright = "Movable Type (r) (C) 2001-$year Six Apart, Ltd. All Rights Reserved"; |
|---|
| 11 | } else { |
|---|
| 12 | $copyright = "Movable Type (r) Open Source (C) 2001-$year Six Apart, Ltd."; |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | my %types = ( |
|---|
| 16 | css => 'CSS::Minifier', |
|---|
| 17 | js => 'JavaScript::Minifier', |
|---|
| 18 | ); |
|---|
| 19 | |
|---|
| 20 | my $file = shift or die "Usage $0 <file>\n"; |
|---|
| 21 | die "File not found: $file\n" unless ( -e $file ); |
|---|
| 22 | |
|---|
| 23 | my ( $ext ) = ( $file =~ m/\.(.*)$/ ); |
|---|
| 24 | |
|---|
| 25 | unless ( defined $ext && exists( $types{ lc( $ext ) } ) ) { |
|---|
| 26 | die "$0 can only handle filetypes: ".join( ',', keys %types ); |
|---|
| 27 | } else { |
|---|
| 28 | $ext = lc( $ext ); |
|---|
| 29 | eval( "use $types{$ext} qw( minify )" ); |
|---|
| 30 | if ( $@ ) { |
|---|
| 31 | # don't die here, so it won't interrupt make |
|---|
| 32 | warn sprintf( "WARNING, %s FILES CAN'T BE MINIFIED, %s IS NOT INSTALLED, skipped\n", $ext, $types{$ext} ); |
|---|
| 33 | exit 0; |
|---|
| 34 | } |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | open( INFILE, $file ) or die $!; |
|---|
| 38 | my $data = join( '', <INFILE> ); |
|---|
| 39 | close( INFILE ); |
|---|
| 40 | |
|---|
| 41 | open( OUTFILE, '>', $file ) or die $!; |
|---|
| 42 | print OUTFILE minify( |
|---|
| 43 | input => $data, |
|---|
| 44 | copyright => qq|$copyright |
|---|
| 45 | * This file is combined from multiple sources. Consult the source files for their |
|---|
| 46 | * respective licenses and copyrights. |
|---|
| 47 | |, |
|---|
| 48 | ); |
|---|
| 49 | close( OUTFILE ); |
|---|
| 50 | |
|---|
| 51 | exit 0; |
|---|