<commit_before><#--
* 
* HTML document markup and script HTML template include, standard Cato markup
*
* Included by htmlTemplate.ftl.
*
* NOTES: 
* * May have implicit dependencies on other parts of Cato API.
*
* DEV NOTES: 
* * This currently contains some theme- and platform-specific utilites... could have own file, but
*   this is somewhat generic.
-->

<#--
*************
* HTML Head Open
************
Opens an HTML document and header section.

IMPL NOTE: Beware of whitespace.

  * Usage Examples *  
    <@htmlHeadOpen />            
                    
  * Parameters *
    includeDocType      = ((boolean), default: false) Whether to include doctype or not
                          Default is false because is already included by screen renderer in @renderScreenBegin.
-->
<#assign htmlHeadOpen_defaultArgs = {
  "includeDocType":false, "passArgs":{}
}>
<#macro htmlHeadOpen args={} inlineArgs...>
  <#local args = mergeArgMaps(args, inlineArgs, catoStdTmplLib.htmlHeadOpen_defaultArgs)>
  <#local dummy = localsPutAll(args)>
  <#local origArgs = args>
  <#if includeDocType><!DOCTYPE html></#if><#lt>
  <#if locale??>
    <#local docLangAttr = locale.toString()?replace("_", "-")>
  </#if>
  <#local langDir = "ltr">
  <#if docLangAttr?? && "ar.iw"?contains(docLangAttr?substring(0, 2))>
    <#local langDir = "rtl">
  </#if>
  <#if !docLangAttr?has_content>
    <#local docLangAttr = "en">
  </#if>
  <@htmlHeadOpen_markup includeDocType=includeDocType docLangAttr=docLangAttr langDir=langDir origArgs=origArgs passArgs=passArgs/><#t>
</#macro>

<#-- @htmlHeadOpen main markup - theme override -->
<#macro htmlHeadOpen_markup includeDocType=false docLangAttr="" langDir="" origArgs={} passArgs={} catchArgs...>
<!--[if IE 9]><html class="lt-ie10"<#if docLangAttr?has_content> lang="${docLangAttr}"</#if><#if langDir?has_content> dir="${langDir}"</#if>><![endif]-->
<html class="no-js"<#if docLangAttr?has_content> lang="${docLangAttr}"</#if><#if langDir?has_content> dir="${langDir}"</#if>>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</#macro>

<#-- 
*************
* Scripts
************
Optional scripts include modifier. Modifies the @script calls within it.

NOTE: This is NOT associated with any HTML element nor does it define any.

  * Usage Examples *  
    <@scripts output=true> <#- guarantees the @script calls will output content to page at this location ->
      <@script>
        jQuery(document).ready(function() {
            alert("Page loaded.");
        });
      </@script>
      <@script>
        jQuery(document).ready(function() {
            alert("Test.");
        });
      </@script>      
    </@scripts>         
                    
  * Parameters *
    scriptType,
    output,
    data,
    htmlwrap                = Default arguments for child script calls; see @script
-->
<#assign scripts_defaultArgs = {
  "scriptType" : "text/javascript", "output" : "", "htmlwrap" : true, "cdata" : true, "passArgs":{}
}>
<#macro scripts args={} inlineArgs...>
  <#local args = mergeArgMaps(args, inlineArgs, catoStdTmplLib.scripts_defaultArgs)>
  <#local dummy = localsPutAll(args)>
  <#local dummy = setRequestVar("catoScriptsInfo", args)>
  <#nested>
  <#local dummy = setRequestVar("catoScriptsInfo", {})>
</#macro>

<#-- 
*************
* Script
************
Inline script wrapper. By default, makes a javascript block.

NOTE: Unlike others, this macro explicitly currently cannot support open/close structure (only htmlwrap).

DEV NOTE: In future, could be used to collect scripts for inclusion at end of page.

  * Usage Examples *  
    <@script>
        jQuery(document).ready(function() {
            alert("Page loaded.");
        });
    </@script>         
                    
  * Parameters *
    type                    = (default: "text/javascript") Script type identifier
    src                     = Source document address (when no nested content)
    language                = DEPRECATED by HTML - ignored by macro
    output                  = ((boolean)) If true, the script must be output in the markup where the macro is used and should never be delegated
                              In cases of scripts within common templates,
                              this should be omitted, except when used in html <head> or in a footer.
                              If not specified or "", cato decides what to do with them (output or accumulate at bottom of page).
                              TODO: code to accumulate at footer.
    htmlwrap                = ((boolean), default: true) If false don't include HTML wrapper (or cdata)
    cdata                   = ((boolean), default: true) If false don't include CDATA guard (only used if htmlwrap true)
