From 1fead1ba9f1ddc4abb8fa63a523903b6bc36e11e Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 7 Nov 2024 12:15:13 +0100 Subject: [PATCH 01/13] adding parameter exist:controller --- add/controller.xql | 1 + 1 file changed, 1 insertion(+) diff --git a/add/controller.xql b/add/controller.xql index b3046c85b..5d7778221 100755 --- a/add/controller.xql +++ b/add/controller.xql @@ -37,6 +37,7 @@ return + (:else if (starts-with($exist:path, "/data")) then From 51c46a4303b85b259f582ca066db52c8bcdcc665 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 7 Nov 2024 12:15:43 +0100 Subject: [PATCH 02/13] lookup defaults if no language set --- add/data/xqm/util.xqm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index 49e466099..3e8817af7 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -287,12 +287,19 @@ declare function eutil:getLanguageString($key as xs:string, $values as xs:string :) declare function eutil:getPreference($key as xs:string, $edition as xs:string?) as xs:string { - let $preferencesFile := + let $prefFileCustom := try { doc(edition:getPreferencesURI($edition)) } - catch * { util:log-system-out('Failed to load preferences') } - + catch * { console:log('Failed to load preferences') } + + let $prefFileDefault := doc($edition:default-prefs-location) + + let $prefFile := if($prefFileCustom//entry/@key = 'application_language') then + $prefFileCustom + else + ($prefFileDefault) + return - $preferencesFile//entry[@key = $key]/@value => string() + $prefFile//entry[@key = $key]/@value => string() }; From db44a249b18ef0beb8e9ba9765229db94176e645 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 7 Nov 2024 12:16:00 +0100 Subject: [PATCH 03/13] using controller for getting location --- add/data/xqm/edition.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index d47d1d235..c9ad8f1e6 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -21,7 +21,7 @@ declare namespace xlink = "http://www.w3.org/1999/xlink"; (: VARIABLE DECLARATIONS =================================================== :) -declare variable $edition:default-prefs-location as xs:string := '../prefs/edirom-prefs.xml'; +declare variable $edition:default-prefs-location as xs:string := request:get-parameter('exist:controller','xmldb:exist:///db/apps/Edirom-Online') || '/data/prefs/edirom-prefs.xml'; (: FUNCTION DECLARATIONS =================================================== :) From cb9d74cf81a0f1e3edf918a0337032adf2cc704b Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 7 Nov 2024 13:28:49 +0100 Subject: [PATCH 04/13] killed cookies --- add/controller.xql | 1 - add/data/xqm/util.xqm | 6 ------ 2 files changed, 7 deletions(-) diff --git a/add/controller.xql b/add/controller.xql index 5d7778221..0c863eb06 100755 --- a/add/controller.xql +++ b/add/controller.xql @@ -35,7 +35,6 @@ return (: forward index.html to index.xql :) - diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index 3e8817af7..eeab484ab 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -310,16 +310,10 @@ declare function eutil:getPreference($key as xs:string, $edition as xs:string?) : @return The language key :) declare function eutil:getLanguage($edition as xs:string?) as xs:string { - if (request:get-parameter("lang", "") != "") then request:get-parameter("lang", "") - - else if(request:get-cookie-names() = 'edirom-language') then - request:get-cookie-value('edirom-language') - else eutil:getPreference('application_language', edition:findEdition($edition)) - }; (:~ From 0ef2a88ae7c921474f6ee920be1d68a884042491 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 7 Nov 2024 13:44:00 +0100 Subject: [PATCH 05/13] fix function --- add/data/xqm/util.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index eeab484ab..0339c9f28 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -293,7 +293,7 @@ declare function eutil:getPreference($key as xs:string, $edition as xs:string?) let $prefFileDefault := doc($edition:default-prefs-location) - let $prefFile := if($prefFileCustom//entry/@key = 'application_language') then + let $prefFile := if($prefFileCustom//entry/@key = $key) then $prefFileCustom else ($prefFileDefault) From ce7b12d4415bae582cab16d0612f79d4e8d85ba1 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 7 Nov 2024 13:44:12 +0100 Subject: [PATCH 06/13] reset log output function --- add/data/xqm/util.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index 0339c9f28..566721bdf 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -289,7 +289,7 @@ declare function eutil:getPreference($key as xs:string, $edition as xs:string?) let $prefFileCustom := try { doc(edition:getPreferencesURI($edition)) } - catch * { console:log('Failed to load preferences') } + catch * { util:log-system-out('Failed to load preferences') } let $prefFileDefault := doc($edition:default-prefs-location) From fe53c920f4e5e8a3e2976cd1e9653b0786a9d007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20R=C3=B6wenstrunk?= Date: Mon, 2 Dec 2024 10:30:45 +0100 Subject: [PATCH 07/13] Relative path is better here as Peter suggested --- add/data/xqm/edition.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index c9ad8f1e6..d47d1d235 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -21,7 +21,7 @@ declare namespace xlink = "http://www.w3.org/1999/xlink"; (: VARIABLE DECLARATIONS =================================================== :) -declare variable $edition:default-prefs-location as xs:string := request:get-parameter('exist:controller','xmldb:exist:///db/apps/Edirom-Online') || '/data/prefs/edirom-prefs.xml'; +declare variable $edition:default-prefs-location as xs:string := '../prefs/edirom-prefs.xml'; (: FUNCTION DECLARATIONS =================================================== :) From 046b643f30765bb997d0d044d4888dc2c4a82da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20R=C3=B6wenstrunk?= Date: Mon, 2 Dec 2024 10:55:17 +0100 Subject: [PATCH 08/13] Enhanced and shorter version of the getPreference function --- add/data/xqm/util.xqm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index 566721bdf..7d2e48542 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -287,20 +287,20 @@ declare function eutil:getLanguageString($key as xs:string, $values as xs:string :) declare function eutil:getPreference($key as xs:string, $edition as xs:string?) as xs:string { + (: Try to load a custom preferences file :) let $prefFileCustom := try { doc(edition:getPreferencesURI($edition)) } - catch * { util:log-system-out('Failed to load preferences') } + catch * { util:log-system-out('Failed to load the custom preferences file') } - let $prefFileDefault := doc($edition:default-prefs-location) - - let $prefFile := if($prefFileCustom//entry/@key = $key) then - $prefFileCustom - else - ($prefFileDefault) - return - $prefFile//entry[@key = $key]/@value => string() - + (: If there is a value for the key in the custom preferences file :) + if($prefFileCustom//entry/@key = $key) then + $prefFileCustom//entry[@key = $key]/@value => string() + (: If not, take the value for the key in the default preferences file :) + else + try { doc($edition:default-prefs-location)//entry[@key = $key]/@value => string() } + (: If the key is not in the default file, then there should be an error :) + catch * { util:log-system-out(concat('Failed to find the key `', $key, '` in default preferences file')) } }; (:~ From 68b65caadf1b6423a569e99e2772afb24440eed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20R=C3=B6wenstrunk?= Date: Mon, 2 Dec 2024 11:00:29 +0100 Subject: [PATCH 09/13] Just in case there is no default language in the preferences --- add/data/xqm/util.xqm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index 7d2e48542..2e8ec3c7d 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -310,10 +310,13 @@ declare function eutil:getPreference($key as xs:string, $edition as xs:string?) : @return The language key :) declare function eutil:getLanguage($edition as xs:string?) as xs:string { + if (request:get-parameter("lang", "") != "") then request:get-parameter("lang", "") - else + else if(eutil:getPreference('application_language', edition:findEdition($edition)) != '') then eutil:getPreference('application_language', edition:findEdition($edition)) + else + 'en' }; (:~ From f545e9602aaf6cd4b228e48d8ae00cdc25de4554 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Wed, 4 Dec 2024 19:45:42 +0100 Subject: [PATCH 10/13] set hard coded default to `de` --- add/data/xqm/util.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index 2e8ec3c7d..a7038c489 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -316,7 +316,7 @@ declare function eutil:getLanguage($edition as xs:string?) as xs:string { else if(eutil:getPreference('application_language', edition:findEdition($edition)) != '') then eutil:getPreference('application_language', edition:findEdition($edition)) else - 'en' + 'de' }; (:~ From be3cd30f44abb0512b28408651ee369690e27adc Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Wed, 4 Dec 2024 19:46:23 +0100 Subject: [PATCH 11/13] remove check for empty values as @peterstadler suggested --- add/data/xqm/util.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index a7038c489..aa958d0e4 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -313,7 +313,7 @@ declare function eutil:getLanguage($edition as xs:string?) as xs:string { if (request:get-parameter("lang", "") != "") then request:get-parameter("lang", "") - else if(eutil:getPreference('application_language', edition:findEdition($edition)) != '') then + else if(eutil:getPreference('application_language', edition:findEdition($edition))) then eutil:getPreference('application_language', edition:findEdition($edition)) else 'de' From 3ad648e48dd3c56ade8984e69190c01d16861e57 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 5 Dec 2024 17:17:30 +0100 Subject: [PATCH 12/13] Update add/data/xqm/util.xqm --- add/data/xqm/util.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index aa958d0e4..8b0825faa 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -285,7 +285,7 @@ declare function eutil:getLanguageString($key as xs:string, $values as xs:string : @param $edition The current edition URI : @return The preference value :) -declare function eutil:getPreference($key as xs:string, $edition as xs:string?) as xs:string { +declare function eutil:getPreference($key as xs:string, $edition as xs:string?) as xs:string? { (: Try to load a custom preferences file :) let $prefFileCustom := From 8d683cafee03098841c956fc33e067c62f9ebfa5 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Mon, 9 Dec 2024 11:03:27 +0100 Subject: [PATCH 13/13] delete fragment --- add/controller.xql | 1 - 1 file changed, 1 deletion(-) diff --git a/add/controller.xql b/add/controller.xql index 0c863eb06..adec226f7 100755 --- a/add/controller.xql +++ b/add/controller.xql @@ -36,7 +36,6 @@ return - (:else if (starts-with($exist:path, "/data")) then