Diff (to html) for Rails?

Hi,

I am looking for a way to compare to pieces of text, and mark up the
differences with html. Basically the way Basecamp Writeboards do it. I
was wondering whether this is available as a plugin (my initial search
didn’t turn up anything).

Ingo W.

HI,

2006/6/16, Ingo W. [email protected]:

I am looking for a way to compare to pieces of text, and mark up the
differences with html. Basically the way Basecamp Writeboards do it. I
was wondering whether this is available as a plugin (my initial search
didn’t turn up anything).

As I wrote on June 4:

There was a mail here on 3.10.05 from Joe C., I quote it below:


Just copy the library from here:
http://dev.instiki.org/file/instiki/trunk/lib/diff.rb.

Save it under your railsdir/lib as diff.rb
In your environment.rb add
require ‘diff’

To use the method in the controller do something like this:
@diff_results = HTMLDiff.diff(@object1.text_to_compare,
@object2.text_to_compare)

in your view do something like this:
<%= @diff_results %>

If you want to change the look of the results, add this to your
stylesheet:

del.diffmod {
color: #999;
background-color: #efefef;
}

ins.diffmod {
background-color: #cfc;
text-decoration: none;
color: #000;
}


HTH,
Beate