Gerrit change 194565 creates a framework for adding warnings about different file types to file pages. Here's how to implement it:
- Add messages for the warning. There will be a maximum of four, only one of them is required:
- 'main' - this will be the text of the warning.
- 'header' - a title for the warning to grab the user's attention
- 'footer' - a qualification of the warning, for example "This is a warning about all PDF files, not this particular file."
- 'info' - text for a link to more information. The URL can be supplied later.
- Create and register a ResourceLoader module with the messages you just created. This will be used to load them onto the client.
- Create or locate a MediaHandler subclass for the type of file you're trying to handle. Most files get handled by ImageHandler or a subclass thereof by default, if a specialized handler doesn't exist for your filetype, you can create it.
- Override the default implementations of the
getWarningConfigmethods on your MediaHandler class. needsWarning should return true if you want a warning to be used, and getWarningConfig should return an object of the following structure:
return array( 'module' => 'pdfhandler.filewarning', // The name of the module you created above 'link' => 'http://example.com', // The link for your link to more information about the problem or solutions 'messages' => array( // The names of the messages you created above 'main' => '...', 'header' => '...', 'footer' => '...', 'info' => '...' ) );
After that, your warning should show up! Report any bugs in Phabricator and we'll get to it as soon as we can.