Skip to content

Commit

Permalink
add analytics for upload to http://andrew-jones.com
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrjones committed Aug 22, 2010
1 parent acaf8e4 commit 0d3bdc6
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions build/build.pl
Expand Up @@ -10,8 +10,25 @@
our $VERSION = "0.1";

my $f = File::Util->new();
my @args = @ARGV;

given($ARGV[0]){
# analytics for upload to http://andrew-jones.com/
my $piwik = <<'PIWIK';
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://analytics.andrew-jones.com/" : "http://analytics.andrew-jones.com/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 3);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://analytics.andrew-jones.com/piwik.php?idsite=3" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tag -->
PIWIK

given(shift @args){
when("minify"){
# minifies the js and css using CPAN modules
minify();
Expand All @@ -27,7 +44,7 @@
build();
}
default{
say "usage: $0 <minify|convert|build>";
say "usage: $0 <minify|convert|build[--upload]>";
exit(0);
}
}
Expand Down Expand Up @@ -93,6 +110,8 @@ sub convert {
}

sub build {
my $upload = grep(/^--upload$/, @args);

my $tmp = "$Bin/tmp";
if( -d $tmp ){
remove_dir($tmp);
Expand All @@ -115,6 +134,17 @@ sub build {
or die "Copy failed: $!";
}

# extra stuff for uploading to http://andrew-jones.com
if( $upload ){
my $index = "$tmp/jquery-placeholder-plugin/index.htm";
my($file) = $f->load_file($index);

# add analytics
$file =~ s!</body>!$piwik</body>!g;

$f->write_file('file' => $index, 'content' => $file, mode => 'trunc');
}

chdir $tmp;
`zip jquery-placeholder-plugin-$VERSION.zip jquery-placeholder-plugin/*`;
say "created jquery-placeholder-plugin-$VERSION.zip";
Expand Down

0 comments on commit 0d3bdc6

Please sign in to comment.