-->
<#assign script_defaultArgs = {
  "type" : "text/javascript", "src" : "", "output" : "", "htmlwrap" : true, "cdata" : true, "passArgs":{}
}>
<#macro script args={} inlineArgs...>
  <#local scriptsInfo = getRequestVar("catoScriptsInfo")!{}>
  <#-- this uses complex defaults from parent @scripts elem, so have to do something different -->
  <#local defaultArgs = {
    "type" : scriptsInfo.scriptType!script_defaultArgs.type,
    "src" : "",
    "output" : scriptsInfo.output!script_defaultArgs.output,
    "htmlwrap" : scriptsInfo.htmlwrap!script_defaultArgs.htmlwrap,
    "cdata" : scriptsInfo.cdata!script_defaultArgs.cdata
  }>
  <#local args = mergeArgMaps(args, inlineArgs, defaultArgs)>
  <#local dummy = localsPutAll(args)>
  <#local origArgs = args>
  <@script_markup type=type src=src output=output htmlwrap=htmlwrap cdata=cdata origArgs=origArgs passArgs=passArgs><#nested></@script_markup>
</#macro>

<#-- @script main markup - theme override -->
<#macro script_markup type="" src="" output="" htmlwrap=true cdata=true origArgs={} passArgs={} catchArgs...>
  <#if src?has_content>
    <script type="${type}" src="${src}"></script>
  <#else>
    <#if htmlwrap>
      <script type="${type}">
      <#if cdata>//<![CDATA[</#if>
    </#if>
        <#nested>
    <#if htmlwrap>
      <#if cdata>//]]></#if>
      </script>
    </#if>
  </#if>
</#macro>

<#-- 
*************
* requireScriptOfbizUrl
************
Informs the rendering process (decorator) that the given ofbiz URI must be made available to javascript
code.

Normally the getOfbizUrl(url) Javascript function will be used to do this.

The screen/ftl has to communicate to the decorator which URIs it needs to use, so
this is one such mechanism 
DEV NOTE: Other options: layoutSettings? any way is messy...
                    
Ideally this shouldn't needed and getOfbizUrl should just work, but URLs are generated
dynamic using controller request defs and can't predict URL patterns unless rewrite
@ofbizUrl in JS.  
         
  * Parameters *
    url                     = Controller request uri
    output                  = ((boolean)) If true, forces the macro to write the markup/content immediately
                              Prevents delegating this script include. In most template usage this should be omitted.  
                              DEV NOTE: If not specified, "" or false for now simply accumulates the names  
                                  and will be included by decorator in footer.
    htmlwrap                = ((boolean), default: false) Whether to wrap in @script
                              NOTE: Default is FALSE for this macro (unlike others).
-->
<#macro requireScriptOfbizUrl uri htmlwrap=false output="">
  <#local requiredScriptOfbizUrls = getRequestVar("requiredScriptOfbizUrls")!false>
  <#if requiredScriptOfbizUrls?is_boolean || !requiredScriptOfbizUrls.contains(uri)>
    <#if output?is_boolean && output == true>
      <@script htmlwrap=htmlwrap output=output>
        <#if requiredScriptOfbizUrls?is_boolean>
          if (typeof variable === 'undefined') {
              var commonOfbizUrls = {};
          }
        </#if>
        commonOfbizUrls["${uri}"] = "<@ofbizUrl>${uri}</@ofbizUrl>";
      </@script>
    <#else>
      <#if requiredScriptOfbizUrls?is_boolean>
        <#local requiredScriptOfbizUrls = toSet([uri])>
      <#else>
        <#local dummy = requiredScriptOfbizUrls.add(uri)!>
      </#if>
      <#local dummy = setRequestVar("requiredScriptOfbizUrls", requiredScriptOfbizUrls)>
    </#if>
  </#if>
</#macro>

<#macro includeRecordedScriptOfbizUrls htmlwrap=false>
  <#local requiredScriptOfbizUrls = getRequestVar("requiredScriptOfbizUrls")!false>
  <#if !requiredScriptOfbizUrls?is_boolean || (!requiredScriptOfbizUrls.isEmpty())>
    <@script output=true htmlwrap=htmlwrap>

      if (typeof variable === 'undefined') {
          var commonOfbizUrls = {};
      }
  
      <#list requiredScriptOfbizUrls as uri>
      commonOfbizUrls["${uri}"] = "<@ofbizUrl>${uri}</@ofbizUrl>";
      </#list>
    </@script>
  </#if><commit_msg>NoRef macros: security fix: add escapePart/FullUrl<commit_after><#--
