1 package System::Introspector::Report::Publish::MediaWiki::Producer;
6 my ($self, $stream) = @_;
7 return join "\n", map {
8 ref($_) ? $self->_render_table($_) : $_;
13 my ($self, $type, $id, $body) = @_;
16 sprintf('<!-- SI:%s begin %s -->', uc($type), $id),
18 sprintf('<!-- SI:%s end %s -->', uc($type), $id),
22 my ($self, $report) = @_;
23 my $id = $report->{id};
24 my $str_id = ref($id) ? join(':', @$id) : $id;
25 my $markup = $self->_load_markup;
26 $markup = $self->_apply_identity($markup, $report);
27 $markup = $self->_apply_table_head($markup, $report);
28 $markup = $self->_apply_table_body($markup, $report);
29 my $description = $report->{description} || [''];
31 $self->_wrap('title', $str_id, $self->_render_title($report)),
33 $self->_wrap('table', $str_id, $markup->to_html),
38 my ($self, $report) = @_;
39 return sprintf '== %s ==', $report->{title};
43 my ($self, $markup, $report) = @_;
44 my $id = $report->{id};
47 ->set_attribute(id => 'si-id-' . join '__',
48 ref($id) ? @$id : $id,
52 sub _apply_table_body {
53 my ($self, $markup, $report) = @_;
55 my $rows = $report->{rows};
56 my @cols = map $_->{key}, @{$report->{columns}};
57 return $markup->repeat('.data-row', sub {
58 return HTML::Zoom::CodeStream->new({
60 return if $index > $#$rows;
61 my $row = $rows->[$index++];
63 $_->repeat('td', [ map {
66 my $value = $row->{$col};
68 $_->apply_if($col !~ m{^__}, sub {
69 $_->add_to_attribute('td', class => "si-column-$col");
71 ->replace_content('td', defined($value) ? $value : '')
72 ->apply_if($col_idx != $#cols, sub {
73 $_->add_after('td', "\n ");
83 sub _apply_table_head {
84 my ($self, $markup, $report) = @_;
85 my @cols = @{$report->{columns}};
91 $_->apply_if($col->{key} !~ m{^__}, sub {
92 $_->add_to_attribute('th', class => 'si-colhead-' . $col->{key});
94 ->replace_content('th', $col->{label})
95 ->apply_if($col_idx != $#cols, sub {
96 $_->add_after('th', "\n ");
103 return HTML::Zoom->from_html(do {
112 <table class="si-report">
116 <tr class="data-row">