Apache-NavBarDD
view release on metacpan or search on metacpan
NavBarDD.pm view on Meta::CPAN
package Apache::NavBarDD;
# file Apache/NavBarDD.pm
use 5.0006;
use strict;
use Apache::Constants qw(:common);
use Apache::File ();
use Apache::URI ();
our $VERSION = '0.75';
my %BARS = ();
# Define default values for the NavBarDD's objects attributes.
# $master_table_atts defines the attributes for the master table.
my $master_table_atts=<<EOF;
CELLSPACING="0" CELLPADDING="1" BORDER="0" WIDTH="600"
EOF
# $vassal_table_atts defines the attributes for the vassal table.
my $vassal_table_atts=<<EOF;
CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="100%" ALIGN="CENTER"
EOF
# $master_padding defines the HTML element to be used between the elements
# of the master table.
my $master_padding=<<EOF;
<TD BGCOLOR="#FFFFFF" WIDTH="2"><FONT SIZE="2"> </FONT></TD>
EOF
# $vassal_padding defines the HTML element to be used between the elements
# of the vassal table.
my $vassal_padding=<<EOF;
<TD NOWRAP BGCOLOR="#FFFFCC" WIDTH="10">
<FONT SIZE="2" COLOR="#336699"> |
</FONT></TD>\n
EOF
# $style defines the HTML style element to be used as a default CSS.
my $style=<<EOF;
<style>
td.master-active {
height: 2ex;
font-family: helvetica,arial;
font-weight: bold;
font-size: 10pt;
color: #003366;
background-color: #FFFFCC;
text-align: center
}
td.master-normal {
height: 2ex;
font-family: helvetica,arial;
font-size: 10pt;
color: #FFFFFF;
background-color: #006633;
text-align:center;
}
td.vassal-active {
height: 4ex;
font-family: helvetica,arial;
font-size: 7pt;
color: #006633;
background-color: #FFFFFF;
}
td.vassal-normal {
height: 4ex;
font-family: helvetica, arial;
font-size: 7pt;
color: #006633;
background-color: #FFFFCC;
}
a.master {
text-decoration: none;
color: #FFFFFF;
}
a.vassal {
text-decoration: none;
color: #006633;
}
</style>
EOF
# if $bottom the bar is displayed both on the top and on the bottom
# of the page.
my $bottom = 0;
# $depth is the vassal bar's depth down the document hierarchy.
my $depth = 2;
sub handler($$) {
my ($self, $r) = @_;
my $bar = $self->read_configuration($r) || return DECLINED;
$r->content_type eq 'text/html' || return DECLINED;
my $fh = Apache::File->new($r->filename) || return DECLINED;
# the following handle caching; they stand in the way when
# making changes to the code, so use them wisely
# $r->update_mtime($bar->modified);
# $r->set_last_modified;
# my $rc = $r->meets_conditions;
# return $rc unless $rc == OK;
$r->send_http_header;
return OK if $r->header_only;
my $before = $self->before;
my $style = $self->style;
my $master_table_atts = $self->master_table_atts;
my $vassal_table_atts = $self->vassal_table_atts;
my $master_padding = $self->master_padding;
my $vassal_padding = $self->vassal_padding;
my $after = $self->after;
my $navbar = $self->make_bar($r, $bar);
local $/ = "";
while (<$fh>) {
s:(</HEAD>):$style$1:oi;
s:(<BODY.*?>):$1$before$navbar$after:osi;
s:(</BODY.*?>):$navbar$1:osi if $self->bottom;
} continue {
$r->print($_);
}
return OK;
NavBarDD.pm view on Meta::CPAN
/site/FAQ/B/B.html B
/site/FAQ/A/C.html C
/site/FAQ/D/D.html D
When selecting the FAQ tab, the user automatically gets C<C.html> as body,
with C<C> selected in the vassal bar.
If no vassals at all are found we get a one-level navigation bar.
=head1 CONSTRUCTOR
=over 4
=item new Apache::NavBarDD [ OPTIONS ]
This is the constructor for a new Apache::NavBarDD object.
C<OPTIONS> are passed in a hash-like fashion, using key and value pairs.
Possible options are:
B<style> - An HTML C<style> element describing the navigation bar's style. The
navigation bar uses the following style classes:
=over 4
=item *
C<td.master-active> - Master bar, selected item.
=item *
C<td.master-normal> - Master bar, normal item.
=item *
C<td.vassal-active> - Vassal bar, selected item.
=item *
C<td.vassal-normal> - Vassal bar, normal item.
=item *
C<a.master> Anchors in master bar.
=item *
C<a.vassal> Anchors in vassal bar.
=back
The default value of C<style> is:
<style>
td.master-active {
height: 2ex;
font-family: helvetica,arial;
font-weight: bold;
font-size: 10pt;
color: #003366;
background-color: #FFFFCC;
text-align: center
}
td.master-normal {
height: 2ex;
font-family: helvetica,arial;
font-size: 10pt;
color: #FFFFFF;
background-color: #006633;
text-align:center;
}
td.vassal-active {
height: 4ex;
font-family: helvetica,arial;
font-size: 7pt;
color: #006633;
background-color: #FFFFFF;
}
td.vassal-normal {
height: 4ex;
font-family: helvetica, arial;
font-size: 7pt;
color: #006633;
background-color: #FFFFCC;
}
a.master {
text-decoration: none;
color: #FFFFFF;
}
a.vassal {
text-decoration: none;
color: #006633;
}
</style>
B<master_table_atts> - The HTML C<table> attributes that apply to the master
table. The default are:
C<CELLSPACING="0" CELLPADDING="1" BORDER="0" WIDTH="600">
B<vassal_table_atts> - The HTML C<table> attributes that apply to the vassal
table. The default are:
C<CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="100%" ALIGN="CENTER">
B<master_padding> - The HTML C<td> element that is used as padding between two
cells in the master table. The default is:
C<< <TD BGCOLOR="#FFFFFF" WIDTH="2"><FONT SIZE="2"> </FONT></TD> >>
B<vassal_padding> - The HTML C<td> element that is used as padding between two
cells in the vassal table. The default is:
C<< <TD NOWRAP BGCOLOR="#FFFFCC" WIDTH="10">
<FONT SIZE="2" COLOR="#336699"> |
</FONT></TD>\n >>
B<before> - An HTML element providing a header to be inserted before the
navigation bar. Default is empty.
B<after> - An HTML element providing a header to be inserted after the
navigation bar. Default is empty.
B<bottom> - A flag specifying, if set, to output the navigation bar on the
bottom as well as on the top of the page. Unset by default.
B<depth> - The depth of the directory hierarchy that is taken into account
when building the master bar; directories one level further down
are taken into account for the vassal bar. Default is 2.
=back
=head1 METHODS
=over 4
=item style ( [ STYLE ] )
If called without an argument, returns the bar's current style. C<STYLE> is
an HTML C<style> element describing the navigation bar's style.
( run in 2.200 seconds using v1.01-cache-2.11-cpan-d8267643d1d )