Kit for Chapter 9

Example 1: Reviewable Docbases

To re-create the reviewable-docbase example, see http://udell.roninhouse.com/examples/ReviewableDocbase.zip which includes:

  • Chapter 1, in XML-ized HTML format

  • CSS style sheets for this chapter, and a table of contents

  • A script to transform the XML content into reviewable HTML content

  • Apparatus (a CGI form template, a form generator, and a form handler) used for the newsgroup version of the comment mechanism

The script, reviewable.pl, expects to read chap1.xml and write chap1.htm. It runs in one of two modes, governed by the $protocol variable in the script. If you use $protocol = 'mail', each header and paragraph will end with a link that begins an email message commenting on that element of the document.

If you instead use $protocol = 'news', the script will write a file called nntp_msgs. This file of NNTP messages defines the skeleton of a newsgroup used for collaborative review of the document. If you’re running a local NNTP server (see Chapter 13), you can load these messages into a newsgroup on that server, as shown in Example 9.9.

In the newsgroup version of this application, the links in the generated document will call the script comment.pl, which in turn reads and interpolates values into the form template comment.htm, which form is in turn handled by comment-handler.pl.

Requirement: the Perl XML::Parser module

To run the script, you’ll need Perl and the XML::Parser module. The build-it-yourself version of XML::Parser is on CPAN (http://www.cpan.org/modules/by-module/XML/). Users of ActiveState Perl (http://www.activestate.com/) who can’t or don’t want to build XML::Parser themselves can install a binary version directly from the ActiveState site, like this:

c:> perl ppm 
PPM interactive shell (0.9.5) - type 'help' for available commands. 
PPM> install XML-Parser

Requirement: an NNTP server

This example requires an NNTP server if you want to use the comment mechanism in newsgroup mode. I’ve used INN (available on every Linux CD, or from http://www.isc.org/), Netscape Collabra (see http://www.netscape.com/download/), and the MS NNTP Service in the freely available NT 4.0 Option Pack (http://www.microsoft.com/ntserver/nts/downloads/recommended/nt4optpk/default.asp).

See Chapter 13 for an overview of setting up these servers. For this example, you’ll need to create a newsgroup called groupware.v3.

Requirement: the Perl TinyCGI module

The TinyCGI module (included with the Docbase kit, http://udell.roninhouse.com/examples/Docbase-1.0.tar.gz).

Requirement: the Perl Net::NNTP module

The CPAN libnet bundle (e.g., http://www.cpan.org/modules/by-module/NET/libnet-1.0606.tar.gz) includes Net::NNTP.

Note that a smaller, simpler alternative to the libnet bundle is CPAN’s NNTPClient (http://www.cpan.org/modules/by-module/News/). It’s just a single .pm file that, unlike the more full-featured Net::NNTP, can be easily deployed even on a server that you don’t control—for example, if your application needs to run on an ISP’s server.

Example 2: HelpDesk

Requirement: an NNTP server

See Section 1.4.1 earlier in this appendix. For this example, you’ll need two newsgroups: it.helpdesk.open and it.helpdesk.closed.

Requirement: Net::NNTP

See Section 1.4.1 earlier in this appendix.

Requirement: dhttp kit

You’ll also need the dhttp kit (http://udell.roninhouse.com/examples/dhttp-v2.tar.gz). The mini-web server in that kit is the host for the scripts that support the Web parts of the HelpDesk example.

As explained later in this appendix, you install dhttp by just unzipping into a subdirectory. In the root of that unzipped archive, you’ll find the main dhttp driver script, which is called simply dhttp.

Requirement: a DBI/DBD data source

The HelpDesk app uses an SQL data store to keep track, in a structured way, of trouble tickets that are also posted to the news server for discussion. Linux and NT examples of the dhttp driver script, illustrating two different data-source configurations, are shown in Example 1.1 and Example 1.2.

Example A-1. Configuring the dhttp Driver for HelpDesk: NT Example

#! /usr/bin/perl -w 
 
use strict; 
no strict 'refs'; 
 
use DBI; 
use DBD::ODBC; 
 
$main::debug = 0; 
 
$main::port = $ARGV[0]; 
$main::hostname = 'jon_nt'; 
$main::server = "$main::hostname:$main::port"; 
$main::fontspec = "font size=-1"; 
$main::root = "d:/dhttp/lib/dhttp"; 
 
                        $main::date_delim = "#";     # e.g.: # for ODBC, ' for Solid SQL 
 
use Engine::Server; 
 
$main::hd_dbh = DBI->connect('DBI:ODBC:HD','','') 
    or die ("hd_dbh: cannot connect"); 
use Apps::hd; 
 
Engine::Server::init;

Example A-2. Configuring the dhttp Driver for HelpDesk: Linux Example

#! /usr/bin/perl -w 
 
use strict; 
no strict 'refs'; 
 
use DBI; 
use DBD::Solid; 
 
$main::debug = 0; 
 
$main::port = $ARGV[0]; 
$main::hostname = 'jon_linux'; 
$main::server = "$main::hostname:$main::port"; 
$main::fontspec = "font size=-1"; 
$main::root = "/home/jon/dhttp/lib/dhttp"; 
 
                        $main::date_delim = "'";     # e.g.: # for ODBC, ' for Solid SQL 
 
use Engine::Server; 
 
$main::hd_dbh = DBI->connect('DBI:Solid:tcp 1313','dba','dba')  
    or die ("hd_dbh: cannot connect"); 
use Apps::hd; 
 
Engine::Server::init;

The differences are mainly to do with SQL. In this example, I’m using ODBC to talk to a .MDB file on NT and the Solid server (http://www.solidtech.com/) on Linux. So it’s necessary to adjust the DBI connection strings for each of these data sources as well as the delimiter used to form date literals. Had I used Solid on both NT and Linux, I’d have needed to set only the hostname and the path to the root of the dhttp installation.

Configuring the Apps::hd module for the HelpDesk app

There’s a further bit of configuration in the file ./lib/dhttp/Apps/hd.pm. Here’s the top of that file on my NT machine:

package Apps::hd; 
 
use Engine::PubUtils; 
use Engine::PrivUtils; 
 
$newsroot = "c:/nntpfile/root/it/helpdesk"; 
                     $newshost = "jon_nt"; 
 
use Net::NNTP; 
my $nntp = Net::NNTP->new($newshost); 
 
my $hd_fontspec = "font size=-1"; 
my $approot = "Apps/hd";

In this case, the news host at 'jon_nt' is the MS NNTP Service, rooted at c:/nntpfile/root/it/helpdesk. On my Linux box, running INN, the equivalent lines are:

                     $newsroot = "/var/spool/news/it/helpdesk"; 
                     $newshost = "jon_linux";

Starting the HelpDesk app

With your news server running, you can start dhttp on port 9191 (from its home directory) like this:

perl -Ilib/dhttp dhttp 9191

Initializing the HelpDesk database

The hd::do_hd_makedb( ) function creates the SQL table used by the HelpDesk application. It assumes that the data source named in the dhttp driver script is available. To use hd::do_hd_makedb( ), go to a browser and issue this URL:

http://host:port/hd_makedb

Using the HelpDesk application

To display the home page of the HelpDesk application, go to a browser and issue this URL:

http://host:port/hd_home

Click open a new ticket on the home page to bring up a trouble ticket form. Fill it out and submit it. If things are working properly, you can click view tickets on the home page to view the ticket in the SQL database and click discuss open tickets to launch your newsreader and view the ticket in a newsgroup.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset