| Perlbug documentation | view source | Contained in the Perlbug distribution. |
Perlbug::Format - Format class
Supplies formatting methods for object data, according to the currently supported format types:
a ascii short - minimal listings default for mail interface
A ASCII long - maximal block style listings
d debug short - a|h with object attributes (unsupported)
D debug long - A|H with object attributes (unsupported)
h html short - minimal listings default for web interface
H HTML long - maximal block style listings
i id short - minimal id style listings
I id HTML - like i, but with html links
l lean list - ascii but purely for parsing minimal data
L lean HTML - like l, but with html links
x xml short - placeholder
X XML short - placeholder
User rights determine what data is seen and how it will be presented pro option
Ascii:
guest: user: $userid admin: user: $userid pass: $passwd
Html:
<pre> guest: user: $userid admin: user: <input type=text value="$userid"> pass: <input type=text value="$passwd"> <submit name=change> </pre>
use Perlbug::Format;
my $o_fmt = Perlbug::Format->new();
print $o_fmt->object('patch')->read('123')->format('l');
Create new Format object:
my $o_fmt = Perlbug::Format->new();
All objects may provide their own formatting methods, these are offered as catchalls
Wrapper for format -> FORMAT
my $formatted_str = $o_fmt->FORMAT('a'); # ([aAhHlL])...
This uses the internal object structure 'data'.
Note that you can also give these data hashes directly as in the following example:
my $formatted_str = $o_fmt->FORMAT('a', { 'this' => 'data' }, { 'ext: over' => 'here :-)' });
Format individual entries for output, handles all available objects
Certain keywords to be careful of here: keys for objects and for relations(ids, count, names)
my $h_data = $o_fmt->format_fields($h_data, [$fmt, [$i_max]]);
Returns data all on a single level
$h_bug = {
'bugid' => '19870502.007',
'user' => {
'count' => 1,
'ids' => [qw(richardf)],
}
Becomes: $h_bug = { 'bugid' => '19870502.007', 'user_count' => 1, 'user_ids' => [qw(richardf)], 'user_names' => ['Richard Foley'], }
my \%data = $o_fmt->normalize(\%data);
Returns args generically wrapped for ascii presentation
my \%data = $o_fmt->asciify(\%data);
Returns args generically wrapped with html tags - way too convoluted.
my \%data = $o_fmt->htmlify(\%data);
Parse email address given into RFC-822 compatible format, also removes duplicates.
With optional address(only) or format(whole string) requested, defaults to address.
my @parsed = $o_fmt->parse_addrs(\@original_addrs, 'address|format');
Return list of perlbug.cgi?req=key_id&... hyperlinks to given list).
Maintains format, rng etc.
my @links = $o_fmt->href( 'bug_id', \@bids, 'visible element of link', [subject hint], [\@boldids], $js, $fmt );
Or
my @links = $o_fmt->href( 'query&status=open', [], 'open bugs', 'Click to see open bugs', );
Return mailto: for a particular ticket
my $mailto = $o_fmt->mailto($h_tkt);
Richard Foley perlbug@rfi.net 2000 2001
| Perlbug documentation | view source | Contained in the Perlbug distribution. |