Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b91eed5

Browse files
committed
Added in a call to Google's closure API, this way we will have less bytes being
sent around the place. The Google closure API removes whitespaces from JS code
1 parent 821fecf commit b91eed5

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

gen-config/gen-sharenice-config.pl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/perl -w
2+
use LWP::UserAgent;
3+
use URI::Escape;
24

35
#Please enter in the domain, without the protocol [http(s)] and without the trailing slash below
46
my $hostedDomain = "sharenice.org";
@@ -46,10 +48,25 @@
4648

4749
close(JSTEMPLATE);
4850

49-
open (OUTPUT, "> ../code.js") || die "sorry cant write to output file : ../code.js\n";
51+
#Get shortended output
52+
my $google = 'http://closure-compiler.appspot.com/compile';
53+
my $ua = LWP::UserAgent->new;
5054

51-
print OUTPUT $output;
55+
my $lame = uri_escape($output);
56+
57+
my $googleres = $ua->post($google,
58+
[ 'js_code' => $output,
59+
'compilation_level' => 'WHITESPACE_ONLY' ,
60+
'output_format' => 'text' ,
61+
'output_info' => 'compiled_code' ]
62+
) ;
63+
die "$google error: ", $googleres->status_line
64+
unless $googleres->is_success;
5265

66+
$output = $googleres->content;
67+
68+
open (OUTPUT, "> ../code.js") || die "sorry cant write to output file : ../code.js\n";
69+
print OUTPUT $output;
5370
close(OUTPUT);
5471

5572
print STDERR "Finished generating new code.js file\n";

0 commit comments

Comments
 (0)