discourse/discourse — pull request #785 by ZogStriP (2013-04-29 00:23:25+00:00)
Title: show diff in post history view

This adds diff on the post history view:

![Screenshot_29_04_13_02_01](https://f.cloud.github.com/assets/362783/436636/1407446a-b060-11e2-8b39-f6ce7b0576a0.png)

This uses the [`google-diff-match-patch`](https://code.google.com/p/google-diff-match-patch/) javascript library to compute and display the diff in the post history view.

I've removed both `match` and `patch` code from the library as they are not used and I slightly modified the `diff_prettyHtml` to work better with HTML.

This will compute the diff whenever the right or left version is changed.

**A note of warning:** there are some *edge* cases where the diff is not accurate as the library was made for working with plain text and I'm feeding it with the `cooked HTML` of both posts. I'm planning on fixing it granted that this is the way to go.

Indeed, another solution to display the diffs would be to compute them server-side using `lib/diff_engine.rb`. This would have the advantage to only have to compute the diffs once per (old version, new version) combinations. But this also requires *quite* a lot of changes in the way the history view is working.

On the other hand, my solution integrates quite easily with the current code of the history view, but has the drawbacks of computing the diff on the client and not caching it.

What do you think?