diff options
Diffstat (limited to 'MantisSmalltech.php')
| -rw-r--r-- | MantisSmalltech.php | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/MantisSmalltech.php b/MantisSmalltech.php index df6a984..6207cb0 100644 --- a/MantisSmalltech.php +++ b/MantisSmalltech.php @@ -12,11 +12,32 @@ class MantisSmalltechPlugin extends MantisPlugin { function register() { $this->name = plugin_lang_get( 'title' ); $this->description = plugin_lang_get( 'description' ); - $this->page = ''; + $this->page = 'config'; $this->version = '0.1'; $this->requires = array( 'MantisCore' => '2.3.0-dev', + + /* Plugin loading uses a topological sort. It's important that we know + * what order we load in with respect to MantisCoreFormatting, because + * that also affects the order our event bindings run in: The plugin + * that loads last, gets the event last. + * + * We would really prefer to load before MantisCoreFormatting, so that + * we can both consume and output Markdown, rather than HTML. + * Unfortunatly, the only way that we as a plugin can control that is + * by declaring a dependency, which makes us run afterwards. Otherwise, + * it winds up being unpredictable and depends on things such as which + * plugins are force-installed. + * + * By tweaking the full system configuration at the nix level, we'd have + * the ability to run before, but it's best if MantisSmalltech doesn't + * require nix. + * + * So, we run at the end, and deal with the limitations that come with + * working in HTML. + */ + 'MantisCoreFormatting' => '2.3.0-dev', ); $this->author = 'Irene Knapp'; @@ -47,27 +68,31 @@ class MantisSmalltechPlugin extends MantisPlugin { return $t_hooks; } + /** + * Default plugin configuration. + * @return array + */ + function config() { + return array( + 'process_gerrit_links' => ON + ); + } + function display_bug_id( $p_event_name, $p_string, $p_number ) { return sprintf( 'b/%u', $p_number ); } - function display_formatted( $p_event, $p_string, $p_multiline = true ): string { /* This is better documented in the Gerrit config. If you read that one - * first, there's just two things to keep in mind about this one. - * - * 1. Gerrit applies HTML-escaping to the input prior to letting us see - * it, Mantis gives us raw input. - * - * 2. Gerrit expects HTML output; Mantis expects Markdown. + * first, it's quite similar, except that Mantis leaves apostrophes alone. */ $p_string = preg_replace( - '/(?<=(?:^|(?<=\\s)))((?:[\\(\\[\\{\'"])*)' + '/(?<=(?:^|(?<=\\s|>)))((?:[\\(\\[\\{\']|")*)' . 'cl\\/(\\d+)' - . '(?=(?:[\\.,;?!\\)\\]\\}\'"])*(?:$|(?=\\s)))/', - '\\1[cl/\\2](https://gerrit.internetsafetylabs.org/c/\\2)', + . '(?=(?:[\\.,;?!\\)\\]\\}\']|")*(?:$|(?=\\s|<)))/', + '\\1<a href="https://gerrit.internetsafetylabs.org/c/\\2">cl/\\2</a>', $p_string); return $p_string; |