Transmit: Minify js + css mit YUI-Compressor.jar

Für Textmate (zumindest für die 1er Version) gibt es ein Plug-In zum minimieren von Javascript und Stylesheet Dateien, welches auf Basis von Yahoo’s yuicompressor die Zeilenumbrüche herausfiltert…
Praktisch aber auch etwas umständlich vom handling. Und Smaller kostet gesalzene 20$.
Deshalb hier meine eigene Quick&Dirty Lösung zum Minimieren von .js und .css Dateien in Transmit:
Datei ausfwählen -> wird geladen -> minimiert und als _min. wieder ins gleiche Verzeichnis geladen.

set tmp to path to "temp"
set tmp_posix to POSIX path of tmp
set myyui to path to resource "yuicompressor-2.4.7.jar"
set myyui_posix to POSIX path of myyui
tell application "Transmit"
  tell current tab of document 1
    tell remote browser
      repeat with thisItem in selected browser items
        set currentName to name of thisItem
        download item at path (get path of thisItem) to tmp_posix with resume mode overwrite
      end repeat
    end tell
  end tell
end tell

tell application "Finder"
  set this to (item currentName of tmp) as alias
  set this_type to ""
  set this_name to name of this
  if (this_name as text) ends with ".css" then
    set this_type to "css"
    set this_name to (characters 1 through -5 of this_name) as text
  else if (this_name as text) ends with ".js" then
    set this_type to "js"
    set this_name to (characters 1 through -4 of this_name) as text
  else
    ##        display alert (this_name)
  end if
  
  if this_type ≠ "" then
    set this_posix to POSIX path of this
    set this_folder to (do shell script "dirname " & quoted form of this_posix) & "/"
    set mycommand to "java -jar " & quoted form of myyui_posix & " --nomunge --type " & this_type & " " & quoted form of this_posix & " > " & quoted form of this_folder & quoted form of this_name & "_min." & this_type
    do shell script mycommand
  end if
end tell

tell application "Transmit"
  tell current tab of document 1
    tell remote browser
      upload item at path tmp_posix & this_name & "_min." & this_type to (get root path)
    end tell
  end tell
end tell

									


Der Code ist der eines Skript-Bundles in dem sich das YUI-Compressor.jar auch befindet… am besten direkt alles laden
[Download not found]

Leave a Reply