Introducing Thumbnail Integration through Extensions

Review Request #3614 — Created Dec. 2, 2012 and submitted


Review Board


ReviewBoard Extensions can now define how to create thumbnails
for specified file attachment mimetypes.

Added FileAttachmentThumbnailHook to generalize a hook point for
all files of all mimetypes. Mimetype Handlers for text-based
mimetypes can leverage `reviewboard.attachments.mimetypes.TextMimetype`
by simply overriding `_generate_preview_html` to define how to
generate the HTML used in the thumbnail, instead of having to
redefine `get_thumbnail`.
Test Steps:

- Disabled the registration of XMLMimetype in reviewboard.attachments.__init__ (
- Verified that XML thumbnails now fall back to raw uncolored text)
- Copied over the XMLReviewUIExtension from the sample extension branch, and:
  - Added to define the XMLMimetype class for generating XML thumbnails
  - Modified to use the FileAttachmentThumbnailHook to hook XMLMimetype into ReviewBoard to handle XML thumbnails.
- Verified that the Extension installs without error
- Verified that Extension-installed XML thumbnails feature work exactly as did before.

(see attached screenshot, disregard the hyperlink lines - that was due to a separate change to master:

Description From Last Updated

Why are the *s on different lines?

  1. This looks pretty good. Just one question.
  2. reviewboard/extensions/ (Diff revision 3)
    Why are the *s on different lines?
    1. I believe this is the syntax used when items in a list need span multiple lines in the pre-rendered docs text:
      Similar comments:
    2. Okay. I'm not very familiar with rst, I guess.
  1. Why is the text so tiny?
    1. A few possible reasons:
      - Text for XML might appear smaller by contrast as I stopped zooming in to take the screenshots.
      - I've noticed that markdown, docutil, and pygments produce different style/layouts of HTML based on raw text: they all use the same div class "file-thumbnail-clipped" in reviewboard/static/rb/css/reviews.less to scale down font-sizes by 40% on "p, table, pre, code, img, li, h1, h2, h3, h4, h5, h6" - but markdown files will appear slightly larger than .rst or .xml counterparts visually.
      However, the thumbnail text render size is not affected by this change in particular: XML thumbnails render and behave exactly the same when enabled as part of RB, or as through an Extension.
  1. Ship It!
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-1.7.x (63f82e2). Thanks!