17 |
@RequiredPlugin[list]: |
@RequiredPlugin[list]: |
18 |
WikiLinking |
WikiLinking |
19 |
WikiResource |
WikiResource |
|
@Use: |
|
|
my $WIKILINKING; |
|
|
my $WIKIRESOURCE; |
|
20 |
@Namespace: |
@Namespace: |
21 |
|
@@bt: |
22 |
|
http://suika.fam.cx/~wakaba/archive/2004/8/11/sw-bt# |
23 |
@@media-type: |
@@media-type: |
24 |
http://suika.fam.cx/~wakaba/-temp/2004/04/24/mt# |
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: |
PluginConst: |
54 |
@NS_XHTML1: |
@NS_XHTML1: |
159 |
@@lang: en |
@@lang: en |
160 |
@Main: |
@Main: |
161 |
my (undef, %opt) = @_; |
my (undef, %opt) = @_; |
162 |
## TODO: New style property should also be implemented |
my $content_prop = $opt{o}->{wiki}->{db}->get (content_prop => $opt{page}); |
|
my $bug_info = $opt{o}->{wiki}->{db}->get (content => $opt{page}); |
|
163 |
my %bug_prop; |
my %bug_prop; |
164 |
my $f = 0; |
|
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) { |
for (split /\n/, $bug_info) { |
184 |
tr/\x0A\x0D//d; |
tr/\x0A\x0D//d; |
185 |
if (/^-\s*([0-9A-Za-z-]+)\s*:\s*(\S.*\S)/) { |
if (/^-\s*([0-9A-Za-z-]+)\s*:\s*(\S.*\S)/) { |
189 |
last if $f; |
last if $f; |
190 |
} |
} |
191 |
} |
} |
192 |
\ \%bug_prop; |
} |
193 |
|
return \%bug_prop; |
194 |
|
|
195 |
FormattingRule: |
FormattingRule: |
196 |
@Category[list]: |
@Category[list]: |
518 |
@@@: Create a new bug WikiPage |
@@@: Create a new bug WikiPage |
519 |
@@lang:en |
@@lang:en |
520 |
@method: |
@method: |
521 |
|
@@Name: main |
522 |
@@@: |
@@@: |
523 |
my $wiki = $self->{view}->{wiki}; |
my $wiki = $self->{view}->{wiki}; |
524 |
## Open Database |
## Open Database |
537 |
(ns => $ns, o => $o), |
(ns => $ns, o => $o), |
538 |
}; |
}; |
539 |
|
|
540 |
## Generate new content |
## Set properties |
541 |
my $content_prop = $wiki->{db}->get |
my $content_prop = $wiki->{db}->get |
542 |
(content_prop => $o->{bt__bug}->{bug_page}); |
(content_prop => $o->{bt__bug}->{bug_page}); |
543 |
$content_prop->set_attribute |
$content_prop->set_attribute |
545 |
my @page; |
my @page; |
546 |
for (qw/Subject Priority Status Category/) { |
for (qw/Subject Priority Status Category/) { |
547 |
my $value = $o->{wiki}->{input}->parameter ('bt--' . lc $_) |
my $value = $o->{wiki}->{input}->parameter ('bt--' . lc $_) |
548 |
|| $WIKIRESOURCE->get (name => 'BugTrack:'.$_.':Default', |
|| __FUNCPACK{WikiResource}__ |
549 |
|
->get (name => 'BugTrack:'.$_.':Default', |
550 |
o => $o, wiki => $o->{wiki}); |
o => $o, wiki => $o->{wiki}); |
551 |
push @page, '- ' . $_ . ': ' . $value; |
## TODO: multiple categories |
552 |
|
$content_prop->set_attribute ($BugProp{$_}->{uri} => $value); |
553 |
$o->{bt__bug}->{prop}->{$_} = $value; |
$o->{bt__bug}->{prop}->{$_} = $value; |
554 |
} |
} |
555 |
my @time = gmtime; |
$content_prop->set_attribute ($BugProp{CreationDate}->{uri} => time); |
556 |
push @page, '- Creation-Date: ' . |
$wiki->{db}->set (content_prop => $o->{bt__bug}->{bug_page} |
557 |
sprintf '%04d-%02d-%02d %02d:%02d:%02d +00:00', |
=> $content_prop); |
|
$time[5]+1900,$time[4]+1,@time[3,2,1,0]; |
|
|
push @page, ''; |
|
|
push @page, '[1] ' . "\n" . $o->{wiki}->{input}->parameter ('bt--body'); |
|
|
$wiki->{db}->set (content => $o->{bt__bug}->{bug_page} |
|
|
=> join "\x0A", @page); |
|
558 |
$wiki->{db}->set (lastmodified => $o->{bt__bug}->{bug_page} |
$wiki->{db}->set (lastmodified => $o->{bt__bug}->{bug_page} |
559 |
=> time); |
=> 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 |
my $uri = $self->{view}->{wiki}->uri_reference |
568 |
(page => $o->{bt__bug}->{bug_page}, |
(page => $o->{bt__bug}->{bug_page}, |
569 |
up_to_date => 1); |
up_to_date => 1); |
574 |
status_phrase => q(Created)); |
status_phrase => q(Created)); |
575 |
## Should we use 201 Created? |
## Should we use 201 Created? |
576 |
$output->output (output => 'http-cgi'); |
$output->output (output => 'http-cgi'); |
|
@@Name: main |
|
577 |
|
|
578 |
ViewFragment: |
ViewFragment: |
579 |
@Template[list]: links |
@Template[list]: links |
593 |
}p, |
}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: |
Resource: |
612 |
@BugTrack:Category:Default: |
@BugTrack:Category:Default: |
613 |
@@@: (default) |
@@@: (default) |
670 |
@BugTrack:Priority:normal: |
@BugTrack:Priority:normal: |
671 |
@@@: normal |
@@@: normal |
672 |
@@lang: en |
@@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: |
@BugTrack:Status:Default: |
686 |
@@@: open |
@@@: open |
687 |
@@lang: en |
@@lang: en |