diff options
author | Byron Jones <bjones@mozilla.com> | 2014-02-13 06:48:52 +0100 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2014-02-13 06:48:52 +0100 |
commit | c56d18a3e5c4d022741c6457f5c91122699e482f (patch) | |
tree | 2b18e1d7709f6408021cb63c8b3aef49f20d918f /Bugzilla/WebService | |
parent | b5ed02725ff4bd4aa4245aa7389130c5935d9c90 (diff) | |
download | bugzilla-c56d18a3e5c4d022741c6457f5c91122699e482f.tar.gz bugzilla-c56d18a3e5c4d022741c6457f5c91122699e482f.tar.xz |
Bug 40896: Bugzilla needs a "preview" mode for comments
Diffstat (limited to 'Bugzilla/WebService')
-rw-r--r-- | Bugzilla/WebService/Bug.pm | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index ab2e85a93..e37d1cd00 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -325,6 +325,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) = @_; @@ -4508,3 +4532,46 @@ this bug. =back =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 + |