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 ...

Get Practical Internet Groupware now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.