Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: arthurfurlan/minify-media
base: 572eccfe5c
...
head fork: arthurfurlan/minify-media
compare: 66f6a0e083
  • 4 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
BIN  src/googleclosure.jar
Binary file not shown
View
76 src/minify.sh
@@ -1,9 +1,11 @@
#!/bin/bash
#
+# written by Arthur Furlan <afurlan@mecasar.com>
# written by Osvaldo Santana <osantana@triveos.com>
-# by Arthur Furlan <afurlan@mecasar.com>
-YUICOMPRESS="yuicompressor-2.4.6.jar"
+YUICOMPRESSOR="yuicompressor.jar"
+GOOGLECLOSURE="googleclosure.jar"
+GZIP="1"
if [ $# -lt 1 ]; then
echo "Usage: $0 BASEDIR"
@@ -44,6 +46,20 @@ is_file_minified() {
fi
}
+## check if the file should be statically gziped
+gzip_compressor() {
+ [ $# -lt 1 ] && return 0
+
+ FILE="$1"
+ DEST="${FILE}.gz"
+
+ ## check if this feature is enabled
+ if [ "$GZIP" = "1" ]; then
+ gzip -c "${FILE}" > "${DEST}"
+ touch "${DEST}" -r "${FILE}"
+ fi
+}
+
## minify all modified files under $BASEDIR
BASEDIR=$1
find "$BASEDIR" -type f | egrep -v '\.min\.' | while read FILE; do
@@ -53,7 +69,7 @@ find "$BASEDIR" -type f | egrep -v '\.min\.' | while read FILE; do
case "$TYPE" in
- css|js)
+ js)
DEST="${NAME}.min.${TYPE}"
## check if the file needs to be minified
@@ -62,11 +78,54 @@ find "$BASEDIR" -type f | egrep -v '\.min\.' | while read FILE; do
## create the new (and minified) version
echo "Compressing: ${DEST}"
- java -jar "${YUICOMPRESS}" "${FILE}" > "${DEST}"
+ java -jar "${GOOGLECLOSURE}" --js "${FILE}" --compilation_level SIMPLE_OPTIMIZATIONS > "${DEST}"
## check if the minified file really is smaller
is_file_minified "$FILE" "$DEST"
[ "$?" = "0" ] || cp "$FILE" "$DEST"
+
+ ## check if the file should be also compressed using gzip
+ gzip_compressor "$DEST"
+ ;;
+
+ css)
+ DEST="${NAME}.min.${TYPE}"
+
+ ## check if the file needs to be minified
+ is_file_modified "$FILE" "$DEST"
+ [ "$?" = "1" ] || continue
+
+ ## create the new (and minified) version
+ echo "Compressing: ${DEST}"
+ java -jar "${YUICOMPRESSOR}" "${FILE}" > "${DEST}"
+
+ ## check if the minified file really is smaller
+ is_file_minified "$FILE" "$DEST"
+ [ "$?" = "0" ] || cp "$FILE" "$DEST"
+
+ ## check if the file should be also compressed using gzip
+ gzip_compressor "$DEST"
+ ;;
+
+ less)
+ DEST="${NAME}.min.css"
+
+ ## check if the file needs to be minified
+ is_file_modified "$FILE" "$DEST"
+ [ "$?" = "1" ] || continue
+
+ ## create the new (and minified) version
+ echo "Compressing: ${DEST}"
+ lessc "${FILE}" --yui-compress > "${DEST}"
+
+ ## less files cannot use the same rule of copying
+ ## the original file over the destination file if
+ ## the minified version was bigger than the original
+ ## because the less syntax could not be a valid css
+ ## syntax
+
+ ## check if the file should be also compressed using gzip
+ gzip_compressor "$DEST"
;;
png)
@@ -85,6 +144,9 @@ find "$BASEDIR" -type f | egrep -v '\.min\.' | while read FILE; do
## check if the minified file really is smaller
is_file_minified "$FILE" "$DEST"
[ "$?" = "0" ] || cp "$FILE" "$DEST"
+
+ ## check if the file should be also compressed using gzip
+ gzip_compressor "$DEST"
;;
jpg|jpeg)
@@ -102,6 +164,9 @@ find "$BASEDIR" -type f | egrep -v '\.min\.' | while read FILE; do
## check if the minified file really is smaller
is_file_minified "$FILE" "$DEST"
[ "$?" = "0" ] || cp "$FILE" "$DEST"
+
+ ## check if the file should be also compressed using gzip
+ gzip_compressor "$DEST"
;;
gif)
@@ -118,6 +183,9 @@ find "$BASEDIR" -type f | egrep -v '\.min\.' | while read FILE; do
## check if the minified file really is smaller
is_file_minified "$FILE" "$DEST"
[ "$?" = "0" ] || cp "$FILE" "$DEST"
+
+ ## check if the file should be also compressed using gzip
+ gzip_compressor "$DEST"
;;
xml)
View
BIN  src/yuicompressor.jar
Binary file not shown

No commit comments for this range

Something went wrong with that request. Please try again.