RFS Rules

This is a general improvement to the default configuration.

Until now, you could specify a set of settings for the static export, like <rfs-prefix>, <exportpath> and <userelativelinks> , which were global settings and you had no possibility to have different settings for different resource sets. The idea of the rfs-rules is to complement this global settings, being able to specify different settings for different resource sets.

The rfs rules as also all the other configuration settings for the Static Export Feature should be given in the ${CONTEXT_NAME}/WEB-INF/config/opencms-importexport.xml configuration file.

An rfs rule needs following data.

  • Name: The name of the rule .
  • Description: A precise description of the uses of this rule.
  • Source: A regular expression that indicates the set of resources that apply this rule.
  • RFS-Prefix: The prefix to add to the link of a resource.
  • Export Path: A rfs path where the exported files will be written, it could be absolute like /path/to/export/ or c:\path\to\export, or relative to the OpenCms installation directory like ../export.
  • Use Relative Links: This boolean setting says if the generated links should be absolute or relative. Optional, if not given the global setting is used.
  • Related System Resources: A list of regular expressions that should specify all resources in the /system/ folder used by the source resource set. This resources will also be exported to the given export path.

For instance, let's say we have two different sites, using both the same base template having resources under /system/modules/master.template/ and /system/galleries/pics/master.template/

  • Site One: This site has to be accessible at http://www.site-one.com, and is configured in OpenCms at /sites/site1/, for these we have an Apache server serving from /var/apache/site1/ .
  • Site Two: This site has to be accessible at http://www.site-two.com, and is configured in OpenCms as /sites/site2/, for these we have the same Apache server serving from /var/apache/site2/, using an additional template having resources under /system/modules/site2.template/ and /system/galleries/pics/site2.template/, with relative links.

The site configuration in our ${CONTEXT_NAME}/WEB-INF/config/opencms-system.xml configuration file should look like:

        <sites>
            <workplace-server>http://www.workplace.com</workplace-server>
            <default-uri>/sites/default/</default-uri>
            <site server="http://www.default.com" uri="/sites/default/"/>
            <site server="http://www.site-one.com" uri="/sites/site1/"/>
            <site server="http://www.site-two.com" uri="/sites/site2/"/>
        </sites>

And the rfs-rule definitions in your  ${CONTEXT_NAME}/WEB-INF/config/opencms-importexport.xml configuration file, under the <rendersettings> node, should look like:

    <rfs-rules>
        <rfs-rule>
            <name>site-one</name>
            <description>This is the rfs-rule for site one</description>
            <source>/sites/site1/.*</source>
            <rfs-prefix></rfs-prefix>
            <exportpath>c:/apache/site1</exportpath>
            <related-system-res>
                <regex>/system/modules/master.template/.*</regex>
                <regex>/system/galleries/pics/master.template/.*</regex>
            </related-system-res>
        </rfs-rule>
        <rfs-rule>
            <name>site-two</name>
            <description>This is the rfs-rule for site two</description>
            <source>/sites/site2/.*</source>
            <rfs-prefix></rfs-prefix>
            <exportpath>c:/apache/site2</exportpath>
            <userelativelinks>true</userelativelinks>           
            <related-system-res>
                <regex>/system/modules/master.template/.*</regex>
                <regex>/system/galleries/pics/master.template/.*</regex>
                <regex>/system/modules/site2.template/.*</regex>
                <regex>/system/galleries/pics/site2.template/.*</regex>
            </related-system-res>
        </rfs-rule>
    </rfs-rules>

The default behaviour is still the same as before, if a exported resource does not match any rule, the global settings are used instead (all system resources are written to the global default export path).