/[pub]/suikawiki/script/misc/plugins/BugTrack.pm
Suika

Contents of /suikawiki/script/misc/plugins/BugTrack.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Sun Jun 1 07:01:58 2003 UTC (21 years, 10 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
New

1 ## This file is auto-generated (at 2003-05-31T11:44:28Z).
2 ## Do not edit by hand!
3
4 =head1 NAME
5
6 SuikaWiki::Plugin::BugTrack --- Wiki BugTracking System
7 <IW:SuikaWiki:"SuikaWiki//BugTrack">
8
9
10 =cut
11
12 package SuikaWiki::Plugin::BugTrack;
13 use strict;
14 our $VERSION = q(2003.0531.1144);
15
16 my $NS_XHTML1 = 'http://www.w3.org/1999/xhtml';
17
18 sub import {
19 my $self = shift;
20 $self->SuikaWiki::Plugin::regist (qw/wikibt__bug_table_header wikiview wikiview_resource wikibt__bug_item wikiform_input/);
21 }
22
23 sub property ($;@) {
24 shift;
25 my %prop = (
26 name => q(Wiki BugTracking System),
27 version => $VERSION,
28 uri => q(IW:SuikaWiki:"SuikaWiki//BugTrack"),
29 description => q(),
30 provide => [qw/wikibt__bug_table_header wikiview wikiview_resource wikibt__bug_item wikiform_input/],
31 partinfo => {
32 q(wikiform_input/bt__bug_list) => {FullName => q(Bug list), description => q()},
33 q(wikibt__bug_table_header/no) => {FullName => q(Table heading cell), description => q()},
34 q(wikibt__bug_table_header/subject) => {FullName => q(Table heading cell), description => q()},
35 q(wikibt__bug_table_header/priority) => {FullName => q(Table heading cell), description => q()},
36 q(wikibt__bug_table_header/status) => {FullName => q(Table heading cell), description => q()},
37 q(wikibt__bug_table_header/category) => {FullName => q(Table heading cell), description => q()},
38 q(wikibt__bug_table_header/-bare_text) => {FullName => q(#text), description => q()},
39 q(wikibt__bug_item/-bare_text) => {FullName => q(#text), description => q()},
40 q(wikibt__bug_item/no) => {FullName => q(Bug number), description => q()},
41 q(wikibt__bug_item/subject) => {FullName => q(Bug subject), description => q()},
42 q(wikibt__bug_item/category) => {FullName => q(Bug category), description => q()},
43 q(wikibt__bug_item/status) => {FullName => q(Bug status), description => q()},
44 q(wikibt__bug_item/priority) => {FullName => q(Bug priority), description => q()},
45 q(wikiview_resource/bt__bug_no) => {FullName => q(Bug number), description => q()},
46 q(wikiform_input/bt__create_new_bug) => {FullName => q(Create a new bug page), description => q()},
47 q(wikiview/bt__create_new_bug) => {FullName => q(Create a new bug page), description => q()},
48 },
49 );
50 if (scalar @_ == 0) {
51 \%prop;
52 } else {
53 @prop{@_};
54 }
55 }
56 sub load_formatter ($$%) {
57 my $self = shift;
58 my ($fmt, %q) = @_;
59 unless ($q{type}) {
60 #
61 }
62 elsif ($q{type} eq 'wikibt__bug_item') {
63 $fmt->{q(-bare_text)} = sub { my ($r, $p, $o) = ('', @_);
64 $r = SuikaWiki::Markup::XML->new (type => '#text', value => $p->{-bare_text});
65 $r };
66
67 $fmt->{q(category)} = sub { my ($r, $p, $o) = ('', @_);
68 $r = __PACKAGE__->make_cell ($o, $p, $o->resource ('Plugin:BugTrack:Category:'.($o->{bt__bug}->{prop}->{Category}||'(default)')));
69 $r };
70
71 $fmt->{q(no)} = sub { my ($r, $p, $o) = ('', @_);
72 $r = __PACKAGE__->make_cell ($o, $p, SuikaWiki::Plugin::WikiLinking->to_wikipage_in_html ({
73 label => qq'%link-to-it(label=>{$o->{bt__bug}->{bug_no}},description=>{%page-name(absolute);}p);',
74 }, {
75 base => $o->{bt_bug}->{bug_ns},
76 page_name_relative => $o->{bt__bug}->{bug_page},
77 }, {
78 o => $o,
79 }));
80 $r };
81
82 $fmt->{q(priority)} = sub { my ($r, $p, $o) = ('', @_);
83 $r = __PACKAGE__->make_cell ($o, $p, $o->resource ('Plugin:BugTrack:Priority:'.($o->{bt__bug}->{prop}->{Priority}||'(default)')));
84 $r };
85
86 $fmt->{q(status)} = sub { my ($r, $p, $o) = ('', @_);
87 $r = __PACKAGE__->make_cell ($o, $p, $o->resource ('Plugin:BugTrack:Status:'.($o->{bt__bug}->{prop}->{Status}||'(default)')));
88 $r };
89
90 $fmt->{q(subject)} = sub { my ($r, $p, $o) = ('', @_);
91 $r = __PACKAGE__->make_cell ($o, $p, SuikaWiki::Plugin::WikiLinking->to_wikipage_in_html ({
92 label => qq'%link-to-it(label=>{$o->{bt__bug}->{prop}->{Subject}},description=>{%page-name(absolute);}p);',
93 }, {
94 base => $o->{bt_bug}->{bug_ns},
95 page_name_relative => $o->{bt__bug}->{bug_page},
96 _with_lm => 1,
97 }, {
98 o => $o,
99 }));
100 $r };
101
102 }
103 elsif ($q{type} eq 'wikibt__bug_table_header') {
104 $fmt->{q(-bare_text)} = sub { my ($r, $p, $o) = ('', @_);
105 $r = SuikaWiki::Markup::XML->new (type => '#text', value => $p->{-bare_text});
106 $r };
107
108 $fmt->{q(category)} = sub { my ($r, $p, $o) = ('', @_);
109 $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'th');
110 $r->append_node ($o->resource ('Plugin:BugTrack:Column:'.$p->{-rule_name}), node_or_text => 1);
111 $r->set_attribute (scope => 'cols');
112 $r };
113
114 $fmt->{q(no)} = sub { my ($r, $p, $o) = ('', @_);
115 $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'th');
116 $r->append_node ($o->resource ('Plugin:BugTrack:Column:'.$p->{-rule_name}), node_or_text => 1);
117 $r->set_attribute (scope => 'cols');
118 $r };
119
120 $fmt->{q(priority)} = sub { my ($r, $p, $o) = ('', @_);
121 $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'th');
122 $r->append_node ($o->resource ('Plugin:BugTrack:Column:'.$p->{-rule_name}), node_or_text => 1);
123 $r->set_attribute (scope => 'cols');
124 $r };
125
126 $fmt->{q(status)} = sub { my ($r, $p, $o) = ('', @_);
127 $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'th');
128 $r->append_node ($o->resource ('Plugin:BugTrack:Column:'.$p->{-rule_name}), node_or_text => 1);
129 $r->set_attribute (scope => 'cols');
130 $r };
131
132 $fmt->{q(subject)} = sub { my ($r, $p, $o) = ('', @_);
133 $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'th');
134 $r->append_node ($o->resource ('Plugin:BugTrack:Column:'.$p->{-rule_name}), node_or_text => 1);
135 $r->set_attribute (scope => 'cols');
136 $r };
137
138 }
139 elsif ($q{type} eq 'wikiform_input') {
140 $fmt->{q(bt__bug_list)} = sub { my ($r, $p, $o) = ('', @_);
141 $p->{ns} ||= $o->{page};
142 $p->{ns} .= '//' if substr ($p->{ns}, -2) ne '//';
143 my @bugs = grep m!//[0-9]+$!, $o->_database->list_items ({ns => $p->{ns}, type => 'key', recursive => 0});
144 my $props = '%no;%status;%priority;%category;%subject;';
145 my $fmt = $o->formatter ('bt--bug-table-header');
146 $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'table');
147 $r->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'thead')
148 ->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'tr')
149 ->append_node ($fmt->replace ($props, $o, {formatter => $fmt}));
150 $r->append_text ("\n");
151 $fmt = $o->formatter ('bt--bug-item');
152 my $tb = $r->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'tbody');
153 my $weight = {
154 Priority => {high => 1, normal => 2, low => 3},
155 Status => {open => 1, reserved => 2, closed => 3},
156 };
157 for $_ (sort {
158 $weight->{Status}->{$a->{prop}->{Status}||'open'}
159 <=> $weight->{Status}->{$b->{prop}->{Status}||'open'}
160 || $weight->{Priority}->{$a->{prop}->{Priority}||'normal'}
161 <=> $weight->{Priority}->{$b->{prop}->{Priority}||'normal'}
162 || $a->{prop}->{Category} cmp $b->{prop}->{Category}
163 || $b->{bug_no} <=> $a->{bug_no}
164 } map {{
165 bug_ns => $p->{ns},
166 bug_page => $_,
167 bug_no => do {$_ =~ m!//([0-9]+)$!; $1},
168 prop => __PACKAGE__->get_bug_properties ($_),
169 }} @bugs) {
170 $o->{bt__bug} = $_;
171 $tb->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'tr')
172 ->append_node ($fmt->replace ($props, $o, {formatter => $fmt}));
173 $tb->append_text ("\n");
174 }
175 $r };
176
177 $fmt->{q(bt__create_new_bug)} = sub { my ($r, $p, $o) = ('', @_);
178 $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'form');
179 $r->set_attribute (action => $o->uri ('wiki'));
180 $r->set_attribute (method => 'post');
181 $r->set_attribute ('accept-charset' => 'iso-2022-jp, utf-8');
182 $r->set_attribute (class => 'bt--create-bug');
183 for ($r->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'input')) {
184 $_->set_attribute (type => 'hidden');
185 $_->set_attribute (name => 'mode');
186 $_->set_attribute (value => 'bt--bug-create');
187 }
188 for ($r->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'input')) {
189 $_->set_attribute (type => 'hidden');
190 $_->set_attribute (name => 'mypage');
191 $_->set_attribute (value => ($p->{ns} || $o->{page}));
192 }
193 $r->append_node ($p->{content}, node_or_text => 1);
194 $r };
195
196 }
197 elsif ($q{type} eq 'wikiview') {
198 $fmt->{q(bt__create_new_bug)} = sub { my ($r, $p, $o) = ('', @_);
199 my @page = ('#?SuikaWiki/0.9');
200 for (qw/Subject Priority Status Category/) {
201 push @page, '- ' . $_ . ': ' . $main::form{'wikiform__'.$_};
202 }
203 push @page, '- Creation-Date: ' . main::_rfc3339_date (time);
204 push @page, '';
205 push @page, '[1] ' . $main::form{'wikiform__body'};
206
207 $p->{ns} ||= $o->{page};
208 $p->{ns} .= '//' if substr ($p->{ns}, -2) ne '//';
209 my $page = $p->{ns} . __PACKAGE__->get_new_bug_number ($p->{ns});
210 $main::database{$page} = join "\n", @page;
211 $o->{bt__bug} = {
212 bug_ns => $p->{ns},
213 bug_page => $page,
214 bug_no => do {$page =~ m!//([0-9]+)$!; $1},
215 prop => __PACKAGE__->get_bug_properties ($page),
216 };
217 $r };
218
219 }
220 elsif ($q{type} eq 'wikiview_resource') {
221 $fmt->{q(bt__bug_no)} = sub { my ($r, $p, $o) = ('', @_);
222 $r = SuikaWiki::Markup::XML->new (type => '#text', value => $o->{bt__bug}->{bug_no});
223 $r };
224
225 }
226 } # sub load_formatter
227
228 sub get_bug_properties ($$) {
229 my (undef, $bug_page) = @_;
230 my (undef, $bug_info) = (SuikaWiki::Plugin->magic_and_content ($main::database{ $bug_page }));
231 my %bug_prop;
232 for (split /\n/, $bug_info) {
233 tr/\x0A\x0D//d;
234 if (/^-\s*([0-9A-Za-z-]+)\s*:\s*(\S.*\S)/) {
235 $bug_prop{$1} = $2;
236 } elsif (!/^-/) {
237 last;
238 }
239 }
240 \%bug_prop;
241 }
242
243 sub make_cell ($$$$) {
244 my (undef, $o, $p, $content) = @_;
245 my $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'td');
246 if ($p->{is_header}) {
247 $r->local_name ('th');
248 $r->set_attribute (scope => 'rows');
249 }
250 $r->append_node ($content, node_or_text => 1);
251 $r;
252 }
253
254 sub get_new_bug_number ($$) {
255 my (undef, $bug_ns) = @_;
256 my $no = 0;
257 for (SuikaWiki::Plugin->_database->list_items ({ns => $bug_ns, type => 'key', recursive => 0})) {
258 if (m!//([0-9]+)$!) {
259 $no = 0+$1 if $1 > $no;
260 }
261 }
262 ++$no;
263 }
264
265
266 SuikaWiki::View->definition (bt__bug_create => {
267 media => {type => 'text/html', charset => 1, expires => 60},
268 xmedia => {type => 'application/xhtml+xml', charset => 1, expires => 60},
269 template => <<'EOH'});
270 %bt--create-new-bug;
271 %html-document(title=>{%res(name=>{Plugin:BugTrack:Created:WebPageTitle});}p,link-meta=>{%predefined-template(name=>links);%html-meta(name=>ROBOTS,content=>NOINDEX);}p,content=>{
272 %section(level=>1,add-to-toc=>0,type=>body,title=>{%page-name;}p,heading,content=>{
273 %section(id=>tools1,class=>tools,add-to-toc=>0,content=>{%predefined-template(name=>navbar);}p);
274 %section(level=>2,add-to-toc=>0,content=>{
275 %paragraph(content=>{%res(name=>{Plugin:BugTrack:Created:Message});}p);
276 }p);
277 %section(id=>footer,add-to-toc=>0,content=>{%predefined-template(name=>footer);}p);
278 }p);
279 }p);
280 EOH
281
282 =head1 LICENSE
283
284 Copyright 2003 Wakaba <w@suika.fam.cx>
285
286 This program is free software; you can redistribute it and/or modify
287 it under the terms of the GNU General Public License as published by
288 the Free Software Foundation; either version 2 of the License, or
289 (at your option) any later version.
290
291 This program is distributed in the hope that it will be useful,
292 but WITHOUT ANY WARRANTY; without even the implied warranty of
293 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
294 GNU General Public License for more details.
295
296 You should have received a copy of the GNU General Public License
297 along with this program; see the file COPYING. If not, write to
298 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
299 Boston, MA 02111-1307, USA.
300
301 =cut
302
303 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24