Added GPL disclaimers, some comments here and there, fixed dev/prod CSS.

This commit is contained in:
TLINDEN
2013-09-15 12:57:30 +02:00
parent b86a74ecf5
commit ae423b6423
28 changed files with 1190 additions and 284 deletions

View File

@@ -1,4 +1,51 @@
#!/usr/bin/perl
#
# This file is part of the digital testament management program
# DigiProof.
#
# By accessing this software, DigiProof, you are duly informed
# of and agree to be bound by the conditions described below in this
# notice:
#
# This software product, DigiProof, is developed by T. Linden and
# copyrighted (C) 2013 by T. Linden, with all rights reserved.
#
# There is no charge for DigiProof software. You can redistribute
# it and/or modify it under the terms of the GNU General Public
# License, which is incorporated by reference herein.
#
# DigiProof is distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS,
# OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE or that
# the use of it will not infringe on any third party's intellectual
# property rights.
#
# You should have received a copy of the GNU General Public License
# along with DigiProof. Copies can also be obtained from:
#
# http://www.gnu.org/licenses/gpl-2.0.html
#
# or by writing to:
#
# Free Software Foundation, Inc.
# Inc., 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301
# USA
#
# Or contact:
#
# "T. Linden" <tlinden@cpan.org>
#
# The sourcecode can be found on:
#
# https://github.com/TLINDEN/digiproof
#
#
# Used to build digiproof-prod.html and digiproof-dev.html
# from source files. It just creates a single html file from
# everything. JS and CSS will bin minified, comments removed,
# src-file and git hash added.
use Data::Dumper;
use JavaScript::Minifier qw(minify);
use CSS::Compressor qw( css_compress );
@@ -38,14 +85,18 @@ foreach (@source) {
}
elsif (/script src="([^"]*)"/) {
my $jsfile = $1;
if ($jsfile =~ /localstorage/) {
$jsfile = "js/libs/localstorage_adapter_$type.js";
if ($jsfile =~ /digiproof/) {
$jsfile = "js/digiproof_$type.js";
}
print STDERR "Inserting $jsfile\n";
print qq(<script type="text/javascript">\n);
print &fetch($jsfile);
print qq(</script>\n);
}
elsif (/GITHASH/) {
my $hash = &githash($index);
print " -- Source: $index, Githash: $hash\n";
}
else {
print qq($_\n);
}
@@ -57,9 +108,10 @@ foreach (@source) {
sub fetch {
my $file = shift;
open F, "<$file" or die "Could not open index: $file $!\n";
my $hash = &githash($file);
if($file =~ /\.js/) {
my $js;
my $from = "/* js from $file */\n";
my $from = "/* js from $file ($hash) */\n";
if ($type eq 'prod') {
$js = minify(input => *F);
# ember.js (and probably others) contain strings which contain </script>
@@ -74,7 +126,7 @@ sub fetch {
}
}
else {
my $from = "/* css from $file */\n";
my $from = "/* css from $file ($hash) */\n";
my $src = join "", <F>;
close F;
if ($prod) {
@@ -85,3 +137,10 @@ sub fetch {
}
}
}
sub githash {
my $file = shift;
my $hash = `git hash-object $file`;
chomp $hash;
return $hash;
}