|
HTML::WWWTheme - Standard theme generation, including sidebars and navigation bars |
HTML::WWWTheme - Standard theme generation, including sidebars and navigation bars
use HTML::WWWTheme; my $Theme = new HTML::WWWTheme(@args);
Nothing special -- Perl 5 or newer.
HTML::WWWTheme is a module that creates a standard sidebar and implements local colour conventions. It is used by the Apache::SetWWWTheme module to enforce this through the server. In fact, the code in this module was originally contained within the SetWWWTheme module, but at the suggestion of Tim Jenness, I separated this module to allow CGI programs to create standard pages that would fit in with the static pages that are automatically rewritten by the Apache module. So, static pages in the web tree are filtered through Apache::SetWWWTheme, and CGI-generated pages are generated with the help of HTML::WWWTheme. In this manner, a consistent look and feel can be maintained in all pages. Any changes in the structure of WWWTheme are automatically reflected in both the CGI-generated and static pages.
The new() function will return a reference to a Theme object. It will accept an
array of arbitrary length as arguments. Each element of this array must be a fully
qualified path to a configuration file.
Configuration is accomplished in three ways. First, one may pass arguments to the
new() function. These arguments must be fully qualified paths to a configuration file.
The syntax of the directives in this file is simple:
@DIRECTIVE=value;
for example,
@BGCOLOR=#FFFFFF;
or, in the case of a directive that accepts a list, the values are comma-separated and semi-colon terminated. Escaped semi-colons will be transformed into semi-colons, and will not terminate the directive.
@DIRECTIVE=value1, value2, value3;
@DIRECTIVE=value1, value2\; still going, value3;
In the second example, the value2\; will be replaced with value2; in the parsed text.
for example,
@INFO=<A HREF="here.html">Here</a>, <A HREF="there.html">There</a>;
Second, the GetConfiguration() function may be passed a list of full-paths to configuration
files. The GetConfiguration() function will parse these files and set the appropriate values.
Finally, one may use methods to directly change the settings of the page before it is produced. This is the recommended method, because it is the most intuitive and the easiest to figure out when you're trying to figure out someone else's code. I use these methods extensively in my Apache::SetWWWTheme module.
The following are all the methods that may be used to control the behaviour of the module.
GetConfiguration()@DIRECTIVE=value;
or, in the case of a list-value (for example, with the infolinks that make up the links on the sidebar under ``More Links'' or ``More Info'')
@DIRECTIVE=value1, value2, value3;
Valid directives are listed, along with the corresponding method that performs the same method:
@BLANKGIF (see SetBlankGif() ) @NAVBAR (see SetUseNavBar() ) @NEXTLINK (see SetNextLink() ) @LASTLINK (see SetLastLink() ) @UPLINK (see SetUpLink() ) @BGCOLOR (see SetBGColor() ) @BGPICTURE (see SetBGPicture() ) @BACKGROUND (see SetBGPicture() ) @ALINK (see SetALink() ) @LINK (see SetLink() ) @VLINK (see SetVLink() ) @SIDEBARTOP (see SetSideBarTop() ) @SIDEBARMENUTITLE (see SetSidebarMenuTitle() ) @SIDEBARSEARCHBOX (see SetSideBarSearchBox() ) @SIDEBARCOLOR (see SetSideBarColor() ) @SIDEBARWIDTH (see SetSideBarWidth() ) @NOSIDEBAREXTRAS (see SetNoSideBarExtras() ) @MORELINKSTITLE (see SetMoreLinksTitle() ) @INFO (see SetInfoLinks() ) @SIDEBARMENULINKS (see SetSideBarMenuLinks() )
MakeFooter()MakeHeader()MakeNavBar()SetNextLink()
$Theme->SetNextLink('<A HREF="http://somewhere.com">somewhere</a>');
SetLastLink()
$Theme->SetLastLink('<A HREF="http://here.com">here</a>');
SetUpLink()
$Theme->SetUpLink('<A HREF="http://there.com">there</a>');
SetBGColor()
$Theme->SetBGColor("#CCFFFF");
SetBGPicture()
$Theme->SetBGPicture("/WWW/images/wallpaper.gif");
SetVLink()
$Theme->SetALink("#FFCCFF");
$Theme->SetVLink("#FFCCFF");
$Theme->SetLink ("#FFCCFF");
SetMoreLinksTitle()
$Theme->SetMoreLinksTitle("More useful links");
SetNoSideBarExtras()
$Theme->SetNoSideBarExtras("1");
SetHTMLStartString()
$Theme->SetHTMLStartString("<HTML><HEAD><TITLE>This is my page.</TITLE></HEAD>");
SetHTMLEndString()
$Theme->SetHTMLEndString("</HTML>");
SetPrintableName()
$Theme->SetPrintableName("/printable/path/to/file.html");
SetText()
$Theme->SetText("#000000");
SetSideBarColor()
$Theme->SetSideBarColor("#FFCCFF");
SetSideBarWidth()
$Theme->SetSideBarWidth("120");
SetBlankGif()
$Theme->SetBlankGif("/WWW/images/blank.gif");
SetInfoLinks()
@array = ('<a href="here.html">here</a>', '<a href="there.html">there</a>');
$Theme->SetInfoLinks(\@array);
SetSideBarTop()
$Theme->SetSideBarTop('<A HREF="/">My Webserver</a>');
SetSearchTemplate()<B>Search JAC</B><BR><HR> <DIV align="center"> <form method="POST" action="/cgi-bin/isearch"> <input name="SEARCH_TYPE" type=hidden value="ADVANCED"> <input name="HTTP_PATH" type=hidden value="/WWW"> <input name="DATABASE" type=hidden value="webindex"> <input name="FIELD_1" type=hidden value="FULLTEXT"> <input name="WEIGHT_1" type=hidden value= "1"> <input name="ELEMENT_SET" type=hidden value="TITLE"> <input name="MAXHITS" type=hidden value="50"> <input name="ISEARCH_TERM" size="14" border="0"> </form> </DIV> <H6><a href="http://www.yoursite.edu/search.html">More searching....</a></h6>
Your template must be customized as appropriate for your engine, of course. This template should be passed to the SetSearchTemplate function as one big string.
SetSideBarMenuLinks()
@array = ('<a href="here.html">here</a>', '<a href="there.html">there</a>');
$Theme->SetSideBarMenuLinks(\@array);
SetSideBarMenuTitle()
$Theme->SetSideBarMenuTitle("Main Sections");
SetSideBarSearchBox()
$Theme->SetSideBarSearchBox("1");
SetUseNavBar()Set__Link() methods.
$Theme->SetUseNavBar("1");
SetTopBottomLinks()
@array = ('<a href="here.html">here</a>', '<a href="there.html">there</a>');
$Theme->SetTopBottomLinks(\@array);
StartHTML()print $Theme->StartHTML();
EndHTML()print $Theme->EndHTML();
The MakeNavBar() function may be used to create the top/bottom navigation bar. This bar contains
the previous/up/next links. It takes no arguments, but uses the [next|last|up]link keys in the hash.
Finally, the MakeFooter() function is used to end the html file. This function is absolutely necessary, as
the page won't render without it! The tables will not be finished, and very few browswers can deal with this.
Here is a simple but functional example. Notice that there are no <BODY> tags. The header and footer take care of this. Write your HTML as if you were writing between the <BODY> and </BODY> tags.:
#!/usr/bin/perl -w
use strict; use HTML::WWWTheme;
# read in a few defaults
my $Theme = new HTML::WWWTheme("/WWW/LookAndFeel", "/home/chogan/Lookandfeel");
# set a few things by hand
$Theme->SetBlankGif("/WWW/images/blank.gif");
$Theme->SetBGColor("#FFFFFF");
$Theme->SetHTMLStartString("<HTML><HEAD><TITLE>My Example.</TITLE></HEAD>");
$Theme->SetHTMLEndString("</HTML>");
# make the header, navbar, body, navbar, footer. print $Theme->StartHTML(); print $Theme->MakeHeader(); print $Theme->MakeTopBottomBar(); print $Theme->MakeNavBar(); print "This is the body of my file. Isn't it groovy?"; print $Theme->MakeNavBar(); print $Theme->MakeTopBottomBar(); print $Theme->MakeFooter(); print $Theme->EndHTML(); exit 0;
the Apache::SetWWWTheme manpage
Copyright (C) 2000 Chad Hogan (chogan@uvastro.phys.uvic.ca) Copyright (C) 2000 Joint Astronomy Centre
All rights reserved. HTML::WWWTheme is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 or (at your option) any later version.
HTML::WWWTheme is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with HTML::WWWTheme; see the file gpl.txt. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
HTML::WWWTheme - Standard theme generation, including sidebars and navigation bars |