Configurable Magnolia CMS Versions


License

License

Categories

Categories

config Application Layer Libs Configuration
GroupId

GroupId

it.schm.magnolia
ArtifactId

ArtifactId

magnolia-configurable-version
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Configurable Magnolia CMS Versions
Configurable Magnolia CMS Versions
Project URL

Project URL

https://github.com/hdensity/magnolia-configurable-version
Source Code Management

Source Code Management

http://github.com/hdensity/magnolia-configurable-version/tree/master

Download magnolia-configurable-version

How to add to project

<!-- https://jarcasting.com/artifacts/it.schm.magnolia/magnolia-configurable-version/ -->
<dependency>
    <groupId>it.schm.magnolia</groupId>
    <artifactId>magnolia-configurable-version</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/it.schm.magnolia/magnolia-configurable-version/
implementation 'it.schm.magnolia:magnolia-configurable-version:1.0.0'
// https://jarcasting.com/artifacts/it.schm.magnolia/magnolia-configurable-version/
implementation ("it.schm.magnolia:magnolia-configurable-version:1.0.0")
'it.schm.magnolia:magnolia-configurable-version:jar:1.0.0'
<dependency org="it.schm.magnolia" name="magnolia-configurable-version" rev="1.0.0">
  <artifact name="magnolia-configurable-version" type="jar" />
</dependency>
@Grapes(
@Grab(group='it.schm.magnolia', module='magnolia-configurable-version', version='1.0.0')
)
libraryDependencies += "it.schm.magnolia" % "magnolia-configurable-version" % "1.0.0"
[it.schm.magnolia/magnolia-configurable-version "1.0.0"]

Dependencies

compile (3)

Group / Artifact Type Version
info.magnolia » magnolia-core jar
javax.inject : javax.inject jar
org.projectlombok : lombok jar

test (8)

Group / Artifact Type Version
info.magnolia » magnolia-core test-jar
org.apache.tomcat.embed : tomcat-embed-core jar 9.0.35
org.junit.jupiter : junit-jupiter jar 5.6.2
org.mockito : mockito-core jar 3.3.3
org.mockito : mockito-junit-jupiter jar 3.3.3
org.assertj : assertj-core jar 3.16.0
nl.jqno.equalsverifier : equalsverifier jar 3.1.13
org.jacoco : org.jacoco.agent jar 0.8.5

Project Modules

There are no modules declared in this project.

Configurable versions for Magnolia CMS 6.2 CE

GitHub Build Status Coverage Status Maintainability Code Climate issues Maven Central Active

Magnolia versions pages, assets and contacts by default when they are published and unpublished. You can also configure versioning for any other content type. The Community Edition of Magnolia CMS, by default, limits the number of versions kept to 3 and does not allow you to change it. With this module, that number becomes easily configurable.

Installation

To install the Magnolia Configurable Version module, add a maven dependency to your webapp bundle:

<properties>
    <version.magnolia.configurable.version>1.0.0</version.magnolia.configurable.version>
</properties>

<dependency>
    <groupId>it.schm.magnolia</groupId>
    <artifactId>magnolia-configurable-version</artifactId>
    <version>${version.magnolia.configurable.version}</version>
</dependency>

Additionally, to ensure your custom configuration is applied after module defaults have already been loaded, add the following to your module descriptor, which is usually found under src/main/resources/META-INF/magnolia/<module-name>.xml

<dependencies>
    <dependency>
        <name>configurable-version</name>
        <version>1.0.0/*</version>
    </dependency>
</dependencies>

Usage

Without further configuration this module recreates the defaults of the base community edition versioning, i.e. versioning is active and at most 3 versions are kept. You can change the default configuration in 3 ways:

  1. using a task in a module version handler
  2. bootstrapping the necessary configuration
  3. manually setting the values at runtime

Module Version Handler

We provide the ConfigureVersionTask class, a custom Task implementation, which you can use in your module version handler to set the configuration of this module:

public class MyVersionHandler extends DefaultModuleVersionHandler {

    @Override
    protected List<Task> getExtraInstallTasks(InstallContext installContext) {
        List<Task> tasks = new ArrayList<>();
        tasks.add(new ConfigureVersionTask(true, 42L));

        return tasks;
    }

}

Line 6 shows the task in use, which in this case (true) enables versioning and (42L) tells it to keep 42 versions.

Bootstrapping

Alternatively you can also bootstrap the configuration. Add a file named config.server.version.xml or config.server.version.yaml in your bootstrap folder and add the following content, replacing ?active? and ?maxVersions? with your required values:

XML

<?xml version="1.0" encoding="UTF-8"?>
<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" sv:name="version">
  <sv:property sv:name="jcr:primaryType" sv:type="Name">
    <sv:value>mgnl:content</sv:value>
  </sv:property>
  <sv:property sv:name="jcr:mixinTypes" sv:type="Name">
    <sv:value>mix:versionable</sv:value>
  </sv:property>
  <sv:property sv:name="active" sv:type="String">
    <sv:value>?active?</sv:value>
  </sv:property>
  <sv:property sv:name="maxVersionIndex" sv:type="String">
    <sv:value>?maxVersions?</sv:value>
  </sv:property>
</sv:node>

YAML

'version':
  'active': ?active?
  'maxVersionIndex': ?maxVersions?

Manual

Lastly, you can also manually change the configuration on a running author instance of Magnolia CMS. To achieve this, open the Configuration app and navigate to /server/version. You can adjust the properties active and maxVersionIndex to your needs.

Please note, we recommend the former two approaches, as they allow you to put your configuration under source control.

License

This project is licensed under the MIT License; see the LICENSE file for details.

Copyright 2020 © Sam Schmit-Van Werweke

Versions

Version
1.0.0