* 
* HTML document markup and script HTML template include, standard Cato markup
*
* Included by htmlTemplate.ftl.
*
* NOTES: 
* * May have implicit dependencies on other parts of Cato API.
*
* DEV NOTES: 
* * This currently contains some theme- and platform-specific utilites... could have own file, but
*   this is somewhat generic.
-->

<#--
*************
* HTML Head Open
************
Opens an HTML document and header section.

IMPL NOTE: Beware of whitespace.

  * Usage Examples *  
    <@htmlHeadOpen />            
                    
  * Parameters *
    includeDocType      = ((boolean), default: false) Whether to include doctype or not
                          Default is false because is already included by screen renderer in @renderScreenBegin.
-->
<#assign htmlHeadOpen_defaultArgs = {
  "includeDocType":false, "passArgs":{}
}>
<#macro htmlHeadOpen args={} inlineArgs...>
  <#local args = mergeArgMaps(args, inlineArgs, catoStdTmplLib.htmlHeadOpen_defaultArgs)>
  <#local dummy = localsPutAll(args)>
  <#local origArgs = args>
  <#if includeDocType><!DOCTYPE html></#if><#lt>
  <#if locale??>
    <#local docLangAttr = locale.toString()?replace("_", "-")>
  </#if>
  <#local langDir = "ltr">
  <#if docLangAttr?? && "ar.iw"?contains(docLangAttr?substring(0, 2))>
    <#local langDir = "rtl">
  </#if>
  <#if !docLangAttr?has_content>
    <#local docLangAttr = "en">
  </#if>
  <@htmlHeadOpen_markup includeDocType=includeDocType docLangAttr=docLangAttr langDir=langDir origArgs=origArgs passArgs=passArgs/><#t>
</#macro>

<#-- @htmlHeadOpen main markup - theme override -->
<#macro htmlHeadOpen_markup includeDocType=false docLangAttr="" langDir="" origArgs={} passArgs={} catchArgs...>
<!--[if IE 9]><html class="lt-ie10"<#if docLangAttr?has_content> lang="${docLangAttr}"</#if><#if langDir?has_content> dir="${langDir}"</#if>><![endif]-->
<html class="no-js"<#if docLangAttr?has_content> lang="${docLangAttr}"</#if><#if langDir?has_content> dir="${langDir}"</#if>>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</#macro>

<#-- 
*************
* Scripts
************
Optional scripts include modifier. Modifies the @script calls within it.

NOTE: This is NOT associated with any HTML element nor does it define any.

  * Usage Examples *  
    <@scripts output=true> <#- guarantees the @script calls will output content to page at this location ->
      <@script>
        jQuery(document).ready(function() {
            alert("Page loaded.");
        });
      </@script>
      <@script>
        jQuery(document).ready(function() {
            alert("Test.");
        });
      </@script>      
    </@scripts>         
                    
  * Parameters *
    scriptType,
    output,
    data,
    htmlwrap                = Default arguments for child script calls; see @script
-->
<#assign scripts_defaultArgs = {
  "scriptType" : "text/javascript", "output" : "", "htmlwrap" : true, "cdata" : true, "passArgs":{}
}>
<#macro scripts args={} inlineArgs...>
  <#local args = mergeArgMaps(args, inlineArgs, catoStdTmplLib.scripts_defaultArgs)>
  <#local dummy = localsPutAll(args)>
  <#local dummy = setRequestVar("catoScriptsInfo", args)>
  <#nested>
  <#local dummy = setRequestVar("catoScriptsInfo", {})>
</#macro>

<#-- 
*************
* Script
************
Inline script wrapper. By default, makes a javascript block.

NOTE: Unlike others, this macro explicitly currently cannot support open/close structure (only htmlwrap).

DEV NOTE: In future, could be used to collect scripts for inclusion at end of page.

  * Usage Examples *  
    <@script>
        jQuery(document).ready(function() {
            alert("Page loaded.");
        });
    </@script>         
                    
  * Parameters *
    type                    = (default: "text/javascript") Script type identifier
    src                     = Source document address (when no nested content)
    language                = DEPRECATED by HTML - ignored by macro
    output                  = ((boolean)) If true, the script must be output in the markup where the macro is used and should never be delegated
                              In cases of scripts within common templates,
                              this should be omitted, except when used in html <head> or in a footer.
                              If not specified or "", cato decides what to do with them (output or accumulate at bottom of page).
                              TODO: code to accumulate at footer.
    htmlwrap                = ((boolean), default: true) If false don't include HTML wrapper (or cdata)
    cdata                   = ((boolean), default: true) If false don't include CDATA guard (only used if htmlwrap true)
