Implement Thumbnail Rendering for Text-ish File Attachments (.rst and .md)
Review Request #3454 — Created Oct. 24, 2012 and submitted — Latest diff uploaded
Implemented thumbnail rendering for ReStructuredText (.rst) and MarkDown (.md) file attachment types. The rendered thumbnails are displayed as HTML scaled down by css (instead of rendered as image thumbs), and are mem cached. Also changed the way MimetypeHandlers are registered to match existing infrastructure for registering Review UIs, replacing the old way of doing it through __subclass__
1. Ran unit tests for reviewboard.attachments.tests: - Updated tests now all pass after adding setUp() and tearDown() to register / unregister the test Mimetype Handlers. 2. Manual testing on localhost: Tested by uploading to a new review-request: - raw .txt file - raw .rst file - raw .md file - raw .jpg file - raw .rst file with javascript injection - raw .md file with javascript injection Visual inspection of the rendered thumbnails all pass: - Thumbnails appear immediately (without a refresh), reflecting latest feature updates to master. - Scaling, cropping and rendering all appear to be correct. - Javascript injection correctly escaped for malicious .rst and .md files See updated screenshots (2012-11-24, in the files attachment section)
The reStructuredText_ Cheat Sheet: Syntax Reminders
Info: | See <http://docutils.sf.net/rst.html> for introductory docs. |
---|---|
Author: | David Goodger <goodger@python.org> |
Date: | 2012-06-22 |
Revision: | 7463 |
Description: | This is a "docinfo block", or bibliographic field list |
Section Structure
Section titles are underlined or overlined & underlined.
Body Elements
Grid table:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.9.1: http://docutils.sourceforge.net/" />
<title>The reStructuredText Cheat Sheet: Syntax Reminders</title>
<meta name="author" content="David Goodger <goodger@python.org>" />
<meta name="date" content="2012-06-22" />
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7434 2012-05-11 21:06:27Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borde
sack
s(hortcut)-ack: a faster way to use ack (and grep)!
sack acts as a wrapper for ack to provide convenience for the repetitive menial tasks
What is ack?
ack is the replacement for grep!
Here is why you should use ack over grep: http://betterthangrep.com/
(Now that you are sold on ack) To install ack in a one-line script:
curl http://betterthangrep.com/ack-standalone > ~/bin/ack && chmod 0755 !#:3
How to Install:
Open a terminal and run the following:
git clone git@github.com:sampson-chen/sack.git && cd sack && chmod +x install_sack.sh && ./install_sack.sh
How to Use:
You can use sack in exactly the same way you currently use ack! Woot!
For why sack is faster (and more fun!) to use, read on about its main / side features...
Main Feature 1 - Shortcuts:
sack prefixes shortcut tags to ack's search results:
user@linux:~/src$ sack thumbnail
... (omitted results)
/home/user/src/reviewboard/reviewboard/attachments/mimetypes.py
[13] 6
<h1>sack</h1>
<p>s(hortcut)-ack: a faster way to use ack (and grep)!</p>
<p>sack acts as a wrapper for ack to provide convenience for the repetitive menial tasks</p>
<h2>What is ack?</h2>
<p>ack is the replacement for grep!</p>
<p>Here is why you should use ack over grep: http://betterthangrep.com/</p>
<p>(Now that you are sold on ack) To install ack in a one-line script:</p>
<pre><code>curl http://betterthangrep.com/ack-standalone > ~/bin/ack && chmod 0755 !#:3
</code></pre>
<h2>How to Install:</h2>
<p>Open a terminal and run the following:</p>
<pre><code>git clone git@github.com:sampson-chen/sack.git && cd sack && chmod +x install_sack.sh && ./install_sack.sh
</code></pre>
<h2>How to Use:</h2>
<p>You can use sack in exactly the same way you currently use ack! Woot!</p>
<p>For why sack is faster (and more fun!) to use, read on about its main / side features...</p>
<h2>Main Feature 1 - Shortcuts:</h2>
<p>sack prefixes shortcut tags to ack's search res
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequa
t. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugia
t nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culp
a qui officia deserunt mollit anim id est laborum."
Review Board
Review Board is a web-based review tool designed to help projects and companies
keep track of pending code changes and make reviews of code, graphics, and more
much less painful and time-consuming. It's generic enough to use in any
project, and works at companies and organizations of any size.
Information on usage and installation can be found on
http://www.reviewboard.org/docs/manual/dev/
General information on the project is available on
http://www.reviewboard.org/
reviewboard/attachments/mimetypes.py |
---|
reviewboard/static/rb/css/reviews.less |
---|