Built-in visualization of age content
I have two tables, pages and revisions. Changes have a foreign key to the page. The page content is the last entry in the version table for that page. Changes are full copies of the content, no deltas.
As an experiment, I would like to visualize the revision state of the current revision. If the text is not new in the new edition, do nothing. If it's from a recent version, give it a green background color. If it is very old, give it a red background color. Between them, orange. For example, a heatmap is different from a hold time.
My question is: How can I retrieve this data from page revisions? Literature pointers would be equally useful for the actual code to solve this problem.
Not very relevant, but just in case: this is for a Ruby project, Ruby on Rails. Here's the project, on github .
Update: Here's an example test case written in Ruby. http://pastie.org/631604
source to share
Update: [long and slightly off-topic answer to long common subsequence removed]
I have integrated my Hunt-McIlroy Algorithm Search Algorithm subsequence search with your test case which is now passing. I made some mods for your test case, see here at pastie.org. Likewise, here is the rdiff module . Here is my svn log why your test case changed .
source to share
One quick way to do this is to get consistent versions of the page and run them through the diff utility to get the delta so you know how to color. Of course, you could reinvent code that comes from two full pages and discovers what bits they have in common, but it will be easier to reuse existing code.
source to share
You can use svn blame command to get similar results. Of course, changes and pages must be stored in svn. If going to svn is a road block, perhaps examining the svn sources as the blame command is written might help.
Edit: @August To render this, I need something that doesn't care about lines. Is not it?
Well, you have to blame for the lines and diff for the content of one line. The first is done by VCS, the second is you can do it yourself or third-party code. For each repository of changes in the database, the blame delta is estimated (only the changed rows need to be saved). In the sample results for one row, we have:
Rev. num. Value
23 Hello worl
36 Hello cruel world
45 Hello wonderful world
The desired result for you I assume (for clarity, I missed the spaces)
Afer first diff:
(Hello)(23)(cruel)(36)(worl)(23)(d)(36)
After the second difference:
(Hello)(23)(wonderful)(45)(worl)(23)(d)(36)
Unified diff does not help in this case, so diff must be done differently. You can write algoritm for diff yourself, or find the appropriate code in the merge tools. Below is an example of how TortiseMerge makes stuff.
merge ants http://img169.imageshack.us/img169/7871/merge.png
The problem is not easy, but I think my ideas may help you a little or give you any hints.
source to share