<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Scott Evans &#187; software</title>
	<atom:link href="http://antisleep.com/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://antisleep.com</link>
	<description>The Evans Center for Sleep Deprivation Studies</description>
	<lastBuildDate>Mon, 02 Jan 2012 09:37:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>indices 1.1</title>
		<link>http://antisleep.com/2009/09/01/indices-11/</link>
		<comments>http://antisleep.com/2009/09/01/indices-11/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 05:08:20 +0000</pubDate>
		<dc:creator>gse</dc:creator>
				<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://antisleep.com/wp/2009/09/01/indices-11/</guid>
		<description><![CDATA[I just posted a small but welcome update to Indices. In order to make the entire link cells clickable, the original version used a technique that caused &#8220;Save As&#8221; and &#8220;Copy Link Location&#8221; to break in most browsers. This has annoyed me for almost two years but I just found time to fix it. The [...]]]></description>
			<content:encoded><![CDATA[<p>I just posted a small but welcome update to <a href="http://antisleep.com/indices">Indices</a>.</p>
<p>In order to make the entire link cells clickable, the original version used a technique that caused &#8220;Save As&#8221; and &#8220;Copy Link Location&#8221; to break in most browsers.  This has annoyed me for almost two years but I just found time to fix it.</p>
<p>The original version surrounded the cell content with a div, and put the link on that.  I changed it to use CSS to expand the link:</p>
<pre>td a, th a {
  display: block;
  height: 100%;
}</pre>
<p>Seems to work much better.</p>
<p>You can download the new version (1.1) <a href="http://antisleep.com/indices">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://antisleep.com/2009/09/01/indices-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>indices: prettying up apache directory listings</title>
		<link>http://antisleep.com/2007/10/08/indices-prettying-up-apache-directory-listings/</link>
		<comments>http://antisleep.com/2007/10/08/indices-prettying-up-apache-directory-listings/#comments</comments>
		<pubDate>Tue, 09 Oct 2007 05:06:14 +0000</pubDate>
		<dc:creator>gse</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[modded and working.]]></category>
		<category><![CDATA[YJM-308 pedal]]></category>

		<guid isPermaLink="false">http://antisleep.com/wp/2007/10/08/indices-prettying-up-apache-directory-listings/</guid>
		<description><![CDATA[Here&#8217;s a cool little hack I wrote: Indices. It takes the &#8220;vintage&#8221; looking Apache directory listings and gives them a significant facelift. I&#8217;ve wanted this for years and finally got around to doing it. There&#8217;s a README in the download, but I thought I&#8217;d write a bit about the details of my approach. Why? I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://antisleep.com/wp/wp-content/uploads/2007/10/2007-02-06_yjm.jpg" rel="lightbox[51]"><img class="alignright size-thumbnail wp-image-91" title=" YJM-308 pedal, modded and working. " src="http://antisleep.com/wp/wp-content/uploads/2007/10/2007-02-06_yjm-200x200.jpg" alt=" YJM-308 pedal, modded and working. " width="200" height="200" /></a></p>
<p>Here&#8217;s a cool little hack I wrote: <a href="http://antisleep.com/software/indices">Indices</a>. It takes the &#8220;vintage&#8221; looking Apache directory listings and gives them a significant facelift.  I&#8217;ve wanted this for years and finally got around to doing it.</p>
<p>There&#8217;s a <a href="http://www.antisleep.com/software/indices/README.txt">README</a> in the download, but I thought I&#8217;d write a bit about the details of my approach.</p>
<h2>Why?</h2>
<p>I&#8217;ve been using a hacked-up version of Ash Young&#8217;s <a href="http://www.evoluted.net/community/code/directorylisting.php">directory listing</a> PHP.  It worked pretty well, but I wasn&#8217;t able to get it running as the default index, so I had to softlink an index.php to every directory I cared about prettying up.  And directory navigation is done with URL parameters (i.e. http://site/url?dir=somedir), which offends my delicate sense of aesthetics.</p>
<p>The softlink part was the real problem though; I had people asking how they could get their directory indexes to look nice, and &#8220;softlink this file to each directory&#8221; wasn&#8217;t going to work for them.  So I set about finding a way to make directory listings pretty via Apache.</p>
<h2>Getting started: adding CSS</h2>
<p>Apache doesn&#8217;t give you a lot to work with, but it&#8217;s enough.  There are a couple of <code>mod_autoindex</code> directives and options that got me started:</p>
<p><a href="http://httpd.apache.org/docs/2.0/mod/mod_autoindex.html#headername">HeaderName</a> and <a href="http://httpd.apache.org/docs/2.0/mod/mod_autoindex.html#readmename">ReadmeName</a> These directives allowed me to replace the HTML that appears before and after the file list. By adding <code>IndexOptions SuppressHTMLPreamble</code>, I was able to replace the entire HTML header — so I could use my own title and, more importantly, link to a CSS file. That was my prybar to styling the content.</p>
<p><a href="http://httpd.apache.org/docs/2.0/mod/mod_autoindex.html#indexoptions">IndexOptions HTMLTable</a> This experimental option turns the file list itself into an HTML table. There&#8217;s (sadly) no semantic markup in the table, but the table itself is sort of semantic: the first column is the icon, the second is the filename, etc.  Based on that knowledge, you can use gnarly CSS2 selectors and get <em>a lot</em> of styling.</p>
<p>For example, this snippet styles all of the <code>td </code>elements that are the third one after the first <code>td</code>. In the table Apache generates, that&#8217;s the &#8220;Size&#8221; column.  Nice!  (in its own way.) See the &#8220;table styling&#8221; section of<a href="http://antisleep.com/indices/style-nojs.css"> style-nojs.css</a> for more.</p>
<pre>/* all other SIZE cells */
<strong>td:first-child + td + td + td</strong> {
padding-right: 5px;
}</pre>
<h2>Making the header dynamic</h2>
<p>One problem with replacing the entire header: the title could no longer contain any information about the directory being browsed (like its name).  After some digging I found that you can make the <code>HeaderName</code> file a PHP file with some <code>.htaccess</code> trickery:</p>
<pre># For the PHP file to execute in a header, need to have a major type of text
AddType text/html .php
AddHandler application/x-httpd-php .php</pre>
<p>Another prybar: Now I could put server-side smarts in my listing.</p>
<p>I used this for my title text: <code>urldecode($_SERVER['REQUEST_URI'])</code>. Then I added some PHP to look for a <code>readme.html</code> file and insert its contents before the table.</p>
<h2>Of course, CSS2 doesn&#8217;t work in IE</h2>
<p>Yeah, most of those neat CSS selectors don&#8217;t do anything in IE.  I was still getting a lot of styling, but not everything: the &#8220;parent directory&#8221; link wasn&#8217;t getting hidden; table cell contents weren&#8217;t getting styled; etc.</p>
<h2>Making the browser part dynamic</h2>
<p>Finally it occurred to me: hey, javascript.  I could hop around the DOM and<em> insert</em> semantic markup, which would allow for much simpler, universal CSS.  The tradeoff is that you&#8217;re doing goofy DHTML things that might break in some browsers, and that won&#8217;t work at all for angry luddites who have javascript disabled.  But everything has to work in IE, right?  So I decided to give it a go.</p>
<p>The <a href="http://antisleep.com/indices/script.js">javascript</a> isn&#8217;t too bad, really.  It feels its way around the DOM — partially based on table position as semantic information — and adds class attributes, shuffles around some cell contents, and changes a few display things.  I should document the resulting CSS so people can go nuts with styling, but for now, read the javascript.</p>
<p>I could have gotten a lot more carried away with the javascript.  For instance, one way to attempt Apache 1.x compatibility would be to <em>not</em> use<code> HTMLTable</code>, and instead convert the non-table DOM into a table with javascript.  Fortunately, I was only doing this for my Apache installation so I didn&#8217;t feel the need to try things like that.</p>
<h2>A bit of productization</h2>
<p>Finally, I spent some time making my code presentable and configurable.  There are PHP variables to control whether you use CSS-only styling (which means you&#8217;re leaning on the CSS2 stuff) or the Javascript-and-CSS1 approach; what your title should say; what logo to use; etc.  I used a few more Apache <code>IndexOptions</code> to clean up the output: <code>FoldersFirst</code>, <code>IgnoreCase</code>.  I also wired up nice icons for most common file types (I grabbed a handful of these from somebody else&#8217;s free directory index package; can&#8217;t remember which).</p>
<h2>The result</h2>
<p><a href="http://antisleep.com/indices-demo">Here&#8217;s a sample index</a>. It&#8217;s much nicer than the stock Apache thing.  And the cool part is, you change your Apache config in one place (either a top-level <code>.htaccess </code>file, or in your Apache conf file), and every directory listing on your site dresses up.That&#8217;s about it.  Hope this is useful to somebody.</p>
]]></content:encoded>
			<wfw:commentRss>http://antisleep.com/2007/10/08/indices-prettying-up-apache-directory-listings/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
	</channel>
</rss>

