Apache2-AutoIndex-XSLT

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

Build.PL
Changes
complain.txt
examples/apache/conf/extra/Apache2-AutoIndex-XSLT.conf
examples/apache/conf/filetypes.dat
examples/apache/htdocs/favicon.ico
examples/apache/htdocs/icons/__back.png
examples/apache/htdocs/icons/__broken.png
examples/apache/htdocs/icons/__dir.png
examples/apache/htdocs/icons/__dir_nox.png
examples/apache/htdocs/icons/__dvd_drive.png
examples/apache/htdocs/icons/__floppy_disk_drive.png
examples/apache/htdocs/icons/__hard_disk_drive.png
examples/apache/htdocs/icons/__my_documents.png
examples/apache/htdocs/icons/__my_music.png
examples/apache/htdocs/icons/__my_pictures.png
examples/apache/htdocs/icons/__my_videos.png
examples/apache/htdocs/icons/__network_drive.png
examples/apache/htdocs/icons/__recycle_bin.png
examples/apache/htdocs/icons/__unknown.png
examples/apache/htdocs/icons/__webcam.png
examples/apache/htdocs/icons/ai.png
examples/apache/htdocs/icons/arj.png
examples/apache/htdocs/icons/au.png
examples/apache/htdocs/icons/avi.png
examples/apache/htdocs/icons/bat.png
examples/apache/htdocs/icons/bin.png
examples/apache/htdocs/icons/bmp.png
examples/apache/htdocs/icons/bz2.png
examples/apache/htdocs/icons/c.png
examples/apache/htdocs/icons/cdr.png
examples/apache/htdocs/icons/chm.png
examples/apache/htdocs/icons/class.png
examples/apache/htdocs/icons/com.png
examples/apache/htdocs/icons/conf.png
examples/apache/htdocs/icons/crt.png
examples/apache/htdocs/icons/deb.png
examples/apache/htdocs/icons/diff.png
examples/apache/htdocs/icons/dll.png
examples/apache/htdocs/icons/doc.png
examples/apache/htdocs/icons/dot.png
examples/apache/htdocs/icons/eml.png
examples/apache/htdocs/icons/exe.png
examples/apache/htdocs/icons/gif.png
examples/apache/htdocs/icons/gz.png
examples/apache/htdocs/icons/htm.png
examples/apache/htdocs/icons/html.png
examples/apache/htdocs/icons/ini.png
examples/apache/htdocs/icons/iso.png
examples/apache/htdocs/icons/it.png
examples/apache/htdocs/icons/jar.png
examples/apache/htdocs/icons/java.png
examples/apache/htdocs/icons/jpeg.png
examples/apache/htdocs/icons/jpg.png
examples/apache/htdocs/icons/jsp.png
examples/apache/htdocs/icons/lhz.png
examples/apache/htdocs/icons/m3u.png
examples/apache/htdocs/icons/mid.png
examples/apache/htdocs/icons/mod.png
examples/apache/htdocs/icons/mov.png
examples/apache/htdocs/icons/mp3.png
examples/apache/htdocs/icons/mpeg.png
examples/apache/htdocs/icons/mpg.png
examples/apache/htdocs/icons/msi.png
examples/apache/htdocs/icons/ogg.png
examples/apache/htdocs/icons/pas.png
examples/apache/htdocs/icons/patch.png
examples/apache/htdocs/icons/pdf.png
examples/apache/htdocs/icons/pem.png
examples/apache/htdocs/icons/pl.png
examples/apache/htdocs/icons/pm.png
examples/apache/htdocs/icons/png.png
examples/apache/htdocs/icons/pps.png
examples/apache/htdocs/icons/ppt.png
examples/apache/htdocs/icons/ps.png
examples/apache/htdocs/icons/psd.png
examples/apache/htdocs/icons/ra.png
examples/apache/htdocs/icons/ram.png
examples/apache/htdocs/icons/rar.png
examples/apache/htdocs/icons/readme.png
examples/apache/htdocs/icons/reg.png
examples/apache/htdocs/icons/rm.png
examples/apache/htdocs/icons/rpm.png
examples/apache/htdocs/icons/s3m.png
examples/apache/htdocs/icons/sh.png
examples/apache/htdocs/icons/shtml.png
examples/apache/htdocs/icons/sql.png
examples/apache/htdocs/icons/swf.png
examples/apache/htdocs/icons/sxc.png
examples/apache/htdocs/icons/sxd.png
examples/apache/htdocs/icons/sxi.png
examples/apache/htdocs/icons/sxw.png
examples/apache/htdocs/icons/tar.png
examples/apache/htdocs/icons/text.png
examples/apache/htdocs/icons/tgz.png
examples/apache/htdocs/icons/tif.png
examples/apache/htdocs/icons/tiff.png
examples/apache/htdocs/icons/txt.png
examples/apache/htdocs/icons/url.png
examples/apache/htdocs/icons/uu.png
examples/apache/htdocs/icons/vsd.png
examples/apache/htdocs/icons/wav.png
examples/apache/htdocs/icons/wma.png
examples/apache/htdocs/icons/wmf.png
examples/apache/htdocs/icons/wmv.png
examples/apache/htdocs/icons/wri.png
examples/apache/htdocs/icons/xls.png
examples/apache/htdocs/icons/xm.png
examples/apache/htdocs/icons/xsl.png
examples/apache/htdocs/icons/xslt.png
examples/apache/htdocs/icons/zip.png
examples/apache/htdocs/index.xslt
examples/bluewhitebar.png
examples/fakeup.pl
examples/filetypes.pl
examples/mason_icon_index.html
examples/RegFileTypes.cs
examples/RegFileTypes.exe
examples/sitemap.pl
examples/static.html
INSTALL
lib/Apache2/AutoIndex/XSLT.pm
LICENSE
Makefile.PL
MANIFEST			This list of files
META.yml
NOTICE
README
t/htdocs/fake.gif
t/htdocs/fake.jpg
t/htdocs/fake.png
t/htdocs/fake.xbm
t/htdocs/favicon.ico
t/htdocs/icons/exists
t/htdocs/index.xslt
t/htdocs/test/Apache2-AutoIndex-XSLT/shopping.txt
t/htdocs/test/empty_file
t/htdocs/test/feed.png
t/htdocs/test/file1.txt
t/htdocs/test/invoice.doc
t/htdocs/test/knickers/exists
t/htdocs/test/perl.txt
t/TEST.PL
t/tests/10pod.t
t/tests/11pod_coverage.t
t/tests/20compile.t
t/tests/30options.t
t/tests/31listing.t

