<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: View Generated Source in Safari</title>
	<atom:link href="http://www.thebusygeek.com/2008/11/view-generated-source-in-safari/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thebusygeek.com/2008/11/view-generated-source-in-safari/</link>
	<description>Where's my coffee?</description>
	<pubDate>Mon, 06 Feb 2012 08:49:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Kirch</title>
		<link>http://www.thebusygeek.com/2008/11/view-generated-source-in-safari/#comment-291</link>
		<dc:creator>Kirch</dc:creator>
		<pubDate>Mon, 01 Nov 2010 19:10:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.thebusygeek.com/?p=69#comment-291</guid>
		<description>I'm not too familiar with AppleScript either, but I found another script from Ben Alman (link below) to view source in Textmate. Might be a bit overkill (creates a temp file with page title, etc.), but I used your variables to view the generated source. Seems to work.

http://benalman.com/projects/safari-view-source-in-textmate/


global jsCode
global htmlSource
set jsCode to "document.documentElement.outerHTML"
tell application "Safari"
	set src to (do JavaScript jsCode in front document)
	set location to URL of document 1
end tell


set file_name to do shell script "echo " &#38; quoted form of location &#38; " &#124; perl -pe 's/^.*\\/\\/[^\\/]+.*\\/([^?#]*).*$/$1/'"
set file_base to do shell script "echo " &#38; quoted form of file_name &#38; " &#124; perl -pe 's/\\.[^.]*$//'"
set file_ext to do shell script "echo " &#38; quoted form of file_name &#38; " &#124; perl -pe 's/^(?:[^.]*\\.?&#124;.*\\.(.*))$/$1/'"

if file_base is "" then set file_base to "file"

set extensions_to_keep to "js css txt html"
if (" " &#38; extensions_to_keep &#38; " ") does not contain (" " &#38; file_ext &#38; " ") then set file_ext to "html"

set tmp to (do shell script "mktemp -d /tmp/textmate.XXXXXX") &#38; "/" &#38; file_base &#38; "." &#38; file_ext



try
	
	set handle to POSIX file tmp
	
	open for access handle with write permission
	
	write src to handle
	
	close access handle
	
on error
	
	do shell script "curl " &#38; quoted form of location &#38; " -o " &#38; quoted form of tmp
	
end try
tell application "TextMate"
	activate
	open tmp
end tell</description>
		<content:encoded><![CDATA[<p>I&#8217;m not too familiar with AppleScript either, but I found another script from Ben Alman (link below) to view source in Textmate. Might be a bit overkill (creates a temp file with page title, etc.), but I used your variables to view the generated source. Seems to work.</p>
<p><a href="http://benalman.com/projects/safari-view-source-in-textmate/" rel="nofollow">http://benalman.com/projects/safari-view-source-in-textmate/</a></p>
<p>global jsCode<br />
global htmlSource<br />
set jsCode to &#8220;document.documentElement.outerHTML&#8221;<br />
tell application &#8220;Safari&#8221;<br />
	set src to (do JavaScript jsCode in front document)<br />
	set location to URL of document 1<br />
end tell</p>
<p>set file_name to do shell script &#8220;echo &#8221; &amp; quoted form of location &amp; &#8221; | perl -pe &#8217;s/^.*\\/\\/[^\\/]+.*\\/([^?#]*).*$/$1/&#8217;&#8221;<br />
set file_base to do shell script &#8220;echo &#8221; &amp; quoted form of file_name &amp; &#8221; | perl -pe &#8217;s/\\.[^.]*$//&#8217;&#8221;<br />
set file_ext to do shell script &#8220;echo &#8221; &amp; quoted form of file_name &amp; &#8221; | perl -pe &#8217;s/^(?:[^.]*\\.?|.*\\.(.*))$/$1/&#8217;&#8221;</p>
<p>if file_base is &#8220;&#8221; then set file_base to &#8220;file&#8221;</p>
<p>set extensions_to_keep to &#8220;js css txt html&#8221;<br />
if (&#8221; &#8221; &amp; extensions_to_keep &amp; &#8221; &#8220;) does not contain (&#8221; &#8221; &amp; file_ext &amp; &#8221; &#8220;) then set file_ext to &#8220;html&#8221;</p>
<p>set tmp to (do shell script &#8220;mktemp -d /tmp/textmate.XXXXXX&#8221;) &amp; &#8220;/&#8221; &amp; file_base &amp; &#8220;.&#8221; &amp; file_ext</p>
<p>try</p>
<p>	set handle to POSIX file tmp</p>
<p>	open for access handle with write permission</p>
<p>	write src to handle</p>
<p>	close access handle</p>
<p>on error</p>
<p>	do shell script &#8220;curl &#8221; &amp; quoted form of location &amp; &#8221; -o &#8221; &amp; quoted form of tmp</p>
<p>end try<br />
tell application &#8220;TextMate&#8221;<br />
	activate<br />
	open tmp<br />
end tell</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://www.thebusygeek.com/2008/11/view-generated-source-in-safari/#comment-290</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Wed, 07 Jul 2010 22:09:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.thebusygeek.com/?p=69#comment-290</guid>
		<description>Thanks a lot... worked perfectly!</description>
		<content:encoded><![CDATA[<p>Thanks a lot&#8230; worked perfectly!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clint</title>
		<link>http://www.thebusygeek.com/2008/11/view-generated-source-in-safari/#comment-258</link>
		<dc:creator>Clint</dc:creator>
		<pubDate>Wed, 29 Apr 2009 17:02:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.thebusygeek.com/?p=69#comment-258</guid>
		<description>Just wanted to say thx. I did the same 'just google it' method, and yours was the first result. Worked like a charm.</description>
		<content:encoded><![CDATA[<p>Just wanted to say thx. I did the same &#8216;just google it&#8217; method, and yours was the first result. Worked like a charm.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

