<?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>actionshrimp.com &#187; apache</title>
	<atom:link href="http://www.actionshrimp.com/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.actionshrimp.com</link>
	<description>fun and geekery</description>
	<lastBuildDate>Sun, 18 Apr 2010 12:42:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Lightbox with Apache directory listings as an image gallery</title>
		<link>http://www.actionshrimp.com/2009/03/using-lightbox-with-apache-directory-listings-as-an-image-gallery/</link>
		<comments>http://www.actionshrimp.com/2009/03/using-lightbox-with-apache-directory-listings-as-an-image-gallery/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 21:48:22 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.actionshrimp.com/?p=79</guid>
		<description><![CDATA[As you may know, if it can&#8217;t find an index.html the apache web server will show a list of files in the current directory. I was browsing through lists of images on my file server the other day and I thought, wouldn&#8217;t it be nice to have a next button? So I started digging around.
In [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.actionshrimp.com/wordpress/wp-content/uploads/2009/03/lightbox.jpg"><img class="alignleft size-medium wp-image-114" src="http://www.actionshrimp.com/wordpress/wp-content/uploads/2009/03/lightbox-300x184.jpg" alt="Screenshot" width="300" height="184" /></a>As you may know, if it can&#8217;t find an <code>index.html</code> the apache web server will show a list of files in the current directory. I was browsing through lists of images on my file server the other day and I thought, wouldn&#8217;t it be nice to have a next button? So I started digging around.</p>
<p>In the end I used a wonderful little script called <a href="http://www.lokeshdhakar.com/projects/lightbox2/">Lightbox 2</a> and a bit of JavaScript <a href="http://prototypejs.org">Prototype</a> magic to produce <a href="http://files.mattjbray.com/lightbox_images">this</a> (try clicking on the image files).</p>
<p>The directory listings are provided by an apache module going by the name of <code>mod_autoindex</code>. This module allows you to insert a custom header and footer through the directives <code>HeaderName</code> and <code>ReadmeName</code>. The plan is to insert some HTML that includes the Lightbox code and tags all the links to images with the <code>rel=lightbox</code> attribute that Lightbox uses to function.</p>
<p><span id="more-79"></span></p>
<p>Create a directory called <code>lightbox</code> in your server&#8217;s document root. Download <a href="http://www.lokeshdhakar.com/projects/lightbox2/#download">Lightbox 2</a> and extract it to that directory (go to http://www.yourwebsite.com/lightbox to try it out). To get the Lightbox &#8216;loading&#8217; and &#8216;next&#8217; images to show up, you need to edit a couple of lines in the configuration section of <code>js/lightbox.js</code> that comes with Lightbox. Change the following</p>
<blockquote>
<pre>LightboxOptions = Object.extend({
    fileLoadingImage:        'images/loading.gif',
    fileBottomNavCloseImage: 'images/closelabel.gif',</pre>
</blockquote>
<p>to look like</p>
<blockquote>
<pre>LightboxOptions = Object.extend({
    fileLoadingImage:        '/lightbox/images/loading.gif',
    fileBottomNavCloseImage: '/lightbox/images/closelabel.gif',</pre>
</blockquote>
<p>I also adjusted <code>resizeSpeed</code> to 9 to make it feel a little snappier, change this to your taste.</p>
<p>Now create a new file called <code>lightbox.html</code> in your <code>/lightbox</code> directory and copy and paste the following:</p>
<blockquote>
<pre>&lt;script src="/lightbox/js/prototype.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="/lightbox/js/scriptaculous.js?load=effects,builder" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="/lightbox/js/lightbox.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;&lt;!--
    // Insert the lightbox stylesheet into &lt;head&gt;
    var stylesheet = new Element('link', {  'rel': 'stylesheet',
                                            'href': '/lightbox/css/lightbox.css',
                                            'type': 'text/css',
                                            'media': 'screen'
                                         });
    $$('head')[0].appendChild(stylesheet);

    // Check for links preceded by the image icon provided by mod_autoindex.
    // On my setup the src attribute in the img tag preceding a link to an image
    // is "/icons/image2.gif". This is used to identify links to images.
    $$("a").each( function(elmt) {
            // The default output is tabular, so check the previous cell for the img tag
            imgelmt = elmt.up().previous().down()
            // If the FancyIndexes option is set, the output is formatted differently
            if (imgelmt == undefined) { imgelmt = elmt.previous('img') }
            if (imgelmt.readAttribute('src') == "/icons/image2.gif")
            {
                elmt.setAttribute('rel', 'lightbox[images]');

                // As ps suggested, provide a link to the image in the lightbox description
                link = "&lt;a href='" + elmt.readAttribute('href') + "'&gt;" +
                        elmt.innerHTML.stripScripts().stripTags() + "&lt;/a&gt;";
                elmt.setAttribute('title', link );
            }
        } );
// --&gt;&lt;/script&gt;</pre>
</blockquote>
<p>Now all you have to do is tell apache to include this file in its directory listing page. Simply paste the following two lines into a file named <code>.htaccess</code> and copy it to any directory that you want Lightbox to appear in.</p>
<blockquote>
<pre>Options Indexes
ReadmeName /lightbox/lightbox.html</pre>
</blockquote>
<p>Et voila! No php, no databases to maintain. Image galleries don&#8217;t get much simpler than that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.actionshrimp.com/2009/03/using-lightbox-with-apache-directory-listings-as-an-image-gallery/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
