The Diff module allows you to compare page versions. Content authors and reviewers can see exactly what has changed between two versions of a page with the redlining feature. It allows line-by-line comparison of text and also displays changes to media files such as images.

Download

Download the Diff module from Magnolia Store or Nexus repository.

Installing

Diff is an enterprise module included in the Enterprise Edition bundle and typically already installed. Go to Magnolia Store > Installed modules in AdminCentral to check. To install the module individually, see the general module installation instructions.

Uninstalling

See the general module uninstalling instructions and advice.

Configuration

(warning) Magnolia 4.5.10/Diff 1.1.5 +. The default settings for headers, cookies, host and port can be set by configuration.

By default Magnolia is set to generate a JSESSIONID cookie. This is configured in /modules/diff/config/cookies.


You can configure custom settings for:

  • cookies: You can specify any number of custom session cookie names to forward.
  • headers: The default value is none. By adding a  headers config node you can specify any number of headers to be sent to the diff servlet thereby automatically excluding any headers that are not specified.
  • host and port: The default host and port is localhost and 8080. However, the Diff module will work even if you change the default Tomcat port. This means that you can use the diff functionality against another server.

(warning) Headers and cookies are configured separately.


Diff servlet

VersionDiffHtmlServlet is registered in the Magnolia filter chain in /server/filters/servlets/VersionDiffHtmlServlet. The controller generates the diff view between two versions of a page by checking the toVersionNr and fromVersionNr request parameters.

Diff HTML generator

VersionDiffHtmlGenerator compares two HTML files using HTMLDiffer and returns HTML that highlights the differences between the compared pages:

  • The comparison only includes the body of the HTML document.
  • The differences are marked with span tags.
  • The header is taken from the HTML of the page that is compared to.
  • CSS is added.

Here's a snippet from diff.css (GIT) located in the mgnl-resources folder of the module jar

/*
 * Styles for the HTML Diff
 */
span.diff-html-added {
    font-size: 100%;
    background-color: #ccffcc; /* light green */
    cursor: pointer;
}
span.diff-html-removed {
    font-size: 100%;
    text-decoration: line-through;
    background-color: #fc6f6f; /* light red */
    cursor: pointer;
}
span.diff-html-changed {
    background-color: #95c6fd; /* light blue */
    cursor: pointer;
}
span.diff-html-selected {
    background-color: #FF8800; /* light orange */
    cursor: pointer;
}

Usage

See Viewing a version.

#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))