README  view on Meta::CPAN

NAME
    Apache2::AutoIndex::XSLT - XSLT Based Directory Listings

SYNOPSIS
     PerlLoadModule Apache2::AutoIndex::XSLT
     <Location />
         SetHandler perl-script
         PerlResponseHandler Apache2::AutoIndex::XSLT
         Options +Indexes
         IndexStyleSheet /index.xslt
         DefaultIcon /icons/__unknown.png
         IndexIgnore .*
         IndexIgnore index.xslt
         IndexIgnore robots.txt
         IndexIgnore sitemap.gz
     </Location>

DESCRIPTION
    This module is designed as a drop in mod_perl2 replacement for the
    mod_dir and mod_index modules. It uses user configurable XSLT
    stylesheets to generate the directory listings.

README  view on Meta::CPAN

  AddAltByType
         AddAltByType 'plain text' text/plain

    *AddAltByType* sets the alternate text to display for a file, instead of
    an icon. MIME-type is a valid content-type, such as text/html. If String
    contains any whitespace, you have to enclose it in quotes (" or '). This
    alternate text is displayed if the client is image-incapable, has image
    loading disabled, or fails to retrieve the icon.

  AddDescription
         AddDescription "The planet Mars" /web/pics/mars.png

    This sets the description to display for a file. File is a file
    extension, partial filename, wild-card expression or full filename for
    files to describe. String is enclosed in double quotes (").

  AddIcon
         AddIcon (IMG,/icons/image.xbm) .gif .jpg .xbm
         AddIcon /icons/dir.xbm ^^DIRECTORY^^
         AddIcon /icons/backup.xbm *~

README  view on Meta::CPAN

         AddIconByType (IMG,/icons/image.xbm) image/*

    This sets the icon to display next to files of type MIME-type. Icon is
    either a (%-escaped) relative URL to the icon, or of the format
    (alttext,url) where alttext is the text tag given for an icon for
    non-graphical browsers.

    MIME-type is a wildcard expression matching required the mime types.

  DefaultIcon
         DefaultIcon /icons/__unknown.png

    The *DefaultIcon* directive sets the icon to display for files when no
    specific icon is known. Url-path is a (%-escaped) relative URL to the
    icon.

  HeaderName
  IndexIgnore
         IndexIgnore README .htindex *.bak *~

    The *IndexIgnore* directive adds to the list of files to hide when

examples/apache/conf/extra/Apache2-AutoIndex-XSLT.conf  view on Meta::CPAN

# Load up Apache2::AutoIndex::XSLT before
# we use any configuration directives that
# we want it to see and use.

PerlLoadModule Apache2::AutoIndex::XSLT

# Set a buch of things that change how we
# will generate our directory listings.

IndexStyleSheet /index.xslt
DefaultIcon /icons/__unknown.png

IndexIgnore .* *.bak lost+found
IndexIgnore index.xslt favicon.ico icons
IndexIgnore robots.txt sitemap.gz googlee820414a2b69240d.html

# Set this to true if you want to pre-
# render the XML/XSLT on the server-side.
#RenderXSLT Off

# Set the handler for the / root of the website

examples/apache/conf/filetypes.dat  view on Meta::CPAN

  MimeType:     
  DisplayName:  Memory Profiling Data
  IconDesc:     C:\App\Rational\PURIFY~1\purifyw.exe,0

Extension:      .pnf
  Type:         pnffile
  MimeType:     
  DisplayName:  Precompiled Setup Information
  IconDesc:     C:\WINDOWS\system32\shell32.dll,-154

Extension:      .png
  Type:         OISpngfile
  MimeType:     image/png
  DisplayName:  PNG Image
  IconDesc:     "C:\App\Office\OFFICE11\ois.exe",4

Extension:      .pnt
  Type:         QuickTime.pnt
  MimeType:     image/x-macpaint
  DisplayName:  MacPaint Image
  IconDesc:     C:\App\QuickTime\PictureViewer.exe,-130

Extension:      .pntg

examples/apache/htdocs/index.xslt  view on Meta::CPAN

							<xsl:text>XXX on 'Anatar' (J:)</xsl:text>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="@title"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<xsl:variable name="icon">
					<xsl:choose>
						<xsl:when test="@title = 'A:' or @title = 'B:'">
							<xsl:text>/icons/__floppy_disk_drive.png</xsl:text>
						</xsl:when>
						<xsl:when test="@title = 'C:' or @title = 'D:'">
							<xsl:text>/icons/__hard_disk_drive.png</xsl:text>
						</xsl:when>
						<xsl:when test="@title = 'E:'">
							<xsl:text>/icons/__dvd_drive.png</xsl:text>
						</xsl:when>
						<xsl:when test="string-length(@title) = 2 and substring(@title,2,1) = ':'">
							<xsl:text>/icons/__network_drive.png</xsl:text>
						</xsl:when>
						<xsl:when test="@title = 'Logitech Webcam'">
							<xsl:text>/icons/__webcam.png</xsl:text>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="@icon"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<xsl:variable name="desc">
					<xsl:choose>
						<xsl:when test="@title = 'A:' or @title = 'B:'">
							<xsl:text>3 1/2-Inch Floppy Disk</xsl:text>

examples/apache/htdocs/index.xslt  view on Meta::CPAN

							<xsl:text>My Music</xsl:text>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="@title"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<xsl:variable name="icon">
					<xsl:choose>
						<xsl:when test="$title = 'Recycle Bin'">
							<xsl:text>/icons/__recycle_bin.png</xsl:text>
						</xsl:when>
						<xsl:when test="$title = 'My Documents'">
							<xsl:text>/icons/__my_documents.png</xsl:text>
						</xsl:when>
						<xsl:when test="$title = 'My Pictures'">
							<xsl:text>/icons/__my_pictures.png</xsl:text>
						</xsl:when>
						<xsl:when test="$title = 'My Videos'">
							<xsl:text>/icons/__my_videos.png</xsl:text>
						</xsl:when>
						<xsl:when test="$title = 'My Music'">
							<xsl:text>/icons/__my_music.png</xsl:text>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="@icon"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<tr>
					<td class="filecol">
						<a>
							<xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>

examples/mason_icon_index.html  view on Meta::CPAN

%# for i in `ls *.ico|sed 's/\.ico$//'`;do convert $i.ico $i.png;done

% use File::Basename qw(dirname basename);
% for (glob(sprintf('"%s/*.png"',dirname($r->filename)))) { $_ = basename($_);
	<a href="<% $_ |u %>"><img src="<% $_ |u %>" alt="<% $_ |h %>" border="0" /></a>
% }

lib/Apache2/AutoIndex/XSLT.pm  view on Meta::CPAN

				sprintf('%s (%s)', $r->uri, $directory),
			);
		return Apache2::Const::FORBIDDEN;
	}

	# Send the XML header and top of the index tree
	$xml .= xml_header($r,$dir_cfg);
	$xml .= sprintf("<index path=\"%s\" href=\"%s\" >\n",
				$r->uri, $r->construct_url);
	$xml .= xml_options($r,$qstring,$dir_cfg);
	$xml .= "\t<updir icon=\"/icons/__back.png\" />\n"
				unless $r->uri =~ m,^/?$,;

	# Build a list of attributes for each item in the directory and then
	# print it as an element in the index tree.
	while (my $id = readdir($dh)) {
		next if $id eq '..' || $id eq '.';
		next if grep($id =~ /^$_$/, @{$dir_cfg->{IndexIgnoreRegex}});
		#my $subr = $r->lookup_file($id); # Not used yet

		my $filename = File::Spec->catfile($directory,$id);

lib/Apache2/AutoIndex/XSLT.pm  view on Meta::CPAN

	$xml .= "\t</options>\n";
	return $xml;
}


sub icon_by_extension {
	my ($r,$id,$ext,$dir_cfg) = @_;

	my $alt = '';
	my $icon =
		$ext && -f File::Spec->catfile($r->document_root,'icons',lc("$ext.png")) 
			? '/icons/'.lc("$ext.png")
			: $dir_cfg->{DefaultIcon} || '';

	while (my ($re,$v) = each %{$dir_cfg->{AddIconRegex}}) {
		if ($id =~ /$re$/) {
			($alt,$icon) = @{$v};
		}
	}

	return ($alt,$icon);
}

lib/Apache2/AutoIndex/XSLT.pm  view on Meta::CPAN

	return {} if $type eq 'updir';

	my $attr = stat_file($r,$filename);

	if ($type eq 'file') {
		($attr->{ext}) = $id =~ /\.([a-z0-9_]+)$/i;
		($attr->{alt},$attr->{icon}) = icon_by_extension($r,$id,$attr->{ext},$dir_cfg);

	} elsif ($type eq 'dir') {
		$attr->{alt} = 'DIR';
		$attr->{icon} = '/icons/__dir.png';
		if ($dir_cfg->{AddIconRegex}->{'^^DIRECTORY^^'}) {
			($attr->{alt},$attr->{icon}) =
				@{$dir_cfg->{AddIconRegex}->{'^^DIRECTORY^^'}};
		}

	} elsif ($type eq 'updir') {
		$attr->{icon} = '/icons/__back.png';
	}

	unless ($type eq 'updir') {
		#$attr->{id} = $id; # This serves no real purpose anymor
		$attr->{href} = URI::Escape::uri_escape($id);
		$attr->{href} .= '/' if $type eq 'dir';
		$attr->{title} = XML::Quote::xml_quote($id);

		$attr->{desc} = $type eq 'dir'
				? 'File Folder'

lib/Apache2/AutoIndex/XSLT.pm  view on Meta::CPAN

	}
}

sub defaults {
	my ($class, $parms) = @_;
	return bless {
			HeaderName => 'HEADER',
			ReadmeName => 'FOOTER',
			DirectoryIndex => [qw(index.html index.shtml)],
			IndexStyleSheet => '/index.xslt',
			DefaultIcon => '/icons/__unknown.png',
			IndexIgnore => [()],
			FileTypesFilename => 'filetypes.dat',
		}, $class;
}

# http://perl.apache.org/docs/2.0/user/config/custom.html#Examples

sub merge {
	my ($base, $add) = @_;
	my %mrg = ();

lib/Apache2/AutoIndex/XSLT.pm  view on Meta::CPAN

Apache2::AutoIndex::XSLT - XSLT Based Directory Listings

=head1 SYNOPSIS

 PerlLoadModule Apache2::AutoIndex::XSLT
 <Location />
     SetHandler perl-script
     PerlResponseHandler Apache2::AutoIndex::XSLT
     Options +Indexes
     IndexStyleSheet /index.xslt
     DefaultIcon /icons/__unknown.png
     IndexIgnore .*
     IndexIgnore index.xslt
     IndexIgnore robots.txt
     IndexIgnore sitemap.gz
 </Location>

=head1 DESCRIPTION

This module is designed as a drop in mod_perl2 replacement for the mod_dir and
mod_index modules. It uses user configurable XSLT stylesheets to generate the

lib/Apache2/AutoIndex/XSLT.pm  view on Meta::CPAN

     AddAltByType 'plain text' text/plain

I<AddAltByType> sets the alternate text to display for a file, instead of an
icon. MIME-type is a valid content-type, such as
text/html. If String contains any whitespace, you have to enclose it in quotes
(" or '). This alternate text is displayed if the client is image-incapable,
has image loading disabled, or fails to retrieve the icon.

=head2 AddDescription

     AddDescription "The planet Mars" /web/pics/mars.png

This sets the description to display for a file. File is
a file extension, partial filename, wild-card expression or full filename for
files to describe. String is enclosed in double quotes (").

=head2 AddIcon

     AddIcon (IMG,/icons/image.xbm) .gif .jpg .xbm
     AddIcon /icons/dir.xbm ^^DIRECTORY^^
     AddIcon /icons/backup.xbm *~

lib/Apache2/AutoIndex/XSLT.pm  view on Meta::CPAN


This sets the icon to display next to files of type MIME-type.
Icon is either a (%-escaped) relative URL to the icon, or of
the format (alttext,url)  where alttext is the text tag given for an icon for
non-graphical browsers.

MIME-type is a wildcard expression matching required the mime types.

=head2 DefaultIcon

     DefaultIcon /icons/__unknown.png

The I<DefaultIcon> directive sets the icon to display for files when no
specific icon is known. Url-path is a (%-escaped)
relative URL to the icon.

=head2 HeaderName

=head2 IndexIgnore

     IndexIgnore README .htindex *.bak *~

t/htdocs/index.xslt  view on Meta::CPAN

							<xsl:text>XXX on 'Anatar' (J:)</xsl:text>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="@title"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<xsl:variable name="icon">
					<xsl:choose>
						<xsl:when test="@title = 'A:' or @title = 'B:'">
							<xsl:text>/icons/__floppy_disk_drive.png</xsl:text>
						</xsl:when>
						<xsl:when test="@title = 'C:' or @title = 'D:'">
							<xsl:text>/icons/__hard_disk_drive.png</xsl:text>
						</xsl:when>
						<xsl:when test="@title = 'E:'">
							<xsl:text>/icons/__dvd_drive.png</xsl:text>
						</xsl:when>
						<xsl:when test="string-length(@title) = 2 and substring(@title,2,1) = ':'">
							<xsl:text>/icons/__network_drive.png</xsl:text>
						</xsl:when>
						<xsl:when test="@title = 'Logitech Webcam'">
							<xsl:text>/icons/__webcam.png</xsl:text>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="@icon"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<xsl:variable name="desc">
					<xsl:choose>
						<xsl:when test="@title = 'A:' or @title = 'B:'">
							<xsl:text>3 1/2-Inch Floppy Disk</xsl:text>

t/htdocs/index.xslt  view on Meta::CPAN

							<xsl:text>My Music</xsl:text>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="@title"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<xsl:variable name="icon">
					<xsl:choose>
						<xsl:when test="$title = 'Recycle Bin'">
							<xsl:text>/icons/__recycle_bin.png</xsl:text>
						</xsl:when>
						<xsl:when test="$title = 'My Documents'">
							<xsl:text>/icons/__my_documents.png</xsl:text>
						</xsl:when>
						<xsl:when test="$title = 'My Pictures'">
							<xsl:text>/icons/__my_pictures.png</xsl:text>
						</xsl:when>
						<xsl:when test="$title = 'My Videos'">
							<xsl:text>/icons/__my_videos.png</xsl:text>
						</xsl:when>
						<xsl:when test="$title = 'My Music'">
							<xsl:text>/icons/__my_music.png</xsl:text>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="@icon"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<tr>
					<td class="filecol">
						<a>
							<xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>

t/tests/30options.t  view on Meta::CPAN

use Apache::TestRequest qw(GET_BODY GET);
  
my @options = (
		'<option name="ReadmeName" value="FOOTER" />',
		'<option name="HeaderName" value="HEADER" />',
		'<option name="IndexStyleSheet" value="/index.xslt" />',
		'<option name="DirectoryIndex" value="index.html" />',
		'<option name="DirectoryIndex" value="index.shtml" />',
		'<option name="RenderXSLTEnvVar" value="RenderXSLT" />',
		'<option name="FileTypesFilename" value="filetypes.dat" />',
		'<option name="DefaultIcon" value="/icons/__unknown.png" />',
		'<option name="RenderXSLT" value="0" />',
		'<option name="AddIcon" value="(IMG,/icons/image.xbm) .gif" />',
		'<option name="AddIcon" value="(IMG,/icons/image.xbm) .jpg" />',
		'<option name="AddIcon" value="(IMG,/icons/image.xbm) .xbm" />',
		'<option name="AddIcon" value="/icons/dir.xbm ^^DIRECTORY^^" />',
		'<option name="AddIcon" value="/icons/backup.xbm *~" />',
	);

plan tests => scalar(@options);
  



( run in 1.538 second using v1.01-cache-2.11-cpan-df04353d9ac )