summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2014-02-13 06:45:42 +0100
committerByron Jones <bjones@mozilla.com>2014-02-13 06:45:42 +0100
commitadceb1cda6441d2969ed5a3d6d45add6f33c6df7 (patch)
treeb97e5509c54029d6cb5d1873ba83c02da93c0e6b /Bugzilla
parenta7ca86321e295e6df44386826aee90deca50ba20 (diff)
downloadbugzilla-adceb1cda6441d2969ed5a3d6d45add6f33c6df7.tar.gz
bugzilla-adceb1cda6441d2969ed5a3d6d45add6f33c6df7.tar.xz
Bug 40896: Bugzilla needs a "preview" mode for comments
r=gerv, a=justdave
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/WebService/Bug.pm66
1 files changed, 66 insertions, 0 deletions
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index de7853092..9ab217b04 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -318,6 +318,30 @@ sub comments {
return { bugs => \%bugs, comments => \%comments };
}
+sub render_comment {
+ my ($self, $params) = @_;
+
+ unless (defined $params->{text}) {
+ ThrowCodeError('params_required',
+ { function => 'Bug.render_comment',
+ params => ['text'] });
+ }
+
+ Bugzilla->switch_to_shadow_db();
+ my $bug = $params->{id} ? Bugzilla::Bug->check($params->{id}) : undef;
+
+ my $tmpl = '[% text FILTER quoteUrls(bug) %]';
+ my $html;
+ my $template = Bugzilla->template;
+ $template->process(
+ \$tmpl,
+ { bug => $bug, text => $params->{text}},
+ \$html
+ );
+
+ return { html => $html };
+}
+
# Helper for Bug.comments
sub _translate_comment {
my ($self, $comment, $filters) = @_;
@@ -4682,6 +4706,48 @@ The comment tag provided is longer than the maximum length.
=back
+=head2 render_comment
+
+B<UNSTABLE>
+
+=over
+
+=item B<Description>
+
+Returns the HTML rendering of the provided comment text.
+
+=item B<Params>
+
+=over
+
+=item C<text>
+
+B<Required> C<strings> Text comment text to render.
+
+=item C<id>
+
+C<int> The ID of the bug to render the comment against.
+
+=back
+
+=item B<Returns>
+
+C<html> containing the HTML rendering.
+
+=item B<Errors>
+
+This method can throw all of the errors that L</get> throws.
+
+=item B<History>
+
+=over
+
+=item Added in Bugzilla B<5.0>.
+
+=back
+
+=back
+
=head1 B<Methods in need of POD>
=over