The Diff module enhances Magnolia core versioning functionality. The module uses the daisydiff Java library to compare two HTML files. Insertions are highlighted in green and deletions in red. Users can see exactly what has changed between two versions of the same content. The module is used by the Pages app to compare page versions. Line-by-line text comparison and changes in asset selection allow editors and publishers to see at a glance exactly what has changed. Diff functionality can also be enabled to compare changes to templates and resources edited in-line in the Standard Templating Kit.

Please note that the artifact's IDs (Maven groupId and artifactId) have changed since Magnolia 5.5.

If you have custom Java code relying on this module, you need to install a compatibility module too.

To be sure - please check the module on our Bitbucket server.


Installing

Maven is the easiest way to install the module. Add the following to your bundle:

Note the changes in groupId and artifactId since the 2.0 release.

Error rendering macro 'artifact-maven-dependencies-snippet-macro'

com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java class info.magnolia.sys.confluence.plugin.artifactinfo.nexus.entities.SearchNGResponse, and Java type class info.magnolia.sys.confluence.plugin.artifactinfo.nexus.entities.SearchNGResponse, and MIME media type application/octet-stream was not found

For integration with the Pages app there is also magnolia-diff-pages-integration.

Error rendering macro 'artifact-maven-dependencies-snippet-macro'

com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java class info.magnolia.sys.confluence.plugin.artifactinfo.nexus.entities.SearchNGResponse, and Java type class info.magnolia.sys.confluence.plugin.artifactinfo.nexus.entities.SearchNGResponse, and MIME media type application/octet-stream was not found

Pre-built JARs are also available for download. See Installing a module for help.

  • Error rendering macro 'artifact-resource-macro'

    com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java class info.magnolia.sys.confluence.plugin.artifactinfo.nexus.entities.SearchNGResponse, and Java type class info.magnolia.sys.confluence.plugin.artifactinfo.nexus.entities.SearchNGResponse, and MIME media type application/octet-stream was not found

  • Error rendering macro 'artifact-resource-macro'

    com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java class info.magnolia.sys.confluence.plugin.artifactinfo.nexus.entities.SearchNGResponse, and Java type class info.magnolia.sys.confluence.plugin.artifactinfo.nexus.entities.SearchNGResponse, and MIME media type application/octet-stream was not found

Compatibility module

With Magnolia 5.6 we've begun removing the old Content API from our modules. If you have custom code relying on classes from the old diff module then you must do one of two things:

  • Update your code for the new version of the diff module.
  • Or you can use the magnolia-diff-compatibility module together with the magnolia-core-compatibility module.

With maven:

Add the following snippet to you pom file:

Error rendering macro 'artifact-maven-dependencies-snippet-macro'

com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java class info.magnolia.sys.confluence.plugin.artifactinfo.nexus.entities.SearchNGResponse, and Java type class info.magnolia.sys.confluence.plugin.artifactinfo.nexus.entities.SearchNGResponse, and MIME media type application/octet-stream was not found

Manually:

Add these jar files to the WEB-INF/lib folder of your webapp:

  • Error rendering macro 'artifact-resource-macro'

    com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java class info.magnolia.sys.confluence.plugin.artifactinfo.nexus.entities.SearchNGResponse, and Java type class info.magnolia.sys.confluence.plugin.artifactinfo.nexus.entities.SearchNGResponse, and MIME media type application/octet-stream was not found

  • Error rendering macro 'artifact-resource-macro'

    com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java class info.magnolia.sys.confluence.plugin.artifactinfo.nexus.entities.SearchNGResponse, and Java type class info.magnolia.sys.confluence.plugin.artifactinfo.nexus.entities.SearchNGResponse, and MIME media type application/octet-stream was not found

Configuration

In most circumstances the Diff module requires no configuration.

However, version comparison relies on functionality provided by the Diff module and, if implemented, may require the following configuration.

Diff servlet

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

Node nameValue

 
VersionDiffHtmlServlet


 
mappings


 
-.magnolia-versionDiff


 
pattern

/.magnolia/versionDiff

 
parameters


 
class

info.magnolia.cms.filters.ServletDispatchingFilter

 
comment

 Shows html diff of different page versions.

 
enabled

 true

 
servletClass

 info.magnolia.module.diff.VersionDiffHtmlServlet

 
servletName

 VersionDiffHtmlServlet

Diff configuration

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 the diff module in the Configuration app > /modules/diff/config/cookies

Node nameValue
 
modules

 
diff


 
config


 
cookie


 
0

JSESSIONID

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.

Node nameValue

 
diff


 
config


 
cookies


 
0

<cookieA>

 
1

<cookieB>

 
headers


 
0

<headerA>

 
1

<headerB>

 
host

<host>

 
port

<port>

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;
}

Diff utility classes

Two utility classes are provided:

  • DiffUtil provides the buildComparisonURLbuildComparisonURLToCurrent and buildComparisonURLToCurrentUnversioned methods.
  • VersionComparisona POJO that gets and sets the versionFrom and versionTo methods.

Compare actions

The CompareLocalizedVersionsAction and CompareToPreviousLocalizedVersionAction open the diff subapp (see below) configured in the Pages app. The action definitions are configured in the Configuration app > /modules/pages/apps/pages/subApps/browser/actions.

Node nameValue
 
modules

 
pages


 
apps


 
pages


 
subApps


 
browser


 
actions


 
compareVersions


 
availability


 
class

info.magnolia.module.diff.app.action.CompareLocalizedVersionsActionDefinition

 
icon

icon-compare-versions

 
label

Compare versions

 
compareToPreviousVersion


 
availability


 
class

info.magnolia.module.diff.app.action.CompareToPreviousLocalizedVersionActionDefinition

 
icon

 icon-compare-versions

 
label

 Compare to previous version

Diff subapp

The diff view that opens when comparing different page versions is configured in the Pages app. This configuration is in the Configuration app > /modules/pages/apps/pages/subApps/diff.

  • classEmbeddedPageSubAppDescriptor embeds the page in an iframe. 
  • label: Renders in the subapp tab.
  • subAppClassEmbeddedPageSubApp is the main tab in an embedded page app.
Node nameValue
 
modules

 
pages


 
apps


 
pages


 
subApps


 
browser


 
detail


 
diff


 
class

info.magnolia.ui.framework.app.embedded.EmbeddedPageSubAppDescriptor

 
label

 Show changes

 
subAppClass

 info.magnolia.ui.framework.app.embedded.EmbeddedPageSubApp

Here's the diff subapp for the /travel/about/what-we-believe  page. The URL is http://localhost:8080/magnoliaAuthor/.magnolia/admincentral#app:pages:diff;/magnoliaAuthor/.magnolia/versionDiff?diffViewContentHandle=/travel/about/what-we-believe&fromVersionNr=1.2&toVersionNr=1.0  . Note the reference to the  diffViewContentHandle and VersionNr parameters



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

1 Comment

  1. We are missing documentation for the 'ssl' option which is configurable under "diff > config > ..." (in parallel with "host" and "port" configuration point). Please getting more information from our development team and update it accordingly.