Pārlūkot izejas kodu

- Fixed some variable names
- Commented the code

Daniele Bonini 9 gadi atpakaļ
revīzija
ded1323248
7 mainītis faili ar 1721 papildinājumiem un 0 dzēšanām
  1. 1 0
      .gitignore
  2. 129 0
      CSSMinifier.pl
  3. 132 0
      HTMLMinifier.pl
  4. 210 0
      example.css
  5. 1233 0
      example.html
  6. 7 0
      nbproject/project.properties
  7. 9 0
      nbproject/project.xml

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+/nbproject/private/

+ 129 - 0
CSSMinifier.pl

@@ -0,0 +1,129 @@
+#!/usr/bin/perl
+#
+# CSSMinifer v1.0 
+#
+# The MIT License (MIT)
+#
+# Copyright (c) 2014 Daniele Bonini
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy of 
+# this software and associated documentation files (the "Software"), to deal in the 
+# Software without restriction, including without limitation the rights to use, 
+# copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the 
+# Software, and to permit persons to whom the Software is furnished to do so, subject 
+# to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all 
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
+# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
+# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+use strict;
+use warnings;
+
+print "CSSMinifier v1.0\n";
+print "Copyright 2014 Daniele Bonini. All rights reserved.\n";  
+print "Author: Daniele Bonini\n";
+print "Creation Date: Jun 27th, 2014\n";
+print "Started at ", scalar(localtime), "\n";
+
+# Initialization of the minifier components
+use CSS::Packer;
+
+my $CSSpacker = CSS::Packer->init();
+
+# Check of the arguments passed to the script
+if (! $ARGV[0]) {
+   print "\n\n";
+   print "Invalid argument, source file is required!";
+   print "\n";
+   exit 1;
+}
+my $sourcefile = $ARGV[0];
+
+my $destinationfile;
+if ($ARGV[1]) {
+  $destinationfile = $ARGV[1];
+}
+else {
+  $destinationfile = $sourcefile . "m";
+}
+
+print "Source file: \'", $sourcefile, "\'\n";
+print "Destination file: \'", $destinationfile, "\'\n";
+
+# Check if the source file exists
+if (! -T $sourcefile) {
+   print "\n\n";
+   print "Source file doesn't exist!";
+   print "\n";
+   exit 1;
+}
+
+# Check if the destinaton file exists
+if (-T $destinationfile) {
+   my $replace="";
+   while (($replace ne "Y") && ($replace ne "N")) {
+     print "\n\n";
+     print "Destination file \'$destinationfile\' already exists. Do you want to continue and replace it? (Y/N)\n";
+     chomp($replace=<STDIN>);
+     if (uc($replace) eq "N") {
+       exit 0;
+     }
+     last if (uc($replace) eq "Y");
+   }
+}
+
+my @sourcetexta;
+my $sourcetext;
+my $minifiedtext;
+
+# Read source file
+open(SFILEH, $sourcefile) || die "Error accessing the source file \'$sourcefile\': $!";
+if (! (@sourcetexta=<SFILEH>)) {
+    die "Error reading the source file \'$sourcefile\': $!";
+}
+close(SFILEH);
+
+print "\n";
+print "Processing data..", "\n", "\n";
+
+# Map the array of the source text to a string scalar to align to the 
+# packer->minify method definition requirements
+my $i;
+for( $i=0; $i<=$#sourcetexta; $i=$i+1 ) {
+  $sourcetext.=$sourcetexta[$i];
+}
+
+# Execute the minification
+my $opts = {
+      compress              => "minify",
+      no_compress_comment   => 1,
+    };
+$minifiedtext = $CSSpacker->minify( \$sourcetext, $opts );
+
+# Output the result to the console
+print $minifiedtext, "\n";
+
+# Write the result to the destination file..
+print "\n", "\n";
+print "Saving to \'" . $destinationfile . "\'...", "\n";
+print "\n", "\n";
+
+open(DFILEH, ">$destinationfile") || die "Error creating the destination file \'$destinationfile\': $!";
+if (! print DFILEH $minifiedtext, "\n" ) {
+    die "Error saving the resulting data to \'$destinationfile\': $!";
+}
+close(DFILEH);
+
+# Ending..
+print "\n", "\n";
+print "OK, done!";
+
+exit 0;

+ 132 - 0
HTMLMinifier.pl

