tags:

views:

290

answers:

4

In a content management system, moderators have to approve changes to existing articles. Currently the system shows the old and the revised version of the text in plain text. It is a pain to find the actual differences.

In GoogleDocs, there is a 'Compare revisions' feature which highlights the differences between two documents.

If there a free component out there that does the same thing?

If not, would you write such a component in JavaScript or on the server side?

All the usual diff tools are desktop applications.

+1  A: 

If you're working with PHP, you may find SimpleDIFF to be helpful.

Jonathan Sampson
+2  A: 

jsdifflib looks like an interesting javascript-based client side library. I would lean strongly toward a client-side implementation if it provided the features that you needed. Why tax your servers on presentation logic when you're already handing the client the data anyway?

David Berger
After implementing this I realized that if the article is like 100k with small changes, the user has to download 200k of text or which only 100k are displayed. So if you have large content pieces it may be better to do the diffing on the server.
Peter Hahndorf
Yes, that is the other side of it.
David Berger
+2  A: 

John Resig wrote one in JavaScript that looks interesting.

Here it is.

Chris Nielsen
Very nice.
Jonathan Sampson
If it is good enough for Mr. Resig, it is good enough for me. Small and usable on the client regardless what's on the server. Thanks.
Peter Hahndorf
+1  A: 

Try Pretty Diff tool. It is based upon jsdifflib, but is enhanced to highlight per character differences and rebuilt for speed. It also compares minified code to unminified code. It is entirely written in JavaScript and supports JavaScript, CSS, and XML/XHTML input.

http://mailmarkup.org/prettydiff/prettydiff.html