1 package System::Introspector::Report::Publish::MediaWiki::Producer;
6 my ($self, $stream) = @_;
7 return $self->_clear_body(join "\n", map {
8 ref($_) ? $self->_render_table($_) : $_;
13 my ($self, $string) = @_;
14 $string =~ s{\n\n+}{\n\n}g;
19 my ($self, $type, $id, $body) = @_;
22 sprintf('<!-- SI:%s begin %s -->', uc($type), $id),
24 sprintf('<!-- SI:%s end %s -->', uc($type), $id),
28 my ($self, $report) = @_;
29 my $id = $report->{id};
30 my $str_id = ref($id) ? join(':', @$id) : $id;
31 my $markup = $self->_load_markup;
32 $markup = $self->_apply_table_head($markup, $report);
33 $markup = $self->_apply_table_body($markup, $report);
34 my $description = $report->{description} || [''];
36 $self->_wrap('title', $str_id, $self->_render_title($report)),
38 $self->_wrap('table', $str_id, $markup->to_html),
43 my ($self, $report) = @_;
44 return sprintf '== %s ==', $report->{title};
47 sub _apply_table_body {
48 my ($self, $markup, $report) = @_;
50 my $rows = $report->{rows};
51 my @cols = map $_->{key}, @{$report->{columns}};
52 return $markup->repeat('.data-row', sub {
53 return HTML::Zoom::CodeStream->new({
55 return if $index > $#$rows;
56 my $row = $rows->[$index++];
58 $_->repeat('td', [ map {
61 my $value = $row->{$col};
63 $_->apply_if($col !~ m{^__}, sub {
64 $_->add_to_attribute('td', class => "si-column-$col");
66 ->replace_content('td', defined($value) ? $value : '')
67 ->apply_if($col_idx != $#cols, sub {
68 $_->add_after('td', "\n ");
80 $string =~ s{(?:^\s+|\s+$)}{}g;
84 sub _apply_table_head {
85 my ($self, $markup, $report) = @_;
86 my @cols = @{$report->{columns}};
91 my $label = $col->{label};
93 $_->apply_if($col->{key} !~ m{^__}, sub {
94 $_->add_to_attribute('th', class => 'si-colhead-' . $col->{key});
96 ->replace_content('th', defined($label) ? $label->$_trim : 'Unnamed')
97 ->apply_if($col_idx != $#cols, sub {
98 $_->add_after('th', "\n ");
111 return HTML::Zoom->from_html($_template);
117 <table class="si-report">
121 <tr class="data-row">