| 1 |
#?SuikaWikiConfig/2.0 |
| 2 |
|
| 3 |
Plugin: |
| 4 |
@Name: BugTrack |
| 5 |
@Description: |
| 6 |
@@@: SuikaWiki Bug Tracking System |
| 7 |
@@lang:en |
| 8 |
@License: %%Perl%% |
| 9 |
@Author: |
| 10 |
@@Name: |
| 11 |
@@@@: Wakaba |
| 12 |
@@@lang:ja |
| 13 |
@@@script:Latn |
| 14 |
@@Mail[list]: [email protected] |
| 15 |
@Date.RCS: |
| 16 |
$Date: 2004/05/18 11:25:11 $ |
| 17 |
@RequiredPlugin[list]: |
| 18 |
WikiLinking |
| 19 |
WikiResource |
| 20 |
@Namespace: |
| 21 |
@@bt: |
| 22 |
http://suika.fam.cx/~wakaba/archive/2004/8/11/sw-bt# |
| 23 |
@@media-type: |
| 24 |
http://suika.fam.cx/~wakaba/-temp/2004/04/24/mt# |
| 25 |
@Use: |
| 26 |
my $WIKILINKING; |
| 27 |
my $WIKIRESOURCE; |
| 28 |
|
| 29 |
my %BugProp = ( |
| 30 |
Status => { |
| 31 |
name => 'Status', |
| 32 |
uri => <Q:bt:status>, |
| 33 |
}, |
| 34 |
Priority => { |
| 35 |
name => 'Priority', |
| 36 |
uri => <Q:bt:priority>, |
| 37 |
}, |
| 38 |
Category => { |
| 39 |
name => 'Category', |
| 40 |
uri => <Q:bt:category>, |
| 41 |
is_list => 1, |
| 42 |
}, |
| 43 |
Subject => { |
| 44 |
name => 'Subject', |
| 45 |
uri => <Q:bt:subject>, |
| 46 |
}, |
| 47 |
CreationDate => { |
| 48 |
name => 'CreationDate', |
| 49 |
uri => <Q:bt:creation-date>, |
| 50 |
}, |
| 51 |
); |
| 52 |
|
| 53 |
PluginConst: |
| 54 |
@NS_XHTML1: |
| 55 |
http://www.w3.org/1999/xhtml |
| 56 |
@WIKILINKING: |
| 57 |
{($WIKILINKING ||= SuikaWiki::Plugin->module_package ('WikiLinking'))} |
| 58 |
@WIKIRESOURCE: |
| 59 |
{($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))} |
| 60 |
|
| 61 |
FormattingRule: |
| 62 |
@Category[list]: |
| 63 |
view |
| 64 |
view-resource |
| 65 |
form-input |
| 66 |
@Name: bt--bug-list |
| 67 |
@Description: |
| 68 |
@@@: Bug list |
| 69 |
@@lang: en |
| 70 |
@Parameter: |
| 71 |
@@Name: ns |
| 72 |
@@Type: WikiName |
| 73 |
@@Default: (auto) |
| 74 |
@@Description: |
| 75 |
@@@@: Bug track WikiPage |
| 76 |
@@@lang: en |
| 77 |
@Formatting: |
| 78 |
__ATTRTEXT:%ns__; |
| 79 |
my $ns = $o->{wiki}->name ($p->{ns} || $o->{wiki}->{var}->{page}); |
| 80 |
my $option_ns = $ns->clone; |
| 81 |
$option_ns->append_component ('Options'); |
| 82 |
my @bugs = map {[$o->{wiki}->name ($_), $_->[$#$_-1] * 100 + $_->[$#$_]]} |
| 83 |
grep {$_->[$#$_] =~ /^[0-9]+$/} |
| 84 |
map {$o->{wiki}->{db}->keys ('content', |
| 85 |
-ns => $_, |
| 86 |
-type => 'key', |
| 87 |
-recursive => 0)} |
| 88 |
grep {$_->[$#$_] =~ /^[0-9]+$/} |
| 89 |
$o->{wiki}->{db}->keys ('content', |
| 90 |
-ns => $ns, |
| 91 |
-type => 'ns', |
| 92 |
-recursive => 0); |
| 93 |
my $props = $WIKIRESOURCE->get (name => 'Plugin:BugTrack:Table:Row', |
| 94 |
wiki => $o->{wiki}, o => $o); |
| 95 |
my $fmt = SuikaWiki::Plugin->formatter ('bt__bug_table_header'); |
| 96 |
my $tbl = $p->{-parent} |
| 97 |
->append_new_node (type => '#element', |
| 98 |
namespace_uri => $NS_XHTML1, |
| 99 |
local_name => 'table'); |
| 100 |
$tbl->set_attribute (class => 'bt--bugtrack'); |
| 101 |
$tbl->set_attribute (summary => $WIKIRESOURCE->get_op |
| 102 |
('BugTrack:Table:Summary', $o)->inner_text); |
| 103 |
$fmt->replace ($props, param => $o, |
| 104 |
-parent => |
| 105 |
$tbl->append_new_node (type => '#element', |
| 106 |
namespace_uri => $NS_XHTML1, |
| 107 |
local_name => 'thead') |
| 108 |
->append_new_node (type => '#element', |
| 109 |
namespace_uri => $NS_XHTML1, |
| 110 |
local_name => 'tr')); |
| 111 |
$tbl->append_text ("\n"); |
| 112 |
|
| 113 |
$fmt = SuikaWiki::Plugin->formatter ('bt__bug_item'); |
| 114 |
my $tb = $tbl->append_new_node (type => '#element', |
| 115 |
namespace_uri => $NS_XHTML1, |
| 116 |
local_name => 'tbody'); |
| 117 |
my $weight = { |
| 118 |
Priority => {high => 1, normal => 2, low => 3}, |
| 119 |
Status => {open => 1, reserved => 2, closed => 3}, |
| 120 |
}; |
| 121 |
for $_ (sort { |
| 122 |
$weight->{Status}->{$a->{prop}->{Status}||'open'} |
| 123 |
<=> $weight->{Status}->{$b->{prop}->{Status}||'open'} |
| 124 |
|| $weight->{Priority}->{$a->{prop}->{Priority}||'normal'} |
| 125 |
<=> $weight->{Priority}->{$b->{prop}->{Priority}||'normal'} |
| 126 |
|| $b->{lm} <=> $a->{lm} |
| 127 |
|| $a->{prop}->{Category} cmp $b->{prop}->{Category} |
| 128 |
|| $b->{bug_no} <=> $a->{bug_no} |
| 129 |
} map {{ |
| 130 |
bug_ns => $ns, |
| 131 |
bug_option_ns => $option_ns, |
| 132 |
bug_page => $_->[0], |
| 133 |
bug_no => $_->[1], |
| 134 |
prop => __FUNCPACK__->get_bug_properties |
| 135 |
(page => $_->[0], o => $o), |
| 136 |
lm => $o->{wiki}->{db}->get (lastmodified => $_->[0]), |
| 137 |
}} @bugs) { |
| 138 |
local $o->{bt__bug} = $_; |
| 139 |
my @class; |
| 140 |
## TODO: ensure each class name is NMTOKEN |
| 141 |
push @class, $o->{bt__bug}->{prop}->{Status}||'open'; |
| 142 |
push @class, $o->{bt__bug}->{prop}->{Priority}||'normal'; |
| 143 |
push @class, $o->{bt__bug}->{prop}->{Category}; |
| 144 |
my $tr = $tb->append_new_node |
| 145 |
(type => '#element', |
| 146 |
namespace_uri => $NS_XHTML1, |
| 147 |
local_name => 'tr'); |
| 148 |
$tr->set_attribute (class => join ' ', grep /^[\w_.+-]+$/, @class); |
| 149 |
$fmt->replace ($props, param => $o, -parent => $tr); |
| 150 |
$tb->append_text ("\n"); |
| 151 |
} |
| 152 |
|
| 153 |
Function: |
| 154 |
@Name: get_bug_properties |
| 155 |
@Description: |
| 156 |
@@@: |
| 157 |
Returning a hash reference that has some bug properties, |
| 158 |
taken from each bug WikiPages. |
| 159 |
@@lang: en |
| 160 |
@Main: |
| 161 |
my (undef, %opt) = @_; |
| 162 |
my $content_prop = $opt{o}->{wiki}->{db}->get (content_prop => $opt{page}); |
| 163 |
my %bug_prop; |
| 164 |
|
| 165 |
## Get from content_prop database |
| 166 |
PROP: { |
| 167 |
for (keys %BugProp) { |
| 168 |
$bug_prop{$_} = ($content_prop->get_attribute ($BugProp{$_}->{uri}) |
| 169 |
or last PROP) |
| 170 |
->value; |
| 171 |
} |
| 172 |
return \%bug_prop; |
| 173 |
} # PROP |
| 174 |
|
| 175 |
## Get from content |
| 176 |
if ($content_prop->get_attribute_value |
| 177 |
(<Q:media-type:media-type>, |
| 178 |
default => q<IMT:text/x-suikawiki;version="0.9"##>) eq |
| 179 |
q<IMT:text/x-suikawiki;version="0.9"##>) { |
| 180 |
|
| 181 |
my $bug_info = $opt{o}->{wiki}->{db}->get (content => $opt{page}); |
| 182 |
my $f = 0; |
| 183 |
for (split /\n/, $bug_info) { |
| 184 |
tr/\x0A\x0D//d; |
| 185 |
if (/^-\s*([0-9A-Za-z-]+)\s*:\s*(\S.*\S)/) { |
| 186 |
$bug_prop{$1} = $2; |
| 187 |
$f = 1; |
| 188 |
} elsif (!/^-/) { |
| 189 |
last if $f; |
| 190 |
} |
| 191 |
} |
| 192 |
} |
| 193 |
return \%bug_prop; |
| 194 |
|
| 195 |
FormattingRule: |
| 196 |
@Category[list]: |
| 197 |
bt--bug-item |
| 198 |
@Name: -default |
| 199 |
@Description: |
| 200 |
@@@: Default formatting for bug list item information |
| 201 |
@@lang: en |
| 202 |
@Pre: |
| 203 |
$p->{-cell_namespace_uri} = $NS_XHTML1; |
| 204 |
$p->{-cell_local_name} = 'td'; |
| 205 |
@Post: |
| 206 |
local $p->{-parent} = $o->{-result} |
| 207 |
->append_new_node |
| 208 |
(type => '#element', |
| 209 |
namespace_uri => $p->{-cell_namespace_uri}, |
| 210 |
local_name => $p->{-cell_local_name}); |
| 211 |
$f->call ($rule_name, 'main', $p, $o, %opt); |
| 212 |
@Formatting: |
| 213 |
\ |
| 214 |
@Attribute: |
| 215 |
if ($param_name eq '-boolean') { |
| 216 |
$p->{$param_value} = 1; |
| 217 |
} else { |
| 218 |
if ($opt{-value_flag} and index ($opt{-value_flag}, 'p') > -1) { |
| 219 |
$p->{-parse_flag}->{$param_name} = 1; |
| 220 |
} |
| 221 |
$p->{$param_name} = $param_value; |
| 222 |
} |
| 223 |
|
| 224 |
FormattingRule: |
| 225 |
@Category[list]: |
| 226 |
bt--bug-table-header |
| 227 |
@Name: -default |
| 228 |
@Description: |
| 229 |
@@@: Default formatting for bug list item information |
| 230 |
@@lang: en |
| 231 |
@Pre: |
| 232 |
$p->{-cell_namespace_uri} = $NS_XHTML1; |
| 233 |
$p->{-cell_local_name} = 'th'; |
| 234 |
@Post: |
| 235 |
local $p->{-parent} = $o->{-result} |
| 236 |
->append_new_node |
| 237 |
(type => '#element', |
| 238 |
namespace_uri => $p->{-cell_namespace_uri}, |
| 239 |
local_name => $p->{-cell_local_name}); |
| 240 |
$p->{-parent}->set_attribute (class => $rule_name); |
| 241 |
$p->{-parent}->set_attribute (scope => 'col'); |
| 242 |
$f->call ($rule_name, 'main', $p, $o, %opt); |
| 243 |
@Formatting: |
| 244 |
\ |
| 245 |
@Attribute: |
| 246 |
if ($param_name eq '-boolean') { |
| 247 |
$p->{$param_value} = 1; |
| 248 |
} else { |
| 249 |
if ($opt{-value_flag} and index ($opt{-value_flag}, 'p') > -1) { |
| 250 |
$p->{-parse_flag}->{$param_name} = 1; |
| 251 |
} |
| 252 |
$p->{$param_name} = $param_value; |
| 253 |
} |
| 254 |
|
| 255 |
FormattingRule: |
| 256 |
@Category[list]: |
| 257 |
bt--bug-item |
| 258 |
@Name: -undef |
| 259 |
@Description: |
| 260 |
@@@: Undefined rule indication |
| 261 |
@@lang: en |
| 262 |
@Formatting: |
| 263 |
$p->{-parent}->append_text ("[undef: $f->{-category_name}/$rule_name]"); |
| 264 |
|
| 265 |
FormattingRule: |
| 266 |
@Category[list]: |
| 267 |
bt--bug-table-header |
| 268 |
@Name: -undef |
| 269 |
@Description: |
| 270 |
@@@: Column header for bug properties |
| 271 |
@@lang: en |
| 272 |
@Formatting: |
| 273 |
$WIKIRESOURCE->get_op |
| 274 |
('Plugin:BugTrack:Column:'.$rule_name, $o, $p->{-parent}); |
| 275 |
|
| 276 |
FormattingRule: |
| 277 |
@Category[list]: |
| 278 |
bt--bug-table-header |
| 279 |
bt--bug-item |
| 280 |
@Name: -bare-text |
| 281 |
@Description: |
| 282 |
@@@: Bare text out of rule - to be ignored |
| 283 |
@@lang: en |
| 284 |
@Formatting: |
| 285 |
\ |
| 286 |
|
| 287 |
FormattingRule[list]: |
| 288 |
@Category[list]: |
| 289 |
bt--bug-item |
| 290 |
@Name: no |
| 291 |
@Description: |
| 292 |
@@@: Bug number |
| 293 |
@@lang: en |
| 294 |
@Formatting: |
| 295 |
$WIKILINKING->to_wikipage_in_html ({ |
| 296 |
label => $WIKIRESOURCE->get (name => 'BugTrack:Item:Number:Label', |
| 297 |
wiki => $o->{wiki}, o => $o), |
| 298 |
} => { |
| 299 |
base => $o->{bt__bug}->{bug_ns}, |
| 300 |
page_name_relative => $o->{bt__bug}->{bug_page}, |
| 301 |
}, { |
| 302 |
o => $o, |
| 303 |
parent => $p->{-parent}, |
| 304 |
}); |
| 305 |
|
| 306 |
FormattingRule[list]: |
| 307 |
@Category[list]: |
| 308 |
bt--bug-item |
| 309 |
@Name: subject |
| 310 |
@Description: |
| 311 |
@@@: Bug subject |
| 312 |
@@lang: en |
| 313 |
@Formatting: |
| 314 |
$WIKILINKING->to_wikipage_in_html ({ |
| 315 |
label => $WIKIRESOURCE->get (name => 'BugTrack:Item:Subject:Label', |
| 316 |
wiki => $o->{wiki}, o => $o), |
| 317 |
} => { |
| 318 |
base => $o->{bt__bug}->{bug_ns}, |
| 319 |
page_name_relative => $o->{bt__bug}->{bug_page}, |
| 320 |
}, { |
| 321 |
o => $o, |
| 322 |
parent => $p->{-parent}, |
| 323 |
}); |
| 324 |
|
| 325 |
FormattingRule: |
| 326 |
@Category[list]: |
| 327 |
page-link |
| 328 |
@Name: bt--property |
| 329 |
@Parameter: |
| 330 |
@@Name: default |
| 331 |
@@Type: CDATA |
| 332 |
@@Default: (none) |
| 333 |
@@Default: |
| 334 |
@@@: Default text |
| 335 |
@@lang: en |
| 336 |
@Parameter: |
| 337 |
@@Name: name |
| 338 |
@@Type: name |
| 339 |
@@Default: #REQUIRED |
| 340 |
@@Description: |
| 341 |
@@@: Bug property name |
| 342 |
@@lang: en |
| 343 |
@Formatting: |
| 344 |
__ATTRTEXT:%name__; |
| 345 |
$p->{name} =~ tr/-/_/; |
| 346 |
|
| 347 |
exists $o->{bt__bug}->{prop}->{$p->{name}} ? |
| 348 |
$p->{-parent}->append_text ($o->{bt__bug}->{prop}->{$p->{name}}) : |
| 349 |
exists $o->{bt__bug}->{$p->{name}} ? |
| 350 |
$p->{-parent}->append_text ($o->{bt__bug}->{$p->{name}}) : |
| 351 |
do {__ATTRNODE:%default->{$p->{-parent}}__;}; |
| 352 |
|
| 353 |
FormattingRule[list]: |
| 354 |
@Category[list]: |
| 355 |
bt--bug-item |
| 356 |
@Name: status |
| 357 |
@Description: |
| 358 |
@@@: Bug status |
| 359 |
@@lang: en |
| 360 |
@Formatting: |
| 361 |
$WIKIRESOURCE->get_op ('Status:'.($o->{bt__bug}->{prop}->{Status} |
| 362 |
or '(default)'), |
| 363 |
$o, $p->{-parent}, |
| 364 |
ns => $o->{bt__bug}->{bug_option_ns}, |
| 365 |
default => $o->{bt__bug}->{prop}->{Status} |
| 366 |
|| '(default)'); |
| 367 |
|
| 368 |
FormattingRule[list]: |
| 369 |
@Category[list]: |
| 370 |
bt--bug-item |
| 371 |
@Name: priority |
| 372 |
@Description: |
| 373 |
@@@: Bug priority |
| 374 |
@@lang: en |
| 375 |
@Formatting: |
| 376 |
$WIKIRESOURCE->get_op ('Priority:'.($o->{bt__bug}->{prop}->{Priority} |
| 377 |
or '(default)'), |
| 378 |
$o, $p->{-parent}, |
| 379 |
ns => $o->{bt__bug}->{bug_option_ns}, |
| 380 |
default => $o->{bt__bug}->{prop}->{Priority} |
| 381 |
|| '(default)'); |
| 382 |
|
| 383 |
FormattingRule[list]: |
| 384 |
@Category[list]: |
| 385 |
bt--bug-item |
| 386 |
@Name: category |
| 387 |
@Description: |
| 388 |
@@@: Bug category |
| 389 |
@@lang: en |
| 390 |
@Formatting: |
| 391 |
$WIKIRESOURCE->get_op ('Category:'.($o->{bt__bug}->{prop}->{Category} |
| 392 |
or '(default)'), |
| 393 |
$o, $p->{-parent}, |
| 394 |
ns => $o->{bt__bug}->{bug_option_ns}, |
| 395 |
default => $o->{bt__bug}->{prop}->{Category} |
| 396 |
|| '(default)'); |
| 397 |
|
| 398 |
FormattingRule[list]: |
| 399 |
@Category[list]: |
| 400 |
bt--bug-item |
| 401 |
@Name: last-modified |
| 402 |
@Description: |
| 403 |
@@@: Bug last modified date-time |
| 404 |
@@lang: en |
| 405 |
@Formatting: |
| 406 |
## TODO: custom date format (Message::Field::Date) |
| 407 |
my @time = gmtime $o->{bt__bug}->{lm}; |
| 408 |
$p->{-parent}->append_text |
| 409 |
(sprintf '%04d-%02d-%02d %02d:%02d:%02d +00:00', |
| 410 |
$time[5]+1900,$time[4]+1,@time[3,2,1,0]); |
| 411 |
|
| 412 |
FormattingRule: |
| 413 |
@Category[list]: |
| 414 |
view |
| 415 |
view-resource |
| 416 |
form-input |
| 417 |
@Name: bt--create-new-bug |
| 418 |
@Description: |
| 419 |
@@@: Creating-new-bug-item form |
| 420 |
@@lang: en |
| 421 |
@Parameter: |
| 422 |
@@Name: ns |
| 423 |
@@Type: WikiName |
| 424 |
@@Default: (auto) |
| 425 |
@@Description: |
| 426 |
@@@@: WikiPage name of bug tracking |
| 427 |
@@@lang:en |
| 428 |
@Formatting: |
| 429 |
__ATTRTEXT:%ns__; |
| 430 |
|
| 431 |
my $page = $o->{wiki}->name ($p->{ns} || $o->{wiki}->{var}->{page}); |
| 432 |
SuikaWiki::Plugin->module_package ('WikiFormCore') |
| 433 |
->make_form_in_html |
| 434 |
($p->{-parent}, $p->{content} || |
| 435 |
$WIKIRESOURCE->get |
| 436 |
(name => 'BugTrack:CreateForm:Content', |
| 437 |
o => $o, wiki => $o->{wiki}), |
| 438 |
wiki => $o->{wiki}, o => $o, |
| 439 |
index => -1, |
| 440 |
output => { |
| 441 |
mode => 'bt--bug-create', |
| 442 |
page => $page, |
| 443 |
}); |
| 444 |
|
| 445 |
Function: |
| 446 |
@Name: get_new_bug_page |
| 447 |
@Main: |
| 448 |
my (undef, %opt) = @_; |
| 449 |
my $max_ns = $opt{ns}->clone; |
| 450 |
$max_ns->append_component ('1'); |
| 451 |
for ( grep {$_->[$#$_] =~ /^[0-9]+$/} |
| 452 |
$opt{o}->{wiki}->{db}->keys ('content', |
| 453 |
-ns => $opt{ns}, |
| 454 |
-type => 'ns', |
| 455 |
-recursive => 0)) { |
| 456 |
$max_ns = $_ if $_->[$#$_] > $max_ns->[$#$_]; |
| 457 |
} |
| 458 |
my $max = ref $max_ns eq 'ARRAY' ? $opt{o}->{wiki}->name ($max_ns) |
| 459 |
: $max_ns->clone; |
| 460 |
$max->append_component ('0'); |
| 461 |
for ( grep {$_->[$#$_] =~ /^[0-9]+$/} |
| 462 |
$opt{o}->{wiki}->{db}->keys ('content', |
| 463 |
-ns => $max_ns, |
| 464 |
-type => 'key', |
| 465 |
-recursive => 0)) { |
| 466 |
$max = $_ if $_->[$#$_] > $max->[$#$_]; |
| 467 |
} |
| 468 |
$max->[$#$max]++; |
| 469 |
$max->[$#$max-1]++, $max->[$#$max] = 1 if $max->[$#$max] > 100; |
| 470 |
$opt{o}->{wiki}->name ($max); |
| 471 |
|
| 472 |
FormattingRule: |
| 473 |
@Category[list]: |
| 474 |
view |
| 475 |
view-resource |
| 476 |
form-input |
| 477 |
@Name: bt--bug-root-page |
| 478 |
@Description: |
| 479 |
@@@: Root of bugtrack |
| 480 |
@@lang: en |
| 481 |
@Formatting: |
| 482 |
__ATTRTEXT:%ns__; |
| 483 |
my $ns = $o->{wiki}->name ($p->{ns} || $o->{wiki}->{var}->{page}); |
| 484 |
if ($#$ns > 1) { |
| 485 |
delete $ns->[$#$ns] if $ns->[$#$ns] =~ /^[0-9]+$/; |
| 486 |
delete $ns->[$#$ns] if $ns->[$#$ns] =~ /^[0-9]+$/; |
| 487 |
} |
| 488 |
$p->{-parent}->append_text ($ns->stringify (wiki => $o->{wiki})); |
| 489 |
|
| 490 |
FormattingRule: |
| 491 |
@Category[list]: |
| 492 |
view |
| 493 |
view-resource |
| 494 |
form-input |
| 495 |
@Name: bt--if-one-of-bug |
| 496 |
@Description: |
| 497 |
@@@: If one of bug track item WikiPages |
| 498 |
@@lang: en |
| 499 |
@Formatting: |
| 500 |
__ATTRTEXT:%ns__; |
| 501 |
my $ns = $o->{wiki}->name ($p->{ns} || $o->{wiki}->{var}->{page}); |
| 502 |
if ($#$ns > 1 and |
| 503 |
$ns->[$#$ns] =~ /^[0-9]+$/ and |
| 504 |
$ns->[$#$ns - 1] =~ /^[0-9]+$/) { |
| 505 |
__ATTRNODE:%true->{$p->{-parent}}__; |
| 506 |
} else { |
| 507 |
__ATTRNODE:%false->{$p->{-parent}}__; |
| 508 |
} |
| 509 |
|
| 510 |
|
| 511 |
ViewDefinition: |
| 512 |
@Mode: bt--bug-create |
| 513 |
@Condition: |
| 514 |
@@output: http-cgi |
| 515 |
@@http-method[list]: |
| 516 |
POST |
| 517 |
@Description: |
| 518 |
@@@: Create a new bug WikiPage |
| 519 |
@@lang:en |
| 520 |
@method: |
| 521 |
@@Name: main |
| 522 |
@@@: |
| 523 |
my $wiki = $self->{view}->{wiki}; |
| 524 |
## Open Database |
| 525 |
$wiki->{var}->{db}->{read_only}->{content} = 0; |
| 526 |
$wiki->{var}->{db}->{read_only}->{content_prop} = 0; |
| 527 |
$wiki->{var}->{db}->{read_only}->{lastmodified} = 0; |
| 528 |
$self->{view}->init_db; |
| 529 |
|
| 530 |
my $ns = $wiki->{var}->{page}; |
| 531 |
my $o = { |
| 532 |
wiki => $wiki, |
| 533 |
}; |
| 534 |
$o->{bt__bug} = { |
| 535 |
bug_ns => $ns, |
| 536 |
bug_page => __FUNCPACK__->get_new_bug_page |
| 537 |
(ns => $ns, o => $o), |
| 538 |
}; |
| 539 |
|
| 540 |
## Set properties |
| 541 |
my $content_prop = $wiki->{db}->get |
| 542 |
(content_prop => $o->{bt__bug}->{bug_page}); |
| 543 |
$content_prop->set_attribute |
| 544 |
(<Q:media-type:media-type> => q<IMT:text/x-suikawiki;version="0.9"##>); |
| 545 |
my @page; |
| 546 |
for (qw/Subject Priority Status Category/) { |
| 547 |
my $value = $o->{wiki}->{input}->parameter ('bt--' . lc $_) |
| 548 |
|| __FUNCPACK{WikiResource}__ |
| 549 |
->get (name => 'BugTrack:'.$_.':Default', |
| 550 |
o => $o, wiki => $o->{wiki}); |
| 551 |
## TODO: multiple categories |
| 552 |
$content_prop->set_attribute ($BugProp{$_}->{uri} => $value); |
| 553 |
$o->{bt__bug}->{prop}->{$_} = $value; |
| 554 |
} |
| 555 |
$content_prop->set_attribute ($BugProp{CreationDate}->{uri} => time); |
| 556 |
$wiki->{db}->set (content_prop => $o->{bt__bug}->{bug_page} |
| 557 |
=> $content_prop); |
| 558 |
$wiki->{db}->set (lastmodified => $o->{bt__bug}->{bug_page} |
| 559 |
=> time); |
| 560 |
|
| 561 |
## Save main content |
| 562 |
my $page = '[1]' . "\n" . $o->{wiki}->{input}->parameter ('bt--body'); |
| 563 |
$wiki->{db}->set (content => $o->{bt__bug}->{bug_page} |
| 564 |
=> join "\x0A", $page); |
| 565 |
|
| 566 |
## Redirect to new WikiPage |
| 567 |
my $uri = $self->{view}->{wiki}->uri_reference |
| 568 |
(page => $o->{bt__bug}->{bug_page}, |
| 569 |
up_to_date => 1); |
| 570 |
|
| 571 |
require SuikaWiki::Output::HTTP; |
| 572 |
my $output = SuikaWiki::Output::HTTP->new (wiki => $self->{view}->{wiki}); |
| 573 |
$output->set_redirect (uri => $uri, status_code => 303, |
| 574 |
status_phrase => q(Created)); |
| 575 |
## Should we use 201 Created? |
| 576 |
$output->output (output => 'http-cgi'); |
| 577 |
|
| 578 |
ViewFragment: |
| 579 |
@Template[list]: links |
| 580 |
@Description: |
| 581 |
@@@: Web page to web page links - bug tracking system |
| 582 |
@@lang:en |
| 583 |
@Formatting: |
| 584 |
%bt--if-one-of-bug ( |
| 585 |
true => { |
| 586 |
%link-to-wikipage ( |
| 587 |
page => {%bt--bug-root-page;}p, |
| 588 |
rel => top, |
| 589 |
label => {%html-link ( |
| 590 |
description => {%page-name;}p, |
| 591 |
);}, |
| 592 |
); |
| 593 |
}p, |
| 594 |
); |
| 595 |
|
| 596 |
ViewFragment: |
| 597 |
@Template[list]:wr--read-body |
| 598 |
@Order: -10 |
| 599 |
@Description: |
| 600 |
@@@: "Read" mode body -- Bug information |
| 601 |
@@lang:en |
| 602 |
@Formatting: |
| 603 |
%bt--if-one-of-bug ( |
| 604 |
true => { |
| 605 |
%pe--propedit (template => { |
| 606 |
%resource-as-plain-text (name => {BugTrack:PropEdit:Template}); |
| 607 |
}p); |
| 608 |
}p, |
| 609 |
); |
| 610 |
|
| 611 |
Resource: |
| 612 |
@BugTrack:Category:Default: |
| 613 |
@@@: (default) |
| 614 |
@@lang: en |
| 615 |
@BugTrack:Category:Label: |
| 616 |
@@@: Category |
| 617 |
@@lang: en |
| 618 |
@BugTrack:CreateForm:Content: |
| 619 |
%line (content => { |
| 620 |
%text (id=>bt--subject,label=>{%res (name => {BugTrack:Subject:Label});}p,default=>{%res (name => {BugTrack:Subject:Default});}p,size=>15); |
| 621 |
}p); |
| 622 |
%line (content => { |
| 623 |
%res (name => {BugTrack:Priority:Label}); |
| 624 |
%radio(id=>bt--priority,label=>{%res (name => {BugTrack:Priority:high});}p,value=>{high}); |
| 625 |
%radio(id=>bt--priority,default,label=>{%res (name => {BugTrack:Priority:normal});}p,value=>{normal}); |
| 626 |
%radio(id=>bt--priority,label=>{%res (name => {BugTrack:Priority:low});}p,value=>{low}); |
| 627 |
}p); |
| 628 |
%line (content => { |
| 629 |
%res (name => {BugTrack:Status:Label}); |
| 630 |
%radio(id=>bt--status,default,label=>{%res (name => {BugTrack:Status:open});}p,value=>{open}); |
| 631 |
%radio(id=>bt--status,label=>{%res (name => {BugTrack:Status:reserved});}p,value=>{reserved}); |
| 632 |
%radio(id=>bt--status,label=>{%res (name => {BugTrack:Status:closed});}p,value=>{closed}); |
| 633 |
}p); |
| 634 |
%line (content => { |
| 635 |
%text (id=>bt--category,label=>{%res (name => {BugTrack:Category:Label});}p,size=>10); |
| 636 |
}p); |
| 637 |
%line (content => { |
| 638 |
%textarea ( |
| 639 |
id => bt--body, size=>15,lines=>5, |
| 640 |
label=>{%res (name => {BugTrack:CreateForm:MainText:Label});}p, |
| 641 |
); |
| 642 |
%submit (label => {%res (name => {Form:Label:Add});}p, |
| 643 |
description => {%res (name => {Form:Description:Add});}p); |
| 644 |
}p); |
| 645 |
@BugTrack:CreateForm:MainText:Label: |
| 646 |
@@@: Bug description |
| 647 |
@@lang: en |
| 648 |
@BugTrack:Item:Number:Label: |
| 649 |
%link-to-it (label => {%bt--property (name => bug-no);}p, default => {0}); |
| 650 |
@BugTrack:Item:Subject:Default: |
| 651 |
@@@: No Title |
| 652 |
@@lang: en |
| 653 |
@BugTrack:Item:Subject:Label: |
| 654 |
%link-to-it (label => {%bt--property ( |
| 655 |
name => Subject, |
| 656 |
default => {%res (name => {BugTrack:Item:Subject:Default});}p, |
| 657 |
);}p); |
| 658 |
@BugTrack:Priority:Default: |
| 659 |
@@@: normal |
| 660 |
@@lang: en |
| 661 |
@BugTrack:Priority:Label: |
| 662 |
@@@: Priority |
| 663 |
@@lang: en |
| 664 |
@BugTrack:Priority:high: |
| 665 |
@@@: HIGH |
| 666 |
@@lang: en |
| 667 |
@BugTrack:Priority:low: |
| 668 |
@@@: low |
| 669 |
@@lang: en |
| 670 |
@BugTrack:Priority:normal: |
| 671 |
@@@: normal |
| 672 |
@@lang: en |
| 673 |
@BugTrack:PropEdit:Template: |
| 674 |
%line (content => { |
| 675 |
%text (label => {%res (name => {BugTrack:Subject:Label});}p, |
| 676 |
id => bt--subject, size => 20, source => prop); |
| 677 |
}p); |
| 678 |
%list ( |
| 679 |
x => { |
| 680 |
%text (label => {%res (name => {BugTrack:Category:Label});}p, |
| 681 |
id => bt--category, size => 20, source => prop); |
| 682 |
}p, |
| 683 |
x => {%submit (label => {%res (name => {WikiForm:Change});}p);}p, |
| 684 |
); |
| 685 |
@BugTrack:Status:Default: |
| 686 |
@@@: open |
| 687 |
@@lang: en |
| 688 |
@BugTrack:Status:Label: |
| 689 |
@@@: Status |
| 690 |
@@lang: en |
| 691 |
@BugTrack:Status:closed: |
| 692 |
@@@: closed |
| 693 |
@@lang: en |
| 694 |
@BugTrack:Status:open: |
| 695 |
@@@: OPEN |
| 696 |
@@lang: en |
| 697 |
@BugTrack:Status:reserved: |
| 698 |
@@@: reserved |
| 699 |
@@lang: en |
| 700 |
@BugTrack:Subject:Default: |
| 701 |
@@@: New bug |
| 702 |
@@lang: en |
| 703 |
@BugTrack:Subject:Label: |
| 704 |
@@@: Subject |
| 705 |
@@lang: en |
| 706 |
@BugTrack:Table:Summary: |
| 707 |
@@@: |
| 708 |
This table shows reported bugs. Each row represent each bug, |
| 709 |
each row in turn contains of bug number, status, priority, |
| 710 |
subject and last-modified date-time. |
| 711 |
@@lang: en |
| 712 |
@Plugin:BugTrack:Column:category: |
| 713 |
@@@: Category |
| 714 |
@@lang: en |
| 715 |
@Plugin:BugTrack:Column:last_modified: |
| 716 |
@@@: Last Modified |
| 717 |
@@lang: en |
| 718 |
@Plugin:BugTrack:Column:no: |
| 719 |
@@@: # |
| 720 |
@@lang: en |
| 721 |
@Plugin:BugTrack:Column:priority: |
| 722 |
@@@: Priority |
| 723 |
@@lang: en |
| 724 |
@Plugin:BugTrack:Column:status: |
| 725 |
@@@: Status |
| 726 |
@@lang: en |
| 727 |
@Plugin:BugTrack:Column:subject: |
| 728 |
@@@: Subject |
| 729 |
@@lang: en |
| 730 |
@Plugin:BugTrack:Table:Row: |
| 731 |
@@@: |
| 732 |
%no; %status; %priority; %category; %subject; %last-modified; |
| 733 |
@@lang: en |
| 734 |
|
| 735 |
Parameter: |
| 736 |
@Name: bt--subject |
| 737 |
@Description: |
| 738 |
@@@: Bug tracking system - subject |
| 739 |
@@lang: en |
| 740 |
|
| 741 |
Parameter: |
| 742 |
@Name: bt--category |
| 743 |
@Description: |
| 744 |
@@@: Bug tracking system - category |
| 745 |
@@lang: en |
| 746 |
|
| 747 |
Parameter: |
| 748 |
@Name: bt--priority |
| 749 |
@Description: |
| 750 |
@@@: Bug tracking system - priority |
| 751 |
@@lang: en |
| 752 |
|
| 753 |
Parameter: |
| 754 |
@Name: bt--status |
| 755 |
@Description: |
| 756 |
@@@: Bug tracking system - status |
| 757 |
@@lang: en |
| 758 |
|
| 759 |
Parameter: |
| 760 |
@Name: bt--body |
| 761 |
@Description: |
| 762 |
@@@: Bug tracking system - main description |
| 763 |
@@lang: en |
| 764 |
|