Created
December 15, 2009 17:57
-
-
Save johnthethird/257124 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
script/plugin install git://github.com/myobie/htmldiff.git | |
# bottom of environment.rb | |
require 'htmldiff' | |
# in model | |
class Page < ActiveRecord::Base | |
extend HTMLDiff | |
end | |
# in view | |
<h1>Revisions for <%= @page.name %></h1> | |
<ul> | |
<% @page.revisions.each do |revision| %> | |
<li> | |
<b>Revised <%= distance_of_time_in_words_to_now revision.created_at %> ago</b><BR> | |
<%= Page.diff( | |
revision.changes['description'][0], | |
revision.changes['description'][1] | |
) %> | |
<BR><BR> | |
</li> | |
<% end %> | |
# in style.css | |
ins.diffmod, ins.diffins { background: #d4fdd5; text-decoration: none; } | |
del.diffmod, del.diffdel { color: #ff9999; } | |
(from http://stackoverflow.com/questions/80091/diff-a-ruby-string-or-array/739161#739161) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment