I use an applescript
--tell application "Safari" to set s to source of document 1 tell application "Safari" to do JavaScript "document.body.outerHTML;" in first document set s to the result set filename to random number from 1 to 10000
set the temp_file to ((path to the temporary items folder) as string) & filename & ".html" open for access temp_file with write permission write s to (temp_file as alias) as string close temp_file
set f to POSIX path of temp_file set command to "~/bin/tm -a '" & f & "'" do shell script command
On 9/23/05, Andreas Wahlin andreaswahlin@bredband.net wrote:
How can I get my "user" accont, I want it to save to ~/Desktop/ but I tried that and it didn't work ...
Andreas
On Sep 20, 2005, at 19:44 , Fred B. wrote:
On 20 sept. 05, at 18:57, Eric Peden wrote:
On Tue, Sep 20, 2005 at 01:47:49PM +0200, José Campos wrote:
Is it yet, or will it be possible to get a item like this in Safari->Services : "Edit page source in TextMate"?
Did you see this?
http://comox.textdrive.com/pipermail/textmate/2005-September/005718.html
You could use the AppleScript menu to get an actual menu item for it, as opposed to just having a keystroke. At that point, the only difference between the AppleScript solution and a service would be which menu it appeared on. ;)
Here is a more sophisticated version, it saves the source of the front page of Safari in a temp folder then opens it in TM. If there is no window in Safari or if it's empty, it warns you. If the name of the page contains slashs, it replaces them with colons.
There's maybe better ways to achieve that, but that's I come up with after encountering numerous problems. AS is useful but can really suck!
*tell* application "Safari" *if* *not* (exists document 1) *then* display dialog "You need to open a web location first!" buttons {"OK"} default button 1 *return* *end* *if* *set* mySource *to* *the* source *of* *front* document *as* text *if* (length *of* mySource *is* 0) *then* display dialog "You need to open a web location first!" buttons {"OK"} default button 1 *return* *end* *if* *set* myName *to* name *of* *front* document *as* text *end* *tell*
*try* *tell* application "TextMate" *to* activate
*set* myName *to* replace_chars(myName, "http://", "") *set* myName *to* replace_chars(myName, "/", ":")
*if* (myName *ends with* ".html") *or* (myName *ends with* ".htm") *then* *set* myPath *to* "/tmp/" & myName *else* *set* myPath *to* "/tmp/" & myName & ".html" *end* *if*
do shell script "rm -f " & quoted form *of* myPath do shell script "echo " & quoted form *of* mySource & " >> " & quoted form *of* myPath do shell script "open -a TextMate " & quoted form *of* myPath *end* *try*
*on* replace_chars(this_text, search_string, replacement_string) *set* AppleScript's text item delimiters *to* *the* search_string *set* *the* item_list *to* *every* text item *of* this_text *set* AppleScript's text item delimiters *to* *the* replacement_string *set* this_text *to* *the* item_list *as* string *set* AppleScript's text item delimiters *to* "" *return* this_text *end* replace_chars
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate