Apache-SetWWWTheme
view release on metacpan or search on metacpan
SetWWWTheme.pm view on Meta::CPAN
$r->log_error("Couldn't open $filename for reading: $!");
return SERVER_ERROR;
}
$r->register_cleanup(sub {close $fh}); # register a cleanup for the filehandle
local $/ = undef; # Read in the whole schmear.
while (<$fh>)
{
s|<A\W+HREF[^>]+>||ig; # wipes out our links
s|</A>||ig;
my $return = $r->uri;
s|</BODY>|<A HREF=\"$return\"><H6>return...</H6></A></BODY>|ig;
$r->print($_); # dumps the results to apache
}
return 1; # and tell it we finished.
}
1;
# May a thousand locusts descend upon pod.
=head1 NAME
Apache::SetWWWTheme - Standard theme generation, including sidebars and navigation bars
=head1 SYNOPSIS
Within the httpd.conf or other apache configuration file:
<Location /some/subtree>
SetHandler perl-script
PerlHandler Apache::SetWWWTheme
PerlSetVar CONFIG_FILE /WWWroot/configfile
</Location>
=head1 REQUIREMENTS
This module requires the Apache server, available from
http://www.apache.org; the Apache B<mod_perl> module, which is
available from http://perl.apache.org, and the B<module
HTML::WWWTheme>, by Chad Hogan (version 1.06 or greater) which may
be found at CPAN.
=head1 DESCRIPTION
The SetWWWTheme module provides a server-based look-and-feel configuration for
an entire webtree. This module allows the server to introduce a common
navigation side-bar. It also provides mechanisms to control the background
color and background picture for a web page.
This is implemented in a layered fashion. The module first reads the server
directives. This sets defaults, and decides what users may have control
over. Server directives may only be set by the webmasters. Following these,
the module reads local directives. These directives are specified in a file,
and will affect all files in that same directory, as well as subdirectories
underneath it. They are set at the user-level, and so they are subject to
the constraints imposed by the server directives. Finally, the module parses
the individual HTML files. Within a file, an HTML authour may override the
settings given in the local directives. Again, these are subject to the
constraints of the server directives.
Please note that you are not required to change anything in your pages. Your
unmodified HTML will work just fine with this module. You are required to
make changes only if you wish to take advantage of the features offered.
=item Server-level configuration
At the server level, the webmaster has full access to all directives. These
tags are specified in a file that is set in the httpd.conf file. If a
webmaster would like his/her subtree to use the module, a <LOCATION> tag is
used to activate the module. A PerlSetVar is used to tell the module the
name of the configuration file. Here is an example:
<Location />
SetHandler perl-script
PerlHandler Apache::SetWWWTheme
PerlSetVar CONFIG_FILE /WWW/ServerConfig
</Location>
This example will use the module for the entire document tree. The
CONFIG_FILE variable is used by the module to look for the file that
controls the defaults for the entire site. Please note that CONFIG_FILE
takes the full path to the file name on the file-system -- do not list this
file relative to the document root.
The creation of printable versions of pages has been greatly simplified.
No longer is any configuration required -- the page is automatically
generated using a GET method. Adding "?printable" to a URI will
cause the page to be displayed in a printable manner, for example.
The server-level configuration is primarily to set defaults. It is also to
set restrictions on the configurability of the rest of the site. The
server-level configuration decides whether or not individual authours will
be permitted to, for example, change the background colour and background
image of their web pages.
Once again, the server configuration may make use of all of the following
directives. The server then decides which of these the users may override.
Local configuration
Any authour may create a text file containing directives. The name of this file
is set by the server directive @LOCALCONFIGFILE, with a default of
LookAndFeelConfig. This file will
affect all HTML files within that directory, as well as any subdirectories.
These directives are subject to the restrictions placed by the server-level
configuration. This file is intended to be used to set common settings for a
tree. For example, one may wish to set the background colour for an entire
tree to white. Then a @BGCOLOR=#FFFFFF; directive in the local config file.
file will set this. Directives that are explicitly set override the server
settings (if allowed). Otherwise, the server's settings persist.
Individual file configuration
This is the final level of configuration. Any authour may embed directives
within a comment tag in an HTML file, as long as this tag appears before the
<BODY> tag. Directives that are explicitly set override the local
configuration and/or server settings (if allowed). Otherwise, the local
settings and the server settings persist.
=item Module directives
Directives consist of a series of tags within a text file, or within an html
comment block before the <BODY> tag. Valid directive tags are always
terminated with a semicolon. For tags that accept lists as values, elements
are separated by commas. Semicolons may be escaped within a tag. Any
semicolon preceded by a backslash will be considered text, and will not terminate
the directive. The final text will have the escaped semicolon replaced with
a bare semicolon.
@DIRECTIVE=Some string of text\; semicolons are escaped.;
The above directive would set a value of "Some string of text; semicolons
are escaped."
=item @ALINK
HTML and local configuration subject to server configuration
This tag is used to set the HTML BODY setting "alink". This is the
active link color. It is subject to the setting of the @ALLOWBODYMOD
tag. If @ALLOWBODYMOD is set to a non-zero value, @ALINK will set this
attribute in the page. Here is an example:
@ALINK=#FF00FF;
=item @ALLOWBODYMOD
Server configuration only
This tag is used to allow or disallow users from changing BODY
elements. These include "alink", "vlink", "link", "text", "bgcolor",
and "background" items using the directives @ALINK, @VLINK, @LINK,
@TEXT, @BGCOLOR and @BGPICTURE respectively. If it is set to a non-zero
value, the user's directives will be read and used. Otherwise, user
settings will be ignored, and only the server configuration values will
be used in creating the <BODY> tag for the page. Here is an example:
@ALLOWBODYMOD=1;
( run in 0.594 second using v1.01-cache-2.11-cpan-39bf76dae61 )