-->
<#assign script_defaultArgs = {
  "type" : "text/javascript", "src" : "", "output" : "", "htmlwrap" : true, "cdata" : true, "passArgs":{}
}>
<#macro script args={} inlineArgs...>
  <#local scriptsInfo = getRequestVar("catoScriptsInfo")!{}>
  <#-- this uses complex defaults from parent @scripts elem, so have to do something different -->
  <#local defaultArgs = {
    "type" : scriptsInfo.scriptType!script_defaultArgs.type,
    "src" : "",
    "output" : scriptsInfo.output!script_defaultArgs.output,
    "htmlwrap" : scriptsInfo.htmlwrap!script_defaultArgs.htmlwrap,
    "cdata" : scriptsInfo.cdata!script_defaultArgs.cdata
  }>
  <#local args = mergeArgMaps(args, inlineArgs, defaultArgs)>
  <#local dummy = localsPutAll(args)>
  <#local origArgs = args>
  <@script_markup type=type src=src output=output htmlwrap=htmlwrap cdata=cdata origArgs=origArgs passArgs=passArgs><#nested></@script_markup>
</#macro>

<#-- @script main markup - theme override -->
<#macro script_markup type="" src="" output="" htmlwrap=true cdata=true origArgs={} passArgs={} catchArgs...>
  <#if src?has_content>
    <script type="${type}" src="${src}"></script>
  <#else>
    <#if htmlwrap>
      <script type="${type}">
      <#if cdata>//<![CDATA[</#if>
    </#if>
        <#nested>
    <#if htmlwrap>
      <#if cdata>//]]></#if>
      </script>
    </#if>
  </#if>
</#macro>

<#-- 
*************
* requireScriptOfbizUrl
************
Informs the rendering process (decorator) that the given ofbiz URI must be made available to javascript
code.

Normally the getOfbizUrl(url) Javascript function will be used to do this.

The screen/ftl has to communicate to the decorator which URIs it needs to use, so
this is one such mechanism 
DEV NOTE: Other options: layoutSettings? any way is messy...
                    
Ideally this shouldn't needed and getOfbizUrl should just work, but URLs are generated
dynamic using controller request defs and can't predict URL patterns unless rewrite
@ofbizUrl in JS.  
         
  * Parameters *
    url                     = Controller request uri
    output                  = ((boolean)) If true, forces the macro to write the markup/content immediately
                              Prevents delegating this script include. In most template usage this should be omitted.  
                              DEV NOTE: If not specified, "" or false for now simply accumulates the names  
                                  and will be included by decorator in footer.
    htmlwrap                = ((boolean), default: false) Whether to wrap in @script
                              NOTE: Default is FALSE for this macro (unlike others).
-->
<#macro requireScriptOfbizUrl uri htmlwrap=false output="">
  <#local requiredScriptOfbizUrls = getRequestVar("requiredScriptOfbizUrls")!false>
  <#if requiredScriptOfbizUrls?is_boolean || !requiredScriptOfbizUrls.contains(uri)>
    <#if output?is_boolean && output == true>
      <@script htmlwrap=htmlwrap output=output>
        <#if requiredScriptOfbizUrls?is_boolean>
          if (typeof variable === 'undefined') {
              var commonOfbizUrls = {};
          }
        </#if>
        commonOfbizUrls["${uri}"] = "<@ofbizUrl>${uri}</@ofbizUrl>";
      </@script>
    <#else>
      <#if requiredScriptOfbizUrls?is_boolean>
        <#local requiredScriptOfbizUrls = toSet([uri])>
      <#else>
        <#local dummy = requiredScriptOfbizUrls.add(uri)!>
      </#if>
      <#local dummy = setRequestVar("requiredScriptOfbizUrls", requiredScriptOfbizUrls)>
    </#if>
  </#if>
</#macro>

<#macro includeRecordedScriptOfbizUrls htmlwrap=false>
  <#local requiredScriptOfbizUrls = getRequestVar("requiredScriptOfbizUrls")!false>
  <#if !requiredScriptOfbizUrls?is_boolean || (!requiredScriptOfbizUrls.isEmpty())>
    <@script output=true htmlwrap=htmlwrap>

      if (typeof variable === 'undefined') {
          var commonOfbizUrls = {};
      }
  
      <#list requiredScriptOfbizUrls as uri>
      commonOfbizUrls["${escapeFullUrl(uri, 'js')}"] = "${escapeFullUrl(makeOfbizUrl(uri), 'js')}";
      </#list>
    </@script>
  </#if>
{'fraction_non_alphanumeric': 0.14050788678823134, 'fraction_numerical': 0.000894954692918671, 'mean_word_length': 3.005152329749104, 'pattern_counts': {'":': 8, '<': 253, '<?xml version=': 0, '>': 253, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3751318', 'n_tokens_mistral': 5419, 'n_tokens_neox': 5206, 'n_words': 1532}