Apache2-AutoIndex-XSLT

 view release on metacpan or  search on metacpan

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

				name         => 'ReadmeName',
				req_override => Apache2::Const::OR_ALL,
				args_how     => Apache2::Const::TAKE1,
				errmsg       => 'ReadmeName filename',
			},

	# http://httpd.apache.org/docs/2.2/mod/mod_dir.html
		DirectoryIndex => {
				name         => 'DirectoryIndex',
				req_override => Apache2::Const::OR_ALL,
				args_how     => Apache2::Const::ITERATE,
				errmsg       => 'DirectoryIndex local-url [local-url] ...',
			},
		DirectorySlash => {
				name         => 'DirectorySlash',
				req_override => Apache2::Const::OR_ALL,
				args_how     => Apache2::Const::FLAG,
				errmsg       => 'DirectorySlash On|Off',
			},
	);

# Register our interest in a bunch of Apache configuration directives
unless (exists $ENV{AUTOMATED_TESTING}) {
	eval {
		Apache2::Module::add(__PACKAGE__, [
			map {
				if (ref($DIRECTIVES{$_}) eq 'HASH') {
					$DIRECTIVES{$_}
				} else {{
					name         => $_,
					req_override => Apache2::Const::OR_ALL,
					args_how     => Apache2::Const::ITERATE,
				}}
			} keys %DIRECTIVES
		]);
	};
	warn $@ if $@;
}

sub dump_apache_configuration {
	my $r = shift;

	my $rtn = '';
	my %secs = ();
	my $s = $r->server;
	my $dir_cfg = get_config($s, $r->per_dir_config);
	my $srv_cfg = get_config($s);
  
	if ($s->is_virtual) {
		$secs{"1: Main Server"}  = get_config(Apache2::ServerUtil->server);
		$secs{"2: Virtual Host"} = $srv_cfg;
		$secs{"3: Location"}     = $dir_cfg;
	} else {
		$secs{"1: Main Server"}  = $srv_cfg;
		$secs{"2: Location"}     = $dir_cfg;
	}
  
	$rtn .= sprintf("Processing by %s.\n", 
	$s->is_virtual ? "virtual host" : "main server");

	require Data::Dumper;
	no warnings 'once';
	local $Data::Dumper::Terse = 1;
	local $Data::Dumper::Deepcopy = 1;
	local $Data::Dumper::Sortkeys = 1;
	$rtn = Data::Dumper::Dumper(\%secs);

	return $rtn;
}
 
sub get_config {
	Apache2::Module::get_config(__PACKAGE__, @_);
}

sub AddAlt {
	push_val_on_key('AddAlt', $_[0], $_[1], join(' ',$_[2],$_[3]));
	push_val_on_key('AddAltRegex', $_[0], $_[1], [( $_[2],glob2regex($_[3]) )]);
}

sub AddAltByEncoding  {
	push_val_on_key('AddAltByEncoding',  @_);
	push_val_on_key('AddAltByEncodingRegex', $_[0], $_[1], [( $_[2],$_[3] )]);
}

sub AddAltByType {
	push_val_on_key('AddAltByType', @_);
	push_val_on_key('AddAltByTypeRegex', $_[0], $_[1], [( $_[2],$_[3] )]);
}

sub AddDescription {
	add_to_key('AddDescription', $_[0], $_[1], $_[3], $_[2]);
}

sub AddIcon {
	push_val('AddIcon', $_[0], $_[1], join(' ',$_[2],$_[3]));
	my $icon = $_[2];
	my $alt = '';
	if ($icon =~ /^\s*\(?(\S+?),(\S+?)\)\s*$/) {
		$alt = $1;
		$icon = $2;
	}
	push_val_on_key('AddIconRegex', $_[0], $_[1],
			glob2regex($_[3]), $alt,$icon,
		);
}

sub AddIconByEncoding {
	push_val_on_key('AddIconByEncoding', @_);
	push_val_on_key('AddIconByEncodingRegex', $_[0], $_[1], [( $_[2],$_[3] )]);
}

sub AddIconByType {
	push_val_on_key('AddIconByType', @_);
	push_val_on_key('AddIconByTypeRegex', $_[0], $_[1], [( $_[2],$_[3] )]);
}

sub IndexIgnore {
	push_val('IndexIgnore', @_);
	push_val('IndexIgnoreRegex', $_[0], $_[1], glob2regex($_[2]));
}

sub IndexOptions      { push_val('IndexOptions',      @_) }
sub DirectoryIndex    { push_val('DirectoryIndex',    @_) }
sub DefaultIcon       { set_val('DefaultIcon',        @_) }
sub HeaderName        { set_val('HeaderName',         @_) }
sub IndexOrderDefault { set_val('IndexOrderDefault',  @_) }



( run in 0.871 second using v1.01-cache-2.11-cpan-39bf76dae61 )