diff --git a/source/includes/freemarker-variables.rst b/source/includes/freemarker-variables.rst index 3ab707f63..e63dac194 100644 --- a/source/includes/freemarker-variables.rst +++ b/source/includes/freemarker-variables.rst @@ -1,86 +1,88 @@ -+---------------------------+---------------------------------------+------------------------------------+ -|| Name || Description || Type | -+===========================+=======================================+====================================+ -|| siteItemService || Allows access to the site || |SiteItemService| | -|| || content. || | -+---------------------------+---------------------------------------+------------------------------------+ -|| urlTransformationService || Service for transforming URLs, || |UrlTransformationService| | -|| || like transforming the content || | -|| || URL of a page to the web or || | -|| || render URL. || | -+---------------------------+---------------------------------------+------------------------------------+ -|| applicationContext || Provides access to the Crafter || |ApplicationContextAccessor| | -|| || Engine's Spring beans and site || | -|| || beans defined in || | -|| || config/spring/application- || | -|| || context.xml. || | -+---------------------------+---------------------------------------+------------------------------------+ -|| globalProperties || Provides access to global || `PropertySourcesPropertyResolver`_| -|| || configuration properties || | -|| || defined in || | -|| || server-config.properties. || | -+---------------------------+---------------------------------------+------------------------------------+ -|| navBreadcrumbBuilder || Helper class that returns the || |BreadcrumbBuilder| | -|| || list of path components in an || | -|| || URL, to create navigation || | -|| || breadcrumbs. || | -+---------------------------+---------------------------------------+------------------------------------+ -|| navTreeBuilder || Helper class that creates || |NavTreeBuilder| | -|| || navigation trees to || | -|| || facilitate rendering. || | -+---------------------------+---------------------------------------+------------------------------------+ -|| tenantsResolver || Can be used to retrieve the || |TenantsResolver| | -|| || Profile tenants associated to || | -|| || the current site. || | -+---------------------------+---------------------------------------+------------------------------------+ -|| modePreview || Flag that indicates that Engine is || Boolean | -|| || being executed in preview mode || | -|| || (also the value of the || | -|| || ``crafter.engine.preview`` property) || | -+---------------------------+---------------------------------------+------------------------------------+ -|| crafterEnv || Indicates the value of the || String | -|| || ``crafter.engine.environment`` || | -|| || property || | -+---------------------------+---------------------------------------+------------------------------------+ -|| siteConfig || The current site Configuration || |XMLConfiguration| | -|| || loaded from /config/site.xml. || | -+---------------------------+---------------------------------------+------------------------------------+ -|| siteContext || The current SiteContext || |SiteContextHashModel| | -+---------------------------+---------------------------------------+------------------------------------+ -|| request || The current request || |HttpRequestHashModel| | -+---------------------------+---------------------------------------+------------------------------------+ -|| requestParameters || The parameter values for the || `HttpRequestParametersHashModel`_ | -|| || current request || | -+---------------------------+---------------------------------------+------------------------------------+ -|| cookies || The cookie values for the || |Map| | -|| || current request || | -+---------------------------+---------------------------------------+------------------------------------+ -|| session || The current session || `HttpSessionHashModel`_ | -+---------------------------+---------------------------------------+------------------------------------+ -|| locale || The current locale for the || |Locale| | -|| || current user || | -+---------------------------+---------------------------------------+------------------------------------+ -|| authToken || The current authentication (if || |SpringAuthentication| | -|| || the user has logged in), || | -|| || created by Spring Security || | -+---------------------------+---------------------------------------+------------------------------------+ +.. list-table:: + :align: left + :header-rows: 1 + :widths: 25 45 30 + + * - Name + - Description + - Type + * - siteItemService + - Allows access to the site content. + - |SiteItemService| + * - urlTransformationService + - Service for transforming URLs, like transforming the content URL of a page to the web or render URL. + - |UrlTransformationService| + * - applicationContext + - Provides access to the Crafter Engine's Spring beans and site beans defined in config/spring/application-context.xml. + - |ApplicationContextAccessor| + * - globalProperties + - Provides access to global configuration properties defined in server-config.properties. + - `PropertySourcesPropertyResolver`_ + * - navBreadcrumbBuilder + - Helper class that returns the list of path components in an URL, to create navigation breadcrumbs. + - |BreadcrumbBuilder| + * - navTreeBuilder + - Helper class that creates navigation trees to facilitate rendering. + - |NavTreeBuilder| + * - tenantsResolver + - Can be used to retrieve the Profile tenants associated to the current site. + - |TenantsResolver| + * - modePreview + - Can be used to check whether Engine is being executed in preview mode (also the value of the ``crafter.engine.preview`` property) e.g. + + .. code-block:: html + :force: + + <#if modePreview> + + + + - Boolean + * - crafterEnv + - Indicates the value of the ``crafter.engine.environment`` property + - String + * - siteConfig + - The current site Configuration loaded from /config/site.xml. + - |XMLConfiguration| + * - siteContext + - The current SiteContext + - |SiteContextHashModel| + * - request + - The current request + - |HttpRequestHashModel| + * - requestParameters + - The parameter values for the current request + - `HttpRequestParametersHashModel`_ + * - cookies + - The cookie values for the current request + - |Map| + * - session + - The current session + - `HttpSessionHashModel`_ + * - locale + - The current locale for the current user + - |Locale| + * - authToken + - The current authentication (if the user has logged in), created by Spring Security + - |SpringAuthentication| The following variables are provided for backward compatibility when using Crafter Profile, should be replaced with ``authToken`` if possible: -+---------------------------+---------------------------------------+------------------------------------+ -|| Name || Description || Type | -+===========================+=======================================+====================================+ -|| authentication || The current authentication (if || |Authentication| | -|| || the user has logged in), || | -|| || created by the || | -|| || Crafter Security Provider || | -+---------------------------+---------------------------------------+------------------------------------+ -|| profile || The current profile (if the || |Profile| | -|| || user has logged in), created || | -|| || by the || | -|| || Crafter Security Provider || | -+---------------------------+---------------------------------------+------------------------------------+ +.. list-table:: + :align: left + :header-rows: 1 + :widths: 25 45 30 + + * - Name + - Description + - Type + * - authentication + - The current authentication (if the user has logged in), created by the Crafter Security Provider + - |Authentication| + * - profile + - The current profile (if the user has logged in), created by the Crafter Security Provider + - |Profile| .. note:: The variables ``profile`` and ``authentication`` listed above will be null in most cases and should not be used anymore @@ -88,13 +90,20 @@ with ``authToken`` if possible: The following variables are restricted by default, to use them see :ref:`configure-custom-services` -+---------------------------+---------------------------------------+------------------------------------+ -|| Name || Description || Type | -+===========================+=======================================+====================================+ -|| application || The servlet context || |ServletContextHashModel| | -+---------------------------+---------------------------------------+------------------------------------+ -|| siteContext || The current SiteContext || |SiteContext| | -+---------------------------+---------------------------------------+------------------------------------+ +.. list-table:: + :align: left + :header-rows: 1 + :widths: 25 45 30 + + * - Name + - Description + - Type + * - application + - The servlet context + - |ServletContextHashModel| + * - siteContext + - The current SiteContext + - |SiteContext| .. |SiteItemService| replace:: :javadoc_base_url:`SiteItemService ` .. |UrlTransformationService| replace:: :javadoc_base_url:`UrlTransformationService ` @@ -118,4 +127,4 @@ The following variables are restricted by default, to use them see :ref:`configu .. |Locale| replace:: See ``Locale`` under the ``java.util`` package of the ``java.base`` module in the `Java documentation `__ .. |Authentication| replace:: :javadoc_base_url:`Authentication ` .. |Profile| replace:: :javadoc_base_url:`Profile ` -.. |SpringAuthentication| replace:: See ``Authentication`` under ``org.springframework.security.core`` in the `Spring Security `__ apidocs \ No newline at end of file +.. |SpringAuthentication| replace:: See ``Authentication`` under ``org.springframework.security.core`` in the `Spring Security `__ apidocs diff --git a/source/includes/global-groovy-variables.rst b/source/includes/global-groovy-variables.rst index 3c4c7da2b..79e0a3aa2 100644 --- a/source/includes/global-groovy-variables.rst +++ b/source/includes/global-groovy-variables.rst @@ -1,67 +1,65 @@ -+------------------------+---------------------------------------+--------------------------------+ -| Name | Description | Type | -+========================+=======================================+================================+ -|| siteItemService || Allows access to the site content. || |SiteItemService| | -+------------------------+---------------------------------------+--------------------------------+ -|| |UrlTransform| || Service for transforming URLs, like || |UrlTransformationService| | -|| || transforming the content URL of a || | -|| || page to the web or render URL. || | -+------------------------+---------------------------------------+--------------------------------+ -|| search || Service that can be used to execute || |OpenSearchWrapper| | -|| || search queries against || | -|| || OpenSearch. || | -+------------------------+---------------------------------------+--------------------------------+ -|| applicationContext || Provides access to the Crafter || |ApplicationContextAccessor| | -|| || Engine's Spring beans and site beans || | -|| || defined in || | -|| || config/spring/application-context.xml|| | -+------------------------+---------------------------------------+--------------------------------+ -|| globalProperties || Provides access to global || |PropertySources|_ | -|| || configuration properties defined in || | -|| || server-config.properties. || | -+------------------------+---------------------------------------+--------------------------------+ -|| navBreadcrumbBuilder || Helper class that returns the list of|| |BreadcrumbBuilder| | -|| || path components in an URL, to create || | -|| || navigation breadcrumbs. || | -+------------------------+---------------------------------------+--------------------------------+ -|| navTreeBuilder || Helper class that creates navigation || |NavTreeBuilder| | -|| || trees to facilitate rendering || | -+------------------------+---------------------------------------+--------------------------------+ -|| tenantsResolver || Can be used to retrieve the || |TenantsResolver| | -|| || Profile tenants associated to the || | -|| || current site. || | -+------------------------+---------------------------------------+--------------------------------+ -|| profileService || Provides access to the Crafter || |ProfileService| | -|| || Profile API for profiles. || | -+------------------------+---------------------------------------+--------------------------------+ -|| tenantService || Provides access to the Crafter || |TenantService| | -|| || Profile API for tenants. || | -+------------------------+---------------------------------------+--------------------------------+ -|| authenticationService || Provides access to the Crafter || |AuthenticationService| | -|| || Profile API for authentication. || | -+------------------------+---------------------------------------+--------------------------------+ -|| authenticationManager || Manages Crafter Security Provider || |AuthenticationManager| | -|| || based authentications. || | -+------------------------+---------------------------------------+--------------------------------+ -|| textEncryptor || Utility class for encrypting/ || |TextEncryptor| | -|| || decrypting text with AES. || | -+------------------------+---------------------------------------+--------------------------------+ -|| modePreview || Flag that indicates that Engine is || Boolean | -|| || being executed in preview mode || | -|| || (also the value of the || | -|| || ``crafter.engine.preview`` property) || | -+------------------------+---------------------------------------+--------------------------------+ -|| crafterEnv || Indicates the value of the || String | -|| || ``crafter.engine.environment`` || | -|| || property || | -+------------------------+---------------------------------------+--------------------------------+ -|| logger || The GroovyUtils SLF4J logger || `Logger`_ | -+------------------------+---------------------------------------+--------------------------------+ -|| siteConfig || The current site Configuration, || |XMLConfiguration| | -|| || loaded from /config/site.xml. || | -+------------------------+---------------------------------------+--------------------------------+ -|| siteContext || The current SiteContext || |SiteContext| | -+------------------------+---------------------------------------+--------------------------------+ +.. list-table:: + :align: left + :header-rows: 1 + :widths: 25 45 30 + + * - Name + - Description + - Type + * - siteItemService + - Allows access to the site content. + - |SiteItemService| + * - |UrlTransform| + - Service for transforming URLs, like transforming the content URL of a page to the web or render URL. + - |UrlTransformationService| + * - search + - Service that can be used to execute search queries against OpenSearch. + - |OpenSearchWrapper| + * - applicationContext + - Provides access to the Crafter Engine's Spring beans and site beans defined in config/spring/application-context.xml + - |ApplicationContextAccessor| + * - globalProperties + - Provides access to global configuration properties defined in server-config.properties. + - |PropertySources|_ + * - navBreadcrumbBuilder + - Helper class that returns the list of path components in an URL, to create navigation breadcrumbs. + - |BreadcrumbBuilder| + * - navTreeBuilder + - Helper class that creates navigation trees to facilitate rendering + - |NavTreeBuilder| + * - tenantsResolver + - Can be used to retrieve the Profile tenants associated to the current site. + - |TenantsResolver| + * - profileService + - Provides access to the Crafter Profile API for profiles. + - |ProfileService| + * - tenantService + - Provides access to the Crafter Profile API for tenants. + - |TenantService| + * - authenticationService + - Provides access to the Crafter Profile API for authentication. + - |AuthenticationService| + * - authenticationManager + - Manages Crafter Security Provider based authentications. + - |AuthenticationManager| + * - textEncryptor + - Utility class for encrypting/decrypting text with AES. + - |TextEncryptor| + * - modePreview + - Can be used to check whether Engine is being executed in preview mode (also the value of the ``crafter.engine.preview`` property) + - Boolean + * - crafterEnv + - Indicates the value of the ``crafter.engine.environment`` property + - String + * - logger + - The GroovyUtils SLF4J logger + - `Logger`_ + * - siteConfig + - The current site Configuration, loaded from /config/site.xml. + - |XMLConfiguration| + * - siteContext + - The current SiteContext + - |SiteContext| .. |SiteItemService| replace:: :javadoc_base_url:`SiteItemService ` .. |UrlTransform| replace:: urlTransformationService diff --git a/source/reference/api/groovy-java-api.rst b/source/reference/api/groovy-java-api.rst index 2b71943b9..07f0a3f56 100644 --- a/source/reference/api/groovy-java-api.rst +++ b/source/reference/api/groovy-java-api.rst @@ -143,6 +143,17 @@ You can find the interface for this service at :javadoc_base_url:`Site Item Serv return result +~~~~~~~~~~~~~~~~~~ +Check Preview Mode +~~~~~~~~~~~~~~~~~~ +The following code example checks if Engine is running in preview mode: + +.. code-block:: groovy + + if (modePreview) { + // Preview-only logic + } + ^^^^^^^^^^^^^^^ Other Variables ^^^^^^^^^^^^^^^ diff --git a/source/reference/modules/engine.rst b/source/reference/modules/engine.rst index 10e065b4b..f7294a207 100644 --- a/source/reference/modules/engine.rst +++ b/source/reference/modules/engine.rst @@ -4075,6 +4075,27 @@ Enabling the security filter in Preview Mode requires the configuration encrypti between Studio and Engine) and admins will need to update the default configurations for the encryption key and salt in :ref:`Studio ` and in :ref:`Engine `. +.. note:: + To check if Engine is running in preview mode, use the ``modePreview`` variable available in + Groovy scripts and FreeMarker templates. + + **FreeMarker** + + .. code-block:: html + :force: + + <#if modePreview> + + + + **Groovy** + + .. code-block:: groovy + + if (modePreview) { + // Preview-only logic + } + .. _engine-preview-cookie: """""""""""""""