@@ -0,0 +1,132 @@
+#!/usr/bin/perl
+#
+# HTMLMinifer v1.0 
+#
+# The MIT License (MIT)
+#
+# Copyright (c) 2014 Daniele Bonini
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy of 
+# this software and associated documentation files (the "Software"), to deal in the 
+# Software without restriction, including without limitation the rights to use, 
+# copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the 
+# Software, and to permit persons to whom the Software is furnished to do so, subject 
+# to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all 
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
+# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
+# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+use strict;
+use warnings;
+
+print "HTMLMinifier v1.0.\n"; 
+print "Copyright 2014 Daniele Bonini. All rights reserved.\n";  
+print "Author: Daniele Bonini\n";
+print "Creation Date: Jun 27th, 2014\n";
+print "Started at ", scalar(localtime), "\n";
+
+# Initialization of the minifier components
+use HTML::Packer;
+
+my $HTMLpacker = HTML::Packer->init();
+
+# Check of the arguments passed to the script
+if (! $ARGV[0]) {
+   print "\n\n";
+   print "Invalid argument, source file is required!";
+   print "\n";
+   exit 1;
+}
+my $sourcefile = $ARGV[0];
+
+my $destinationfile;
+if ($ARGV[1]) {
+  $destinationfile = $ARGV[1];
+}
+else {
+  $destinationfile = $sourcefile . "m";
+}
+
+print "Source file: \'", $sourcefile, "\'\n";
+print "Destination file: \'", $destinationfile, "\'\n";
+
+# Check if the source file exists
+if (! -T $sourcefile) {
+   print "\n\n";
+   print "Source file doesn't exist!";
+   print "\n";
+   exit 1;
+}
+
+# Check if the destinaton file exists
+if (-T $destinationfile) {
+   my $replace="";
+   while (($replace ne "Y") && ($replace ne "N")) {
+     print "\n\n";
+     print "Destination file \'$destinationfile\' already exists. Do you want to continue and replace it? (Y/N)\n";
+     chomp($replace=<STDIN>);
+     if (uc($replace) eq "N") {
+       exit 0;
+     }
+     last if (uc($replace) eq "Y");
+   }
+}
+
+my @sourcetexta;
+my $sourcetext;
+my $minifiedtext;
+
+# Read source file
+open(SFILEH, $sourcefile) || die "Error accessing the source file \'$sourcefile\': $!";
+if (! (@sourcetexta=<SFILEH>)) {
+    die "Error reading the source file \'$sourcefile\': $!";
+}
+close(SFILEH);
+
+print "\n";
+print "Processing data..", "\n", "\n";
+
+# Map the array of the source text to a string scalar to align to the 
+# packer->minify method definition requirements
+my $i;
+for( $i=0; $i<=$#sourcetexta; $i=$i+1 ) {
+  $sourcetext.=$sourcetexta[$i];
+}
+
+# Execute the minification
+my $opts = {
+    remove_comments       => 1,
+    remove_newlines       => 1,
+    do_javascript         => "best",
+    do_stylesheet         => 0,
+    no_compress_comment   => 1,
+  };  
+$minifiedtext = $HTMLpacker->minify( \$sourcetext, $opts );
+
+# Output the result to the console
+print $minifiedtext, "\n";
+
+# Write the result to the destination file..
+print "\n", "\n";
+print "Saving to \'" . $destinationfile . "\'...", "\n";
+print "\n", "\n";
+
+open(DFILEH, ">$destinationfile") || die "Error creating the destination file \'$destinationfile\': $!";
+if (! print DFILEH $minifiedtext, "\n" ) {
+    die "Error saving the resulting data to \'$destinationfile\': $!";
+}
+close(DFILEH);
+
+# Ending..
+print "\n", "\n";
+print "OK, done!";
+
+exit 0;

+ 210 - 0
example.css

