Skip to content

Commit

Permalink
move index configuration into post-install hook
Browse files Browse the repository at this point in the history
because we need to know the location of `$config:data-root`
  • Loading branch information
peterstadler committed Aug 19, 2022
1 parent 043358d commit 3f43f87
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 33 deletions.
38 changes: 38 additions & 0 deletions post-install.xql
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,43 @@ declare function local:force-xml-mime-type-xbl() as xs:string* {
return if (exists($doc)) then xdb:store($forms-includes, $r, $doc, 'application/xml') else ()
};

(:~
: Helper function to recursively create a collection hierarchy.
:)
declare function local:mkcol-recursive($collection, $components) {
if (exists($components)) then
let $newColl := concat($collection, "/", $components[1])
return (
xdb:create-collection($collection, $components[1]),
local:mkcol-recursive($newColl, subsequence($components, 2))
)
else
()
};

(:~
: Helper function to recursively create a collection hierarchy.
:)
declare function local:mkcol($collection, $path) {
local:mkcol-recursive($collection, tokenize($path, "/"))
};

(:~
: Add default index configuration to the data collection provided in $config:data-root
: Indices are used for searching and filtering on the main list page,
: see https://github.com/Edirom/MerMEId/issues/112
:)
declare function local:add-index-configuration() as item()* {
let $config-path := concat("/db/system/config", $config:data-root)
return
if(doc-available(concat($config-path, '/collection.xconf'))) then ()
else (
local:mkcol("/db/system/config", $config:data-root),
xdb:store-files-from-pattern($config-path, $dir, "*.xconf"),
xdb:reindex($config:data-root)
)
};

(: set options provided as environment variables :)
local:set-options(),
local:force-xml-mime-type-xbl(),
Expand All @@ -107,6 +144,7 @@ if (local:first-run()) then
local:create-group(),
local:create-user(),
local:change-group(),
local:add-index-configuration(),
(: This has to be the last command otherwise the other commands will not be executed properly :)
local:set-admin-password()
)
Expand Down
32 changes: 0 additions & 32 deletions pre-install.xql

This file was deleted.

1 change: 0 additions & 1 deletion repo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
<copyright>true</copyright>
<type>application</type>
<target>mermeid</target>
<prepare>pre-install.xql</prepare>
<finish>post-install.xql</finish>
</meta>

0 comments on commit 3f43f87

Please sign in to comment.