O'Reilly logo

Practical Internet Groupware by Jon Udell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Previewing Docbase Records

In any system that transforms raw input into HTML pages, it’s crucial to show the user a preview of the page exactly as it will finally appear. Although each Docbase instance provides its own input-validation script, all instances share a common previewing service provided by Docbase::Input. Its _previewDoc( ) method interpolates user-supplied input into the docbase template, activates mailto: and http:// URLs found in the input, and then shows the user what the final docbase record will look like when actually stored and then rendered as an HTML page. Figure 6.3 shows what a preview looks like when the validation script found warnings but no errors.

Docbase record preview, with optional changes

Figure 6-3. Docbase record preview, with optional changes

The preview contains two versions of the record. One appears on the preview form. The other is encoded as a set of hidden variables within the form, ready to be passed along to the handler that will store them if the user presses the Submit button. As shown in Example 6.6, the _previewDoc( ) method wires the preview form to final-submit.pl, a standard component that’s used, unmodified, by every Docbase instance.

Example 6-6. The _previewDoc Method

sub _previewDoc { my ($self,$vars) = @_; my $app = $self->{app}; my $cgi_absolute = $self->{docbase_cgi_absolute}; my $cgi_relative = $self->{docbase_cgi_relative}; my $preview = ''; $preview .= "<form method=post ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required