Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

cssshrink.sh 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/sh
  2. PWD=`dirname "$0"`
  3. JAR_DIR='/tmp'
  4. VERSION='2.4.8'
  5. COMPILER_URL="https://github.com/yui/yuicompressor/releases/download/v${VERSION}/yuicompressor-${VERSION}.zip"
  6. do_shrink() {
  7. rm -f "$2"
  8. java -jar $JAR_DIR/yuicompressor.jar -v -o "$2" "$1"
  9. }
  10. if [ ! -w "$JAR_DIR" ]; then
  11. JAR_DIR=$PWD
  12. fi
  13. if java -version >/dev/null 2>&1; then
  14. :
  15. else
  16. echo "Java not found. Please ensure that the 'java' program is in your PATH."
  17. exit 1
  18. fi
  19. if [ ! -r "$JAR_DIR/yuicompressor.jar" ]; then
  20. if which wget >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
  21. wget "$COMPILER_URL" -O "/tmp/$$.zip"
  22. elif which curl >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
  23. curl "$COMPILER_URL" -o "/tmp/$$.zip"
  24. else
  25. echo "Please download $COMPILER_URL and extract compiler.jar to $JAR_DIR/."
  26. exit 1
  27. fi
  28. (cd $JAR_DIR && unzip "/tmp/$$.zip" && mv "yuicompressor-${VERSION}.jar" "yuicompressor.jar")
  29. rm -f "/tmp/$$.zip"
  30. fi
  31. # compress single file from argument
  32. if [ $# -gt 0 ]; then
  33. CSS_FILE="$1"
  34. echo "Shrinking $CSS_FILE"
  35. minfile=`echo $CSS_FILE | sed -e 's/\.css$/\.min\.css/'`
  36. do_shrink "$CSS_FILE" "$minfile"
  37. exit
  38. fi
  39. DIRS="$PWD/../skins/* $PWD/../plugins/* $PWD/../plugins/*/skins/*"
  40. # default: compress application scripts
  41. for dir in $DIRS; do
  42. for file in $dir/*.css; do
  43. echo "$file" | grep -e '.min.css$' >/dev/null
  44. if [ $? -eq 0 ]; then
  45. continue
  46. fi
  47. if [ ! -f "$file" ]; then
  48. continue
  49. fi
  50. echo "Shrinking $file"
  51. minfile=`echo $file | sed -e 's/\.css$/\.min\.css/'`
  52. do_shrink "$file" "$minfile"
  53. done
  54. done