Magnolia CMS Modules

by Devexperts

Child pages
  • dx-sync-module

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

It allows to edit templates scripts, CSS, JavaScript and other files directly from IDE or editor of your choice. Changes are instantly propagated to Magnolia repositories of a running Magnolia instance.
So you can preview your changes on the website as soon as you save your files.
Creating, updating, deleting and renaming files operations are supported. 

Content

Table of Contents
excludeContent

...

Download the latest module version.
Note: it is going to be available as a Maven artefact soon.

Download

Go to Downloads page and download the latest version of dx-sync-module-1.1.1.jardx-sync-module-1.1.1-sources.jar 

Install

First, you need to install jnotify http://jnotify.sourceforge.net/ library to your servlet container, including both java and native library parts.
This library is used to get notifications from the file system about file updates.
You can download it from here:

...

mvn install:install-file -DgroupId=com.devexperts.web -DartifactId=dx-sync-module -Dversion=1.1.12 -Dpackaging=jar -Dfile=dx-sync-module-1.1.12.jar -DgeneratePom=true
mvn install:install-file -DgroupId=com.devexperts.web -DartifactId=dx-sync-module -Dversion=1.1.12 -Dpackaging=jar -Dclassifier=sources -Dfile=dx-sync-module-1.1.12-sources.jar -DgeneratePom=false

...

<dependency>
<groupId>com.devexperts.web</groupId>
<artifactId>dx-sync-module</artifactId>
<version>1.1.1<2</version>
</dependency>
Configuration

...

Code Block
super("web-devspace");
keepUpToDateResources("/mgnl-files", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.MGNL_FILE);
keepUpToDateResources("/abc/img", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.DMS_FILE);
keepUpToDateResources("/abc/themes/img", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.DMS_FILE);
keepUpToDateResources("/dev/docs", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.DMS_FILE);
keepUpToDateResources("/abc/js", Scope.FOLDER_ONLY, ResourceType.RESOURCE_PROCESSED_JS);
keepUpToDateResources("/abc/js", Scope.SUBFOLDERS_ONLY, ResourceType.RESOURCE_JS);
keepUpToDateResources("/abc/themes/abc/css", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.RESOURCE_PROCESSED_CSS);
keepUpToDateResources("/abc/emails", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.TEMPLATE);
keepUpToDateResources("/abc/paragraphs", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.TEMPLATE);
keepUpToDateResources("/abc/templates", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.TEMPLATE);
keepUpToDateResources("/search-module/templates", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.TEMPLATE);
keepUpToDateResources("/abc/groovy", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.GROOVY_SCRIPT);

DxModuleVersionHandler may work in 2 modes.

  • Development mode.
    This mode is in use when -DdevPlatform=true JVM argument is specified. In this case all changes in source files are instantly propagated to the running Magnolia CMS.
  • Production mode.
    This mode is used by default. All resources are synchronized on module start up using usual Magnolia tasks.
    Note: you don't need jnotify library in Production mode.
Note: dependent on how you run your project you may still to specify path to the root of your source files via dx.sync.sources system property. See the next section for details.
File-based configuration

You can specify which files are to be synchronized in a configuration file.
Synchronization is performed on a directory basis. Each directory that is needed synchronization should be listed in the configuration file.

...

Specify them by adding -Ddx.sync.sources=<path to source files root> -Ddx.sync.config=<path to configuration file> to the JVM startup command line.
Synchronizing module resources 

DxModuleVersionHandler has an additional functionality of synchronizing resources on start-up.
You can use it instead of writing BootstrapSingleModuleResource tasks in your version handler and updating your module version.

All XML files you need to be bootstraped can be placed under /dx-resources folder in module resources.
Files under resource directory /dx-resources/keepUpToDate (including subdirectories) will be bootstraped on module start up, if they have been changed.
Files under resource directory /dx-resources/installOnce (including subdirectories) will be bootstraped on module start up, if a corresponding node doesn't exist in repository.
For files under resource directory /dx-resources/remove (including subdirectories) a check if a corresponding node exists in repository will be performed on module start up. If it is, it will be removed.

Note that DxModuleVersionHandler usually works significantly faster than Boostrap*** tasks, and you don't need to write code and update module versions.

License 

The module is released under GPL license. Contact us if you need this module under different license.

...