MI-DPLA / combine

Combine /kämˌbīn/ - Metadata Aggregator Platform
MIT License
26 stars 11 forks source link

Improve Record diff, XML/JSON output #173

Closed ghukill closed 6 years ago

ghukill commented 6 years ago

Consider using sxsdiff library for Github-esque diffs between Record documents.

Spike code for models.py:

from sxsdiff import DiffCalculator
from sxsdiff.generators.github import GitHubStyledGenerator
import io

sxsdiff_result = DiffCalculator().run(ir.document, self.document)
sio = io.StringIO()
GitHubStyledGenerator(file=sio).run(sxsdiff_result)
sio.seek(0)
return sio.read()

And then in the view record.html:

{% if input_record_diffs %}
    <div>
         {{ input_record_diffs|safe }}
    </div>
{% else %}
    <p>During Transformation, no changes were detected for this Record.</p>
{% endif %}

The result looks great, but it is considerably slower than using python's diff library. And though visibly attractive, also includes lines that are unchanged which can be redundant. Keeping old, faster method for now, but saving this here in case.

Additioanally, made it apparent how nice it would be to have line numbers for ALL document output (XML, JSON, etc.)

ghukill commented 6 years ago

Closing - optional "side-by-side" diff when viewing Record Changes, which opens new tab. This prevents long load time for each record, but ability to see this, arguably, more detailed view.