Export Rules
This is a new feature of the org.opencms.staticexport.CmsAfterPublishStaticExportHandler
(also used wenn calling the static export tool in the Administration View). So
to be able to take advantaje of this feature you have to set your default static
export handler to this. That is, your static export handler definition in the
${CONTEXT_NAME}/WEB-INF/config/opencms-importexport.xml configuration file should look like: <staticexporthandler>org.opencms.staticexport.CmsAfterPublishStaticExportHandler</staticexporthandler>
An export rule let you specify a set of resources to export if a modified
resource matches a set of rules. And the main idea behind it, is to optimize the
needed time used to do an static export after publish. Until now, every time a
resource has been published, OpenCms mades a static export of all resources
in the vfs! (at least all resources matched by the <regex> patterns in the <resourcetorender> node) since there
was no possibility to know the dependencies of a file. So, this new feature lets
OpenCms know which are the dependencies of a set of resources.
The export 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 export rule needs following data.
- Name: The name of the rule
- Description: A precise description of the uses of this
rule
- Modified-Resources: One or more regular expressions that should
specify a set of resources. If one of this resources becomes published,
all resources specified by the <export-resources> node will be
exported again.
- Export-Resources: One or more uri (resources or folders) indicating a set
of resources to be exported if any of the resources specified with the
<modified-resources> node
becomes published.
Here the two most common application cases:
- Imagine you have some template resources under /system/modules/mymodule/template/, and the
pages that use this template are under /sites/mysite/, so we want an export rule that
should be able to export all pages under /sites/mysite/ if any template resources in
/system/modules/mymodule/template/ is
published. Such an export rule for this situation would look like:
<export-rule> <name>mysite-template</name> <description>This rule will export all resources under /sites/mysite/, if any resource under /system/modules/mymodule/template/ is modified</description> <modified-resources> <regex>/system/modules/mymodule/template/.*</regex> </modified-resources> <export-resources> <uri>/sites/mysite/</uri> </export-resources> </export-rule>
- The second common situation is to have some XML-content like news
under /sites/mysite/modules/news/
and you display this news in an index.html and a news.html file, i.e. we want an export
rule that should be able to export the index.html and the news.html files if any resource in
/sites/mysite/modules/news/ becomes
published. A rule for this situation would look like:
<export-rule> <name>mysite-news</name> <description>This rule will export the index.html and the news.html files in folder /sites/mysite/, if any resource under /sites/mysite/modules/news/ is modified</description> <modified-resources> <regex>sites/mysite/modules/news/.*</regex> </modified-resources> <export-resources> <uri>/sites/mysite/index.html</uri> <uri>/sites/mysite/news.html</uri> </export-resources> </export-rule>
The default behaviour is still the same as before, if a published resource
does not match any rule, all vfs resources that match the <resourcetorender> node regular
expressions, will be exported. Keep also in mind that if you specify an
<export-resources> uri that
does not match the <resourcetorender> node regular
expressions, it will not be exported. So keep your <resourcetorender> node
regularexpressions synchronized with your <export-resources> uris.
Please also note that if a resource is exported having a link to another
resource, the last one will only be exported if it is also part of the <export-resources> set.
Now it depends only on you, on your rules and your sites, how fast the
after publish export can be.
|