FREN

#FF00AA


31 août 2011

Making LESS Useful

I’ve already posted about my web development workflow, and the bit of AppleScript that lets me upload the local file I’m editing to its rightful place on the web server by hitting a simple hotkey in TextWrangler.

But there was a problem with this: it made a pain of using the awesome LESS.app (which allows you such awesome and simple things as defining a color in a variable in the beginning of your CSS file and using it a bunch of times, so you only have to change the value once if you want to make adustments — just as an example among a bunch of more elaborate stuff). Since I was editing the .less file and I wanted to upload the compiled .css file rather than the file I was editing, my workflow just didn’t work. As a result, I just didn’t use LESS unless the benefit was really huge.

That’s until I finally realized I could automate that process, too — AppleScript should be powerful enough to automatically detect that I’m trying to upload a .less file, and then work with the .css instead, shouldn’t it? And I should be able to make it do that, right?

 

So, here goes the updated script:

set fileName to ""

 

tell application "TextWrangler"

save document 1 of window 1

set fileName to (file of document 1 of window 1) as string

end tell

 

set AppleScript’s text item delimiters to "."

if fileName contains "." then

set {fileBasename, fileExtension} to {text 1 thru text item -2, text item -1} of fileName

else

set {fileBasename, fileExtension} to {fileName, ""}

end if

 

if fileExtension is "less" then set fileName to fileBasename & ".css"

 

ignoring application responses

tell application "Transmit"

open fileName

end tell

end ignoring

 

Reminder: for this to work, you have to set up your favorites in Transmit with “DockSend” enabled — that’s the bit of magic that makes Transmit upload a file where it belongs on your server depending on where it is on your local hard drive.

Vous voulez savoir quand je poste du contenu sur mon blog ? Il suffit de vous inscrire gratuitement à un agrégateur RSS (Feedly, NewsBlur, Inoreader, …) et d'ajouter www.ff00aa.com à vos flux (ou www.garoo.net pour vous abonner à tous les sujets). On n'a pas besoin de newsletters, pas besoin de Twitter, le RSS existe toujours.

Mentions légales : ce blog est hébergé par OVH, 2 rue Kellermann, 59100 Roubaix, France, www.ovhcloud.com.

Les données des visiteurs de ce blog ne sont pas utilisées ni transmises à des tiers. Les posteurs de commentaires peuvent demander leur suppression par e-mail.

Tous contenus © de l'auteur ou couverts par le droit de citation.