Syntax-Highlighted Thumbnail Rendering for XML File Attachments

Review Request #3567 — Created Nov. 26, 2012 and submitted

Information

Review Board
master

Reviewers

Added thumbnail rendering support for XML mimetypes using pygments
Manual Testing on Localhost:
- Uploaded various XML files
- All render correctly with syntax-highlighting

(See attached screenshots: 2012-11-27)

Description From Last Updated

So something we've found in the past is that Pygments's XML rendering is very slow for very large XML files. …

chipx86chipx86
chipx86
  1. 
      
  2. reviewboard/attachments/mimetypes.py (Diff revision 1)
     
     
     
     
     
    Show all issues
    So something we've found in the past is that Pygments's XML rendering is very slow for very large XML files. So I'd cap it. If the file is over a certain size (let's say 10KB, which should be defined as a constant on the class), don't highlight it.
    1. Truncated read on file attachments for thumbnail generation is actually already handled by TextMimetype (base class for XMLMimetype) as part of the Thumbnails project: http://reviews.reviewboard.org/r/3454/
      
      Currently it reads up to `FILE_CROP_CHAR_LIMIT = 2000` from TextMimetype, which is under 10KB. If we'd like a different limit, I can put override the class variable in XMLMimeType.
    2. Oh, right. Cool.
  3. 
      
SL
chipx86
  1. Curious, why the zoom? I'd prefer getting an accurate idea of what these look like.
  2. 
      
chipx86
  1. Ship It!
  2. 
      
SL
Review request changed
Status:
Completed
Change Summary:
Pushed to master (1d5226c)
david
  1. I don't know if it's possible without some work, but it would be nice if this was part of the XML Review UI extension.
  2.