/cfdiff.html
HTML | 100 lines | 100 code | 0 blank | 0 comment | 0 complexity | b064cd90e3b41d9b49993971fc817e18 MD5 | raw file
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2<html lang="en" xml:lang="en"> 3<head> 4<title>cfdiff Documentation</title> 5<style type="text/css" title="cfdiff"> 6html, body { 7 padding: 8px; 8 background-color: white; 9 color: black; 10 font-size: 1em; 11} 12h1 { 13 margin: -24px -24px 0px -24px; 14 padding: 8px; 15 color: #def; 16 background-color: #248; 17 border-bottom: 1px dashed #acf; 18 font-size: 2em; 19} 20h2 { 21 margin: 0px -24px 8px -24px; 22 padding: 4px 8px; 23 border: 1px solid #248; 24 border-top: none; 25 background-color: #48f; 26 color: #def; 27 font-size: 1.5em; 28} 29.filelist { width: 100%; border: 1px solid #999; } 30.filelist th, .foot { background-color: #ccf; } 31.even { background-color: #e8e8ff; } 32.file, code, pre.code { font-family: 'Bitstream Sans Mono', 'Sans Mono', 'Lucida Console', 'Monaco', 'Lucida Typewriter', 'Courier New', Courier, fixed-width, monospace; } 33.file { color: maroon; } 34pre.code, code { background-color: #ffd; } 35pre.code { border-left: 1px solid #ff9; border-right: 1px solid #ff9; padding: 0.75em; max-height: 8em; overflow: auto; } 36</style> 37</head> 38<body> 39<h1>cfdiff</h1> 40<h2>Quick Start</h2> 41<ol> 42 <li>There's no ZIP/TAR archive of the project, so you'll need to download each of the files individually from <a href="http://cfdiff.googlecode.com/svn/trunk/" target="_blank">the cfdiff Google Code repository</a>. See the next section for a list of what each of the files do.</li> 43 <li>Copy at least the <kbd class="file">diff.cfc</kbd> file to your CFC area. 44 <ul> 45 <li><strong>If you are the organized type ... </strong> make a folder in your web root named <kbd class="file">org</kbd>, then a subfolder under that named <kbd class="file">rickosborne</kbd>, and put the file under there.</li> 46 <li><strong>If you are the lazy type ... </strong> drop it in your web root.</li> 47 <li><strong>If you know what you are doing ... </strong> then I really don't care where you drop it.</li> 48 </ul> 49 </li> 50 <li>Write some code that does something like this: 51 <pre class="code"><cfset Differ = CreateObject("component", "org.rickosborne.diff")> 52<cfset LeftFile = ListToArray("a,b,c,d,e,f,g")> 53<cfset RightFile = ListToArray("a,d,e,1,2,f,g,h")> 54<cfset Difference = Differ.DiffArrays(LeftFile, RightFile)> 55<cfset Pretty = Differ.Parallelize(Difference, LeftFile, RightFile)></pre> 56 If you chose the <em>lazy</em> option from the previous list, your call to create the CFC will look like this: 57 <pre class="code"><cfset Differ=CreateObject("component","diff")></pre> 58 If you chose the third option, then I presume you can figure out how to create the object. 59 </li> 60 <li>That last variable, <code>Pretty</code>, is the one you'll want to dump or loop over or whatever. If you prefer a unified diff instead of parallel, you can use <code>UnifiedDiffArrays()</code> instead of <code>Parallelize()</code> with the same arguments.</li> 61</ol> 62<h2>Files</h2> 63<table class="filelist"> 64 <thead> 65 <tr> 66 <th>File</th> 67 <th>Purpose</th> 68 <th nowrap="nowrap">Final Location</th> 69 </tr> 70 </thead> 71 <tbody> 72 <tr class="odd"><td class="file"><a href="http://cfdiff.googlecode.com/svn/trunk/cfdiff.css">cfdiff.css</a></td><td>Example stylesheet for the SVN browser.</td><td>SVN Browser root.</td></tr> 73 <tr class="even"><td class="file"><a href="http://cfdiff.googlecode.com/svn/trunk/diff.cfc">diff.cfc</a></td><td>The main component that does all of the work.</td><td>See above. Maybe web root, maybe not.</td></tr> 74 <tr class="odd"><td class="file"><a href="http://cfdiff.googlecode.com/svn/trunk/difftest.cfc">difftest.cfc</a></td><td>Unit tests for the <kbd class="file">diff.cfc</kbd> file.</td><td><em>Not required.</em></td></tr> 75 <tr class="even"><td class="file"><a href="http://cfdiff.googlecode.com/svn/trunk/svn.cfm">svn.cfm</a></td><td>Basic SVN browser front-end.</td><td>Web root?</td></tr> 76 <tr class="odd"><td class="file"><a href="http://cfdiff.googlecode.com/svn/trunk/svnbrowser.cfc">svnbrowser.cfc</a></td><td>Back-end for the SVN browser that interfaces with the JavaSVN API.</td><td>See above. Maybe web root, maybe not.</td></tr> 77 <tr class="even"><td class="file"><a href="http://cfdiff.googlecode.com/svn/trunk/testdiff.cfm">testdiff.cfm</a></td><td>Used to run the unit tests for <kbd class="file">diff.cfc</kbd>.</td><td><em>Not required.</em></td></tr> 78 </tbody> 79 <tfoot> 80 <tr class="foot"><td colspan="3">6 files.</td></tr> 81 </tfoot> 82</table> 83<h2>Implementation Details</h2> 84<p>If you want to use the SVN Browser, you'll need to install the <a href="http://tmate.org/svn/" target="_blank">TMate JavaSVN library</a>. If you just want to run diffs, you <strong>do not</strong> need this library.</p> 85<p>Look at <kbd class="file">svn.cfm</kbd> for the easiest way to show a diff. It's going to look something like this:</p> 86<pre class="code"><cfloop query="Pretty"> 87 <tr> 88 <td><cfif IsNumeric(AtFirst)>#NumberFormat(AtFirst)#<cfelse>&nbsp;</cfif></td> 89 <td><cfif Len(ValueFirst) GT 0>#Replace(HTMLEditFormat(ValueFirst),Chr(9),"&nbsp;&nbsp;&nbsp;","ALL")#<cfelse>&nbsp;</cfif></td> 90 <td><cfif IsNumeric(AtSecond)>#NumberFormat(AtSecond)#<cfelse>&nbsp;</cfif></td> 91 <td><cfif Len(ValueSecond) GT 0>#Replace(HTMLEditFormat(ValueSecond),Chr(9),"&nbsp;&nbsp;&nbsp;","ALL")#<cfelse>&nbsp;</cfif></td> 92 </tr> 93</cfloop></pre> 94<p>If you decide you'd prefer to work with the raw difference, that's what that intermediate <code>Difference</code> variable is. Go to town.</p> 95<h2>License</h2> 96<p>This code is licensed under the <a href="http://www.mozilla.org/MPL/" target="_blank">Mozilla Public License (MPL) version 1.1</a>. Read the license before you use the code!</p> 97<h2>Version / About</h2> 98<p>Original ColdFusion code by <a href="http://rickosborne.org/">Rick Osborne</a>, 2006. The code includes an algorithm translated from the C-Sharp source by <a href="http://www.mathertel.de/Diff/">Matthias Hertel</a>, which itself was originally released under the <a href="http://creativecommons.org/licenses/by/2.0/de/">Creative Commons Attribution 2.0 Germany license</a> and is based on a paper by Eugene Meyers in <em>Algorithmica Vol. 1 No. 2, 1986, p 251: "An O(ND) Difference Algorithm and its Variations"</em>.</p> 99</body> 100</html>