<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: HAML Caching CGI</title>
	<atom:link href="http://blog.kesor.net/2007/07/30/haml-caching-cgi/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.kesor.net/2007/07/30/haml-caching-cgi/</link>
	<description>Making technology about computers, and computers about usability.</description>
	<lastBuildDate>Mon, 30 Aug 2010 06:59:47 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Charlie Smurthwaite</title>
		<link>http://blog.kesor.net/2007/07/30/haml-caching-cgi/comment-page-1/#comment-168</link>
		<dc:creator>Charlie Smurthwaite</dc:creator>
		<pubDate>Mon, 30 Aug 2010 06:59:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.kesor.net/2007/07/30/haml-caching-cgi/#comment-168</guid>
		<description>I had a similar attept at rendering HAML from within Apache. I was able to do it using a persistent Ruby instance using mod_ruby. I realize this is an old post, but thought you may be interested to see my approach: http://atechmedia.com/blog/mini-projects/static-sites-with-haml-and-apache</description>
		<content:encoded><![CDATA[<p>I had a similar attept at rendering HAML from within Apache. I was able to do it using a persistent Ruby instance using mod_ruby. I realize this is an old post, but thought you may be interested to see my approach: <a href="http://atechmedia.com/blog/mini-projects/static-sites-with-haml-and-apache" rel="nofollow">http://atechmedia.com/blog/mini-projects/static-sites-with-haml-and-apache</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Zillion</title>
		<link>http://blog.kesor.net/2007/07/30/haml-caching-cgi/comment-page-1/#comment-6</link>
		<dc:creator>Mike Zillion</dc:creator>
		<pubDate>Sun, 12 Aug 2007 02:01:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.kesor.net/2007/07/30/haml-caching-cgi/#comment-6</guid>
		<description>I appreciate the effort, and the concerns that were raised about the security. I would still love to see something like this work. I&#039;ve been completely spoiled by HAML.</description>
		<content:encoded><![CDATA[<p>I appreciate the effort, and the concerns that were raised about the security. I would still love to see something like this work. I&#8217;ve been completely spoiled by HAML.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roman Shterenzon</title>
		<link>http://blog.kesor.net/2007/07/30/haml-caching-cgi/comment-page-1/#comment-5</link>
		<dc:creator>Roman Shterenzon</dc:creator>
		<pubDate>Mon, 06 Aug 2007 21:53:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.kesor.net/2007/07/30/haml-caching-cgi/#comment-5</guid>
		<description>Line 11 has a serious security flaw - directory traversal, which in line 29 can lead to disaster.
The &quot;output&quot; is an unknown object on line 20, unless there&#039;s a cached file already. Either define it or use defined?(output)
I&#039;d also remove the Pragma, Cache-control and Expires headers, keeping only the Last-Modified. It makes sense, think about it.</description>
		<content:encoded><![CDATA[<p>Line 11 has a serious security flaw &#8211; directory traversal, which in line 29 can lead to disaster.<br />
The &#8220;output&#8221; is an unknown object on line 20, unless there&#8217;s a cached file already. Either define it or use defined?(output)<br />
I&#8217;d also remove the Pragma, Cache-control and Expires headers, keeping only the Last-Modified. It makes sense, think about it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Woody Peterson</title>
		<link>http://blog.kesor.net/2007/07/30/haml-caching-cgi/comment-page-1/#comment-4</link>
		<dc:creator>Woody Peterson</dc:creator>
		<pubDate>Wed, 01 Aug 2007 11:40:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.kesor.net/2007/07/30/haml-caching-cgi/#comment-4</guid>
		<description>I had a hard time getting this to work, so I thought I would share some bits of wisdom I gained.

First of all, I had a consistent but cryptic host of error messages that all went away the moment I changed haml_cache_cgi.rb to haml_cache_cgi.cgi (well, eventually haml_cache.cgi, &#039;cuz the former is repetitive). Note that permissions were always correct, i.e. this was not a permissions issue that I accidentally solved at the same time (they produce similar error behaviors).

Second, in the script, I needed to either prefix haml_file with ../../, or just put haml_cache.cgi in the root (read: web root, etc) directory. I did the latter, as well as making it a hidden file for later convenience (.haml_cache.cgi).

Then, another problem was that ARGV[0] is meant to get at the first argument passed to haml_cache.cgi. Thus, I assumed, say, index.haml would make a call along the lines of &quot;&gt;haml_cache.cgi index.haml&quot;. What I found was that haml_cache.cgi was being passed no argument; rather, it seems (on my environment at least) that the requested file is meant to be accessed via ENV[&#039;REQUEST_URI&#039;] (see http://www.ruby-doc.org/core/classes/CGI.html for a full list of cgi-specific environment variables). Thus, I changed ARGV[0] to ENV[&#039;REQUEST_URI&#039;], and all was almost good. Actually, ENV[&#039;REQUEST_URI&#039;] gives a preceding slash (ex. &quot;/index.html&quot;), but a little bit of gsub-ing fixed that like so: ENV[&#039;REQUEST_URI&#039;].gsub(/^\//, &#039;&#039;). To sum up, then, your lines 3 and 4 are for me:

exit if ENV[&#039;REQUEST_URI&#039;].nil?
haml_file = ENV[&#039;REQUEST_URI&#039;].gsub(/^\//,&#039;&#039;)
exit unless File.exists?(haml_file)

(Note to readers: line 8 would be gone too).

As a final note, I&#039;m hosting on dreamhost (yeah, I know... I&#039;ve actually become a dreamhost deployment ninja (&#039;cuz you have to), so it&#039;s not a bad staging environment). For those who don&#039;t know dreamhost, they&#039;re dirt cheap shared hosting. Anyways, like most shared hosts, you can&#039;t install gems yourself except locally, so I had to also change &quot;require &#039;haml&#039;&quot; to &quot;require &#039;/home/username/.gems/gems/haml-1.7.0/lib/haml&#039;&quot;.

Well, that about sums it up. I spent the better part of my (supposed) work day getting this working, mostly due to lack of understanding (read: when cut&#039;n&#039;paste goes wrong). Hope it helps!</description>
		<content:encoded><![CDATA[<p>I had a hard time getting this to work, so I thought I would share some bits of wisdom I gained.</p>
<p>First of all, I had a consistent but cryptic host of error messages that all went away the moment I changed haml_cache_cgi.rb to haml_cache_cgi.cgi (well, eventually haml_cache.cgi, &#8216;cuz the former is repetitive). Note that permissions were always correct, i.e. this was not a permissions issue that I accidentally solved at the same time (they produce similar error behaviors).</p>
<p>Second, in the script, I needed to either prefix haml_file with ../../, or just put haml_cache.cgi in the root (read: web root, etc) directory. I did the latter, as well as making it a hidden file for later convenience (.haml_cache.cgi).</p>
<p>Then, another problem was that ARGV[0] is meant to get at the first argument passed to haml_cache.cgi. Thus, I assumed, say, index.haml would make a call along the lines of &#8220;&gt;haml_cache.cgi index.haml&#8221;. What I found was that haml_cache.cgi was being passed no argument; rather, it seems (on my environment at least) that the requested file is meant to be accessed via ENV['REQUEST_URI'] (see <a href="http://www.ruby-doc.org/core/classes/CGI.html" rel="nofollow">http://www.ruby-doc.org/core/classes/CGI.html</a> for a full list of cgi-specific environment variables). Thus, I changed ARGV[0] to ENV['REQUEST_URI'], and all was almost good. Actually, ENV['REQUEST_URI'] gives a preceding slash (ex. &#8220;/index.html&#8221;), but a little bit of gsub-ing fixed that like so: ENV['REQUEST_URI'].gsub(/^\//, &#8221;). To sum up, then, your lines 3 and 4 are for me:</p>
<p>exit if ENV['REQUEST_URI'].nil?<br />
haml_file = ENV['REQUEST_URI'].gsub(/^\//,&#8221;)<br />
exit unless File.exists?(haml_file)</p>
<p>(Note to readers: line 8 would be gone too).</p>
<p>As a final note, I&#8217;m hosting on dreamhost (yeah, I know&#8230; I&#8217;ve actually become a dreamhost deployment ninja (&#8217;cuz you have to), so it&#8217;s not a bad staging environment). For those who don&#8217;t know dreamhost, they&#8217;re dirt cheap shared hosting. Anyways, like most shared hosts, you can&#8217;t install gems yourself except locally, so I had to also change &#8220;require &#8216;haml&#8217;&#8221; to &#8220;require &#8216;/home/username/.gems/gems/haml-1.7.0/lib/haml&#8217;&#8221;.</p>
<p>Well, that about sums it up. I spent the better part of my (supposed) work day getting this working, mostly due to lack of understanding (read: when cut&#8217;n'paste goes wrong). Hope it helps!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.222 seconds -->