@@ -0,0 +1,210 @@
+/* CSS Document */
+body{
+	background-color: #4A5152;
+	min-width: none;
+	margin-right: 0px;
+	min-height: none;
+	margin-top: 0px;
+	margin-left: 0px;
+	margin-bottom: 0px;
+	}
+a{
+	text-decoration:none;
+	}
+img {
+	border: 0;
+	}	
+#tablels{
+	width: 1320px;
+	}
+#divcontainerbody{
+	width: 1348px;
+	}
+#divcontainerbodyin{
+	width: 1348px;
+	margin: 0 auto;
+	}
+#divtopbar {
+	width: 100%;
+	height: 78px;
+	float: right;
+	background-color: #4A5152;
+}
+#divtopbarin {
+    width:884px; 
+	margin-left:auto; 
+	margin-right:auto;
+}
+#imgtopbar {
+	border: 0;
+	}
+#divmenubar {
+	width: 100%;
+	height: 30px;
+	float: right;
+	background-color: #FFFFFF;
+}
+#divmenubarin1 {
+	width: 100%;
+	height: 30px;
+	background-color: #FFFFFF;
+}
+#divmenubarin2 {
+	width: 100%;
+	height: 30px;
+	float: right;
+	background-color: #4A5152;
+	text-align:center;
+	vertical-align:central;
+	position: absolute;
+	visibility:hidden;
+}
+#divtablemenu1 {
+	width: 868px;
+	height: 30px;
+	white-space:nowrap;	
+	margin-left:auto; 
+	margin-right:auto;
+}
+#divtablemenu2 {
+	width: 868px;
+	height: 30px;
+	white-space:nowrap;	
+	margin-left:auto; 
+	margin-right:auto;
+	float: right;
+	background-color: #4A5152;
+	position: absolute;
+	visibility:hidden;
+}
+
+.divmenuvoicedef {
+	float:left;
+	width: 215px;
+	height: 30px;
+	text-align: center;
+	vertical-align:middle;
+	white-space:nowrap;	
+	font-family: Helvetica, Arial, sans-serif;
+	font-size: 12pt;
+	background-color: #FFFFFF;
+	padding-top:3px;
+}
+.divmenuvoiceover {
+	float:left;
+	width: 215px;
+	height: 30px;
+	text-align:center;    
+	vertical-align:super; 
+	white-space:nowrap;	
+	font-family: Helvetica, Arial, sans-serif;
+	font-size: 12pt;
+	background-color: #D6186B;
+	padding-top:3px;
+}
+.divmenuvoicecur {
+	float:left;
+	width: 215px;
+    height: 30px;
+	text-align:center;
+	vertical-align:bottom;
+	white-space:nowrap;	
+	font-family: Helvetica, Arial, sans-serif;
+	font-size: 12pt;
+	background-color: #D6186B;
+	padding-top:3px;
+}
+.amenuvoicedef {
+	color: #D6186B;
+	text-decoration: none;
+}
+.amenuvoiceover {
+	color: #FFFFFF;
+	text-decoration: none;
+}
+.amenuvoicecur {
+	color: #FFFFFF;
+	text-decoration: none;
+}
+#divcontent {
+	width: 100%;
+	height: 640px;
+	float: right;
+	background-color: #4A5152;
+}
+#divcontainercointro{
+	position:absolute;
+	width: 300px;
+	top: 160px;
+    }
+#divcompanyintro{
+	position:relative;
+	left:50px;
+	width:210px;
+	height:300px; 
+	font-family: Helvetica, Arial, sans-serif;
+	font-size:12px;
+	color:#FFFFFF;
+	text-align:left;
+	z-index:1;
+	}
+#spancompanyname{
+	display:inline;
+	}	
+#divwindowcontenthome{ 
+	width:891px; 
+	margin-left:auto; 
+	margin-right:auto;
+	}
+#imgalpsmap{
+	position:relative;
+	top:+40px;
+	}
+#divwindowcontent{
+	margin-left:auto; 
+	margin-right:auto;
+	position: relative;
+	top:+250px;
+	width: 876px;
+	height: 167px;
+	background-color: #DDDDDD;
+	opacity: 0.84;
+	filter: alpha(opacity=84);
+}
+#divwindowcontentin{
+	position:relative; 
+    top:+16px;
+	left:+45px;
+    width:93%;
+	height:100%;
+	font-family: Helvetica, Arial, sans-serif;
+	text-align: left;
+	font-size: 18px;
+	font-weight: 100px;
+	color: #828282;
+}
+#spanplacename{
+	color: #D6186B;
+	font-weight:500;
+	}
+#divfooter {
+	position:absolute;
+	width:100%;
+	top:760px;
+	float:left;
+	}
+#divcontactinfo{
+	margin-left:auto; 
+	margin-right:auto;
+	position:relative;
+	height:30px;
+	font-family: Helvetica, Arial, sans-serif;
+	font-size:11px;
+	text-align:center;
+	white-space:nowrap;
+	z-index:1;
+	color:#FFFFFF
+	}
+#imgrefbackground{
+	display:none;
+	}

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1233 - 0
example.html


+ 7 - 0
nbproject/project.properties

@@ -0,0 +1,7 @@
+include.path=${php.global.include.path}
+php.version=PHP_56
+source.encoding=UTF-8
+src.dir=.
+tags.asp=false
+tags.short=false
+web.root=.

+ 9 - 0
nbproject/project.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+    <type>org.netbeans.modules.php.project</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/php-project/1">
+            <name>HTMLMinifier</name>
+        </data>
+    </configuration>
+</project>

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels