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
How can I get my "user" accont, I want it to save to~/Desktop/but I tried that and it didn't work ...AndreasOn 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 inSafari->Services : "Edit page source in TextMate"?Did you see this?You could use the AppleScript menu to get an actual menu item for it, asopposed to just having a keystroke. At that point, the only differencebetween the AppleScript solution and a service would be which menu itappeared 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) thendisplay dialog "You need to open a web location first!" buttons {"OK"} default button 1returnend ifset mySource to the source of front document as textif (length of mySource is 0) thendisplay dialog "You need to open a web location first!" buttons {"OK"} default button 1returnend ifset myName to name of front document as textend telltrytell application "TextMate" to activateset myName to replace_chars (myName, "http://", "")set myName to replace_chars(myName, "/", ":")if (myName ends with ".html") or (myName ends with ".htm") thenset myPath to "/tmp/" & myNameelseset myPath to "/tmp/" & myName & ".html"end ifdo shell script "rm -f " & quoted form of myPathdo shell script "echo " & quoted form of mySource & " >> " & quoted form of myPathdo shell script "open -a TextMate " & quoted form of myPathend tryon replace_chars(this_text, search_string, replacement_string)set AppleScript's text item delimiters to the search_stringset the item_list to every text item of this_textset AppleScript's text item delimiters to the replacement_stringset this_text to the item_list as stringset AppleScript's text item delimiters to ""return this_textend replace_chars______________________________________________________________________For new threads USE THIS: textmate@lists.macromates.com(threading gets destroyed and the universe will collapse if you don't)
______________________________________________________________________
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