Commit 86620ca0 authored by Jérôme Chauveau's avatar Jérôme Chauveau
Browse files

add some comments

parent 9599912a
Loading
Loading
Loading
Loading
+5 −2
Changes for src/main/core/conf.xqm: 5 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ declare function conf:get-package-path() as xs:string{
};

(:~
 : @return vocabulary name
 : @return active vocabulary name
 :)
declare function conf:get-vocabulary-bundle() as xs:string{
	let $bundle := string(conf:get-configuration()/@vocabulary-bundle)
@@ -78,7 +78,7 @@ declare function conf:get-title() as xs:string*{
};

(:~
 : @return vocabulary name
 : @return if dev mode is enabled
 :)
declare function conf:is-dev-mode() as xs:boolean{
	string(conf:get-configuration()/@env) = $conf:dev-mode
@@ -95,6 +95,9 @@ declare function conf:get-vocabulary-namespace(){
    return doc($pkgFile)//expath:xquery/expath:namespace/text()
};

(:~
 : @return main vocabulary bundle xq file path
 :)
declare function conf:get-vocabulary-xq-file(){
    let $bundleName := conf:get-vocabulary-bundle()
    let $pkgFile := utils:get-bundles-path() || $bundleName || '/' || $conf:package-file
+3
Changes for src/main/core/database.xqm: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ declare variable $database:max-db := "max";


(:~
 : @param $documentPath document path
 : @return doc in max db
 :)
declare function database:get-document($documentPath as xs:string) as document-node()?{
@@ -25,6 +26,8 @@ declare function database:get-document($documentPath as xs:string) as document-n


(:~
 : @param $documentPath document path
 : @param  $id  fragment id
 : @return identified fragment in a document of max db
 :)
declare function database:get-element-by-id($documentPath, $id as xs:string) as element()?{
+16
Changes for src/main/core/i18n.xqm: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ import module namespace conf = 'https://certic.unicaen.fr/max/conf' at 'conf.xqm
import module namespace utils = 'https://certic.unicaen.fr/max/utils' at 'utils.xqm';
(:~
 : Returns custom translation (from locales/)
 : @param $key translation key
 : @param $lang target language code
 : @return string
 :)
declare function i18n:translate ($key as xs:string, $lang as xs:string) as xs:string {
@@ -19,6 +21,8 @@ declare function i18n:translate ($key as xs:string, $lang as xs:string) as xs:st

(:~
 : Returns default translation (from vocabulary bundle locales)
 : @param $key translation key
 : @param $lang target language code
 : @return string
 :)
declare function i18n:default-translate ($key as xs:string, $lang as xs:string) as xs:string {
@@ -28,16 +32,28 @@ declare function i18n:default-translate ($key as xs:string, $lang as xs:string)
   }catch * {$key}
};

(:~
 : User locales path
 : @return string
 :)
declare function i18n:getUserLocalesPath(){
    file:current-dir() || 'locales/'
};

(:~
 : bundle locales path
 : @return string
 :)
declare function i18n:getVocabularyLocalesPath(){
    let $voc := conf:get-vocabulary-bundle()
    let $repoPath := utils:get-bundles-path()
    return $repoPath || $voc || '/locales/'
};

(:~
 : locales paths
 : @return sequence of strings
 :)
declare function i18n:getLocalePaths(){
    (i18n:getUserLocalesPath(), i18n:getVocabularyLocalesPath())
};
+4
Changes for src/main/core/routes.xqm: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -210,6 +210,10 @@ function routes:max-infos(){
    else errors:not-found('', $conf:default-lang)
};


(:~
 : @return routes list as html
 :)
declare %private function routes:list(){
    let $wadl:=rest:wadl()
    let $maxRoutes := <ul>{
+22 −1
Changes for src/main/core/templating.xqm: 22 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -9,6 +9,12 @@ import module namespace conf = 'https://certic.unicaen.fr/max/conf' at 'conf.xqm
import module namespace i18n = 'https://certic.unicaen.fr/max/i18n' at 'i18n.xqm';
import module namespace utils= 'https://certic.unicaen.fr/max/utils' at 'utils.xqm';

(:~
 : Render html template
 : @param $template template name
 : @param $map variables
 : @return html node
 :)
declare function templating:render($template as xs:string, $map as map(*)){
    let $filePath := templating:template-file($template)
    let $templateDoc := try {
@@ -59,7 +65,12 @@ declare function templating:render($template as xs:string, $map as map(*)){
           else $render
};


(:~
 : Eval template as xquery
 : @param $templateDoc template document
 : @param $map variables
 : @return html node
 :)
declare function templating:eval-template($templateDoc as document-node(), $map as map(*)){
    let $params := map:put($map, 'active', fn:replace(fn:tokenize(request:path(),'/')[last()],'.html',''))
    let $declarations := string-join(
@@ -69,6 +80,11 @@ declare function templating:eval-template($templateDoc as document-node(), $map
    return xquery:eval($import ||$declarations ||  serialize($templateDoc), $params)
};

(:~
 : Return template file path according to its name
 : @param $filename template filename
 : @return string
 :)
declare function templating:template-file($filename as xs:string){

    let $userFile := file:current-dir()|| 'templates/' || $filename
@@ -84,6 +100,11 @@ declare function templating:template-file($filename as xs:string){

};

(:~
 : Return languages html list
 : @param $currentLang current lang
 : @return html ul node
 :)
declare function templating:languageSelect($currentLang as xs:string?) as node()?{
    let $languages := conf:get-languages()

Loading