Improve a little bit the readability of the rendered template
This commit is contained in:
parent
7eb13db467
commit
f19e622d39
@ -1,15 +1,11 @@
|
|||||||
<script>const _=
|
<script>const _=
|
||||||
<#assign pageId="PAGE_ID_xIgLsPgGId9D8e">
|
|
||||||
(()=>{
|
(()=>{
|
||||||
|
<#assign pageId="PAGE_ID_xIgLsPgGId9D8e">
|
||||||
const out = ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
|
const out = ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
|
||||||
|
|
||||||
out["msg"]= function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); };
|
out["msg"]= function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); };
|
||||||
out["advancedMsg"]= function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); };
|
out["advancedMsg"]= function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); };
|
||||||
|
|
||||||
out["messagesPerField"]= {
|
out["messagesPerField"]= {
|
||||||
<#assign fieldNames = [ FIELD_NAMES_eKsIY4ZsZ4xeM ]>
|
<#assign fieldNames = [ FIELD_NAMES_eKsIY4ZsZ4xeM ]>
|
||||||
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
<#if profile?? && profile.attributes?? && profile.attributes?is_enumerable>
|
<#if profile?? && profile.attributes?? && profile.attributes?is_enumerable>
|
||||||
<#list profile.attributes as attribute>
|
<#list profile.attributes as attribute>
|
||||||
@ -21,231 +17,157 @@
|
|||||||
</#if>
|
</#if>
|
||||||
<#recover>
|
<#recover>
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
"printIfExists": function (fieldName, text) {
|
"printIfExists": function (fieldName, text) {
|
||||||
|
|
||||||
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
||||||
throw new Error("You're not supposed to use messagesPerField.printIfExists in this page");
|
throw new Error("You're not supposed to use messagesPerField.printIfExists in this page");
|
||||||
<#else>
|
<#else>
|
||||||
<#list fieldNames as fieldName>
|
<#list fieldNames as fieldName>
|
||||||
if(fieldName === "${fieldName}" ){
|
if(fieldName === "${fieldName}" ){
|
||||||
|
|
||||||
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
||||||
<#if ('${fieldName}' == 'username' || '${fieldName}' == 'password') && pageId != 'register.ftl' && pageId != 'register-user-profile.ftl'>
|
<#if ('${fieldName}' == 'username' || '${fieldName}' == 'password') && pageId != 'register.ftl' && pageId != 'register-user-profile.ftl'>
|
||||||
|
|
||||||
<#assign doExistErrorOnUsernameOrPassword = "">
|
<#assign doExistErrorOnUsernameOrPassword = "">
|
||||||
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
<#assign doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
<#assign doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
||||||
<#recover>
|
<#recover>
|
||||||
<#assign doExistErrorOnUsernameOrPassword = true>
|
<#assign doExistErrorOnUsernameOrPassword = true>
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
<#if doExistErrorOnUsernameOrPassword>
|
<#if doExistErrorOnUsernameOrPassword>
|
||||||
return text;
|
return text;
|
||||||
<#else>
|
<#else>
|
||||||
|
|
||||||
<#assign doExistMessageForField = "">
|
<#assign doExistMessageForField = "">
|
||||||
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
<#assign doExistMessageForField = messagesPerField.exists('${fieldName}')>
|
<#assign doExistMessageForField = messagesPerField.exists('${fieldName}')>
|
||||||
<#recover>
|
<#recover>
|
||||||
<#assign doExistMessageForField = true>
|
<#assign doExistMessageForField = true>
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
return <#if doExistMessageForField>text<#else>undefined</#if>;
|
return <#if doExistMessageForField>text<#else>undefined</#if>;
|
||||||
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#else>
|
<#else>
|
||||||
|
|
||||||
<#assign doExistMessageForField = "">
|
<#assign doExistMessageForField = "">
|
||||||
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
<#assign doExistMessageForField = messagesPerField.exists('${fieldName}')>
|
<#assign doExistMessageForField = messagesPerField.exists('${fieldName}')>
|
||||||
<#recover>
|
<#recover>
|
||||||
<#assign doExistMessageForField = true>
|
<#assign doExistMessageForField = true>
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
return <#if doExistMessageForField>text<#else>undefined</#if>;
|
return <#if doExistMessageForField>text<#else>undefined</#if>;
|
||||||
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</#list>
|
</#list>
|
||||||
|
|
||||||
throw new Error(fieldName + "is probably runtime generated, see: https://docs.keycloakify.dev/limitations#field-names-cant-be-runtime-generated");
|
throw new Error(fieldName + "is probably runtime generated, see: https://docs.keycloakify.dev/limitations#field-names-cant-be-runtime-generated");
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
},
|
},
|
||||||
"existsError": function (){
|
"existsError": function (){
|
||||||
|
|
||||||
function existsError_singleFieldName(fieldName) {
|
function existsError_singleFieldName(fieldName) {
|
||||||
|
|
||||||
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
||||||
throw new Error("You're not supposed to use messagesPerField.printIfExists in this page");
|
throw new Error("You're not supposed to use messagesPerField.printIfExists in this page");
|
||||||
<#else>
|
<#elske>
|
||||||
<#list fieldNames as fieldName>
|
<#list fieldNames as fieldName>
|
||||||
if(fieldName === "${fieldName}" ){
|
if(fieldName === "${fieldName}" ){
|
||||||
|
|
||||||
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
||||||
<#if ('${fieldName}' == 'username' || '${fieldName}' == 'password') && pageId != 'register.ftl' && pageId != 'register-user-profile.ftl'>
|
<#if ('${fieldName}' == 'username' || '${fieldName}' == 'password') && pageId != 'register.ftl' && pageId != 'register-user-profile.ftl'>
|
||||||
|
|
||||||
<#assign doExistErrorOnUsernameOrPassword = "">
|
<#assign doExistErrorOnUsernameOrPassword = "">
|
||||||
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
<#assign doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
<#assign doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
||||||
<#recover>
|
<#recover>
|
||||||
<#assign doExistErrorOnUsernameOrPassword = true>
|
<#assign doExistErrorOnUsernameOrPassword = true>
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
return <#if doExistErrorOnUsernameOrPassword>true<#else>false</#if>;
|
return <#if doExistErrorOnUsernameOrPassword>true<#else>false</#if>;
|
||||||
|
|
||||||
<#else>
|
<#else>
|
||||||
|
|
||||||
<#assign doExistErrorMessageForField = "">
|
<#assign doExistErrorMessageForField = "">
|
||||||
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
<#assign doExistErrorMessageForField = messagesPerField.existsError('${fieldName}')>
|
<#assign doExistErrorMessageForField = messagesPerField.existsError('${fieldName}')>
|
||||||
<#recover>
|
<#recover>
|
||||||
<#assign doExistErrorMessageForField = true>
|
<#assign doExistErrorMessageForField = true>
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
return <#if doExistErrorMessageForField>true<#else>false</#if>;
|
return <#if doExistErrorMessageForField>true<#else>false</#if>;
|
||||||
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
}
|
}
|
||||||
</#list>
|
</#list>
|
||||||
|
|
||||||
throw new Error(fieldName + "is probably runtime generated, see: https://docs.keycloakify.dev/limitations#field-names-cant-be-runtime-generated");
|
throw new Error(fieldName + "is probably runtime generated, see: https://docs.keycloakify.dev/limitations#field-names-cant-be-runtime-generated");
|
||||||
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for( let i = 0; i < arguments.length; i++ ){
|
for( let i = 0; i < arguments.length; i++ ){
|
||||||
|
|
||||||
if( existsError_singleFieldName(arguments[i]) ){
|
if( existsError_singleFieldName(arguments[i]) ){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
},
|
},
|
||||||
"get": function (fieldName) {
|
"get": function (fieldName) {
|
||||||
|
|
||||||
|
|
||||||
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
||||||
throw new Error("You're not supposed to use messagesPerField.get in this page");
|
throw new Error("You're not supposed to use messagesPerField.get in this page");
|
||||||
<#else>
|
<#else>
|
||||||
<#list fieldNames as fieldName>
|
<#list fieldNames as fieldName>
|
||||||
if(fieldName === "${fieldName}" ){
|
if(fieldName === "${fieldName}" ){
|
||||||
|
|
||||||
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
||||||
<#if ('${fieldName}' == 'username' || '${fieldName}' == 'password') && pageId != 'register.ftl' && pageId != 'register-user-profile.ftl'>
|
<#if ('${fieldName}' == 'username' || '${fieldName}' == 'password') && pageId != 'register.ftl' && pageId != 'register-user-profile.ftl'>
|
||||||
|
|
||||||
<#assign doExistErrorOnUsernameOrPassword = "">
|
<#assign doExistErrorOnUsernameOrPassword = "">
|
||||||
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
<#assign doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
<#assign doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
||||||
<#recover>
|
<#recover>
|
||||||
<#assign doExistErrorOnUsernameOrPassword = true>
|
<#assign doExistErrorOnUsernameOrPassword = true>
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
<#if doExistErrorOnUsernameOrPassword>
|
<#if doExistErrorOnUsernameOrPassword>
|
||||||
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
return "${kcSanitize(msg('invalidUserMessage'))?no_esc}";
|
return "${kcSanitize(msg('invalidUserMessage'))?no_esc}";
|
||||||
<#recover>
|
<#recover>
|
||||||
return "Invalid username or password.";
|
return "Invalid username or password.";
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
<#else>
|
<#else>
|
||||||
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
return "${messagesPerField.get('${fieldName}')?no_esc}";
|
return "${messagesPerField.get('${fieldName}')?no_esc}";
|
||||||
<#recover>
|
<#recover>
|
||||||
return "";
|
return "";
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#else>
|
<#else>
|
||||||
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
return "${messagesPerField.get('${fieldName}')?no_esc}";
|
return "${messagesPerField.get('${fieldName}')?no_esc}";
|
||||||
<#recover>
|
<#recover>
|
||||||
return "invalid field";
|
return "invalid field";
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
}
|
}
|
||||||
</#list>
|
</#list>
|
||||||
|
|
||||||
throw new Error(fieldName + "is probably runtime generated, see: https://docs.keycloakify.dev/limitations#field-names-cant-be-runtime-generated");
|
throw new Error(fieldName + "is probably runtime generated, see: https://docs.keycloakify.dev/limitations#field-names-cant-be-runtime-generated");
|
||||||
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
},
|
},
|
||||||
"exists": function (fieldName) {
|
"exists": function (fieldName) {
|
||||||
|
|
||||||
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
||||||
throw new Error("You're not supposed to use messagesPerField.exists in this page");
|
throw new Error("You're not supposed to use messagesPerField.exists in this page");
|
||||||
<#else>
|
<#else>
|
||||||
<#list fieldNames as fieldName>
|
<#list fieldNames as fieldName>
|
||||||
if(fieldName === "${fieldName}" ){
|
if(fieldName === "${fieldName}" ){
|
||||||
|
|
||||||
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
||||||
<#if ('${fieldName}' == 'username' || '${fieldName}' == 'password') && pageId != 'register.ftl' && pageId != 'register-user-profile.ftl'>
|
<#if ('${fieldName}' == 'username' || '${fieldName}' == 'password') && pageId != 'register.ftl' && pageId != 'register-user-profile.ftl'>
|
||||||
|
|
||||||
<#assign doExistErrorOnUsernameOrPassword = "">
|
<#assign doExistErrorOnUsernameOrPassword = "">
|
||||||
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
<#assign doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
<#assign doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
||||||
<#recover>
|
<#recover>
|
||||||
<#assign doExistErrorOnUsernameOrPassword = true>
|
<#assign doExistErrorOnUsernameOrPassword = true>
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
return <#if doExistErrorOnUsernameOrPassword>true<#else>false</#if>;
|
return <#if doExistErrorOnUsernameOrPassword>true<#else>false</#if>;
|
||||||
|
|
||||||
<#else>
|
<#else>
|
||||||
|
|
||||||
<#assign doExistErrorMessageForField = "">
|
<#assign doExistErrorMessageForField = "">
|
||||||
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
<#assign doExistErrorMessageForField = messagesPerField.exists('${fieldName}')>
|
<#assign doExistErrorMessageForField = messagesPerField.exists('${fieldName}')>
|
||||||
<#recover>
|
<#recover>
|
||||||
<#assign doExistErrorMessageForField = true>
|
<#assign doExistErrorMessageForField = true>
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
return <#if doExistErrorMessageForField>true<#else>false</#if>;
|
return <#if doExistErrorMessageForField>true<#else>false</#if>;
|
||||||
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
}
|
}
|
||||||
</#list>
|
</#list>
|
||||||
|
|
||||||
throw new Error(fieldName + "is probably runtime generated, see: https://docs.keycloakify.dev/limitations#field-names-cant-be-runtime-generated");
|
throw new Error(fieldName + "is probably runtime generated, see: https://docs.keycloakify.dev/limitations#field-names-cant-be-runtime-generated");
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
},
|
},
|
||||||
"getFirstError": function () {
|
"getFirstError": function () {
|
||||||
|
|
||||||
for( let i = 0; i < arguments.length; i++ ){
|
for( let i = 0; i < arguments.length; i++ ){
|
||||||
|
|
||||||
const fieldName = arguments[i];
|
const fieldName = arguments[i];
|
||||||
|
|
||||||
if( out.messagesPerField.existsError(fieldName) ){
|
if( out.messagesPerField.existsError(fieldName) ){
|
||||||
return out.messagesPerField.get(fieldName);
|
return out.messagesPerField.get(fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -256,16 +178,12 @@
|
|||||||
out["pageId"] = "${pageId}";
|
out["pageId"] = "${pageId}";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
out["url"]["resourcesCommonPath"] = out["url"]["resourcesPath"] + "/" + "RESOURCES_COMMON_cLsLsMrtDkpVv";
|
out["url"]["resourcesCommonPath"] = out["url"]["resourcesPath"] + "/" + "RESOURCES_COMMON_cLsLsMrtDkpVv";
|
||||||
|
} catch(error) { }
|
||||||
} catch(error) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
|
||||||
})()
|
})();
|
||||||
<#function ftl_object_to_js_code_declaring_an_object object path>
|
<#function ftl_object_to_js_code_declaring_an_object object path>
|
||||||
|
|
||||||
<#local isHash = "">
|
<#local isHash = "">
|
||||||
@ -289,7 +207,6 @@
|
|||||||
<#return "ABORT: We can't list keys on this object">
|
<#return "ABORT: We can't list keys on this object">
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
|
|
||||||
<#local out_seq = []>
|
<#local out_seq = []>
|
||||||
|
|
||||||
<#list keys as key>
|
<#list keys as key>
|
||||||
|
@ -108,7 +108,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
|
|
||||||
const ftlObjectToJsCodeDeclaringAnObjectPlaceholder = '{ "x": "vIdLqMeOed9sdLdIdOxdK0d" }';
|
const ftlObjectToJsCodeDeclaringAnObjectPlaceholder = '{ "x": "vIdLqMeOed9sdLdIdOxdK0d" }';
|
||||||
|
|
||||||
$("head").prepend(["<script>", ` window.${nameOfTheGlobal}= ${ftlObjectToJsCodeDeclaringAnObjectPlaceholder};`, "</script>"].join("\n"));
|
$("head").prepend(`<script>\nwindow.${nameOfTheGlobal}=${ftlObjectToJsCodeDeclaringAnObjectPlaceholder}</script>`);
|
||||||
|
|
||||||
// Remove part of the document marked as ignored.
|
// Remove part of the document marked as ignored.
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user