Commit 731596d0 authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

Merge branch 'jc/install-ead-demo' into dev

parents fea733ce 507f1eb5
# Changelog
## [1.0.0] - 01/04/2022
Première version stable de MaX
......@@ -25,7 +25,7 @@ mkdir $RELEASE_FOLDER/tools
cp -r $DIRECTORY/../configuration/configuration.dist.xml $RELEASE_FOLDER/configuration
cp -Lr $DIRECTORY/../ui $RELEASE_FOLDER
cp -r $DIRECTORY/../rxq $RELEASE_FOLDER
cp -r $DIRECTORY/../documentation $RELEASE_FOLDER
#cp -r $DIRECTORY/../documentation $RELEASE_FOLDER
cp $DIRECTORY/../max.xq $RELEASE_FOLDER
cp $DIRECTORY/../legal.txt $RELEASE_FOLDER
cp $DIRECTORY/../README.md $RELEASE_FOLDER
......@@ -33,9 +33,11 @@ cp -Lr $DIRECTORY/../plugins $RELEASE_FOLDER
cp $DIRECTORY/../tools/max.sh $RELEASE_FOLDER/tools
cp -r $DIRECTORY/../tools/xq $RELEASE_FOLDER/tools
cp $DIRECTORY/../tools/*.xml $RELEASE_FOLDER/tools
cp $DIRECTORY/../CHANGELOG $RELEASE_FOLDER/
#removes equations plugin
#removes equations & pager plugins
rm -rf $RELEASE_FOLDER/plugins/equations
rm -rf $RELEASE_FOLDER/plugins/pager
#injects MAX VERSION in max.sh cli tool
sed -i "2s/.*/MAX_VERSION=$MAX_VERSION/g" $RELEASE_FOLDER/tools/max.sh
......
......@@ -5,9 +5,15 @@ MAX_VERSION=$(node -p -e "require('$DIRECTORY/../package.json').version")
MAX_PLUGINS_DIR=$DIRECTORY/../plugins
BASEX_CLIENT_BIN="basexclient"
BASEX_BIN="basex"
MAX_DEMO_VERION_NUMBER="v1.1"
MAX_DEMO_VERSION="max-tei-demo-"$MAX_DEMO_VERION_NUMBER
DEMO_RELEASE_URL="https://git.unicaen.fr/pdn-certic/max-tei-demo/-/archive/v1.1/"$MAX_DEMO_VERSION".zip"
MAX_TEI_DEMO_VERION_NUMBER="v1.2"
MAX_TEI_DEMO_VERSION="max-tei-demo-"$MAX_TEI_DEMO_VERION_NUMBER
MAX_EAD_DEMO_VERION_NUMBER="v1.0"
MAX_EAD_DEMO_VERSION="max-ead-demo-"$MAX_EAD_DEMO_VERION_NUMBER
TEI_DEMO_RELEASE_URL="https://git.unicaen.fr/pdn-certic/max-tei-demo/-/archive/"$MAX_TEI_DEMO_VERION_NUMBER"/"$MAX_TEI_DEMO_VERSION".zip"
EAD_DEMO_RELEASE_URL="https://git.unicaen.fr/pdn-certic/max-ead-demo/-/archive/"$MAX_EAD_DEMO_VERION_NUMBER"/"$MAX_EAD_DEMO_VERSION".zip"
SAXON_HE_URL=https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/11.2/Saxon-HE-11.2.jar
FOP_URL=https://files.basex.org/modules/org/basex/modules/fop/FOP.jar
dependency_test(){
result=$(command -v $1)
......@@ -20,12 +26,31 @@ dependency_test(){
fi
}
install_jar_in_libs(){
jar_url=$1
jar_name=`basename $jar_url`
basex_libs=`which $BASEX_BIN`
d=`dirname $basex_libs`/../lib
if [ ! -f $d/$jar_name ]
then
wget $jar_url
ret_code=$?
if [ $ret_code -gt 0 ]
then
echo 'Cannot install jar '$jar_url
exit -1
else
mv $jar_name $d
fi
fi
echo $jar_name': ok'
}
echo "---------------------------"
echo " MaX - Utilities - "$MAX_VERSION
echo "---------------------------"
dependencies=(wget npm xmllint)
for bin in ${dependencies[@]}
......@@ -49,14 +74,21 @@ else
fi
fi
#checks if fop & saxon he jar are in basex libs
echo ""
install_jar_in_libs $SAXON_HE_URL
install_jar_in_libs $FOP_URL
echo ""
display_usage(){
echo ""
echo ""
echo " -h: Display help."
echo " -p: Specify BaseX port to use for db feed. Default one is "$PORT"."
echo " -i: Max development env initialization."
echo " -d: Deploy the demo edition project."
echo " -n: Deploy new edition with its XML sources."
echo " --d-tei: Deploy the TEI demo edition project."
echo " --d-ead: Deploy the EAD demo edition project."
echo " --list-plugins: show plugins and status."
echo " --enable-plugin [plugin_name]: Enable [plugin_name] plugin."
echo " --disable-plugin [plugin_name]: Disable [plugin_name] plugin."
......@@ -136,44 +168,6 @@ disable_plugin(){
}
# 1 argument required
if [ $# -lt 1 ]
then
display_usage
exit 1
fi
NEW_EDITION_MODE='-n'
DEMO_MODE='-d'
INIT_MODE='-i'
CHOOSEN_MODE=''
while [[ "$#" -gt 0 ]]; do
case $1 in
-h) display_usage
exit 0;;
-p) PORT="$2"; shift ;;
-n|-d|-i) CHOOSEN_MODE="$1"; shift ;;
--list-plugins) list_plugins;exit 0;;
--enable-plugin) enable_plugin $2 $3;exit 0;;
--disable-plugin) disable_plugin $2 $3;exit 0;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
if [ -z $CHOOSEN_MODE ]
then
display_usage
exit 1
fi
db_demo_feed(){
db_project_feed max_tei_demo $DIRECTORY/../editions/max_tei_demo/dataset/
}
#adds xml datas to a new db
db_project_feed(){
feed_cmd=$BASEX_CLIENT_BIN" -p$PORT -w -cfeed.txt"
......@@ -184,59 +178,163 @@ db_project_feed(){
ret_code=$?
if [ $ret_code -gt 0 ]
then echo "Cannot insert data in DB. Is your BaseX running on "$PORT" ?"
else
rm feed.txt
return 1
else
echo "INFO: The "$1" DB was successfully created."
rm feed.txt
return 0
fi
}
demo_edition_build(){
if [ ! -d $DIRECTORY/../editions ]
then
echo 'Creates "editions" directory.'
mkdir $DIRECTORY/../editions
fi
# install demo sources from its dataset directory
db_demo_feed(){
edition_name=$1
db_project_feed $1 $DIRECTORY/../editions/$1/dataset/
ret_code=$?
return $ret_code
}
if [ -d $DIRECTORY/../editions/max_tei_demo ]; then
echo "Removes existing demo edition."
rm -rf $DIRECTORY/../editions/max_tei_demo
fi
#is project already declared in main config file ?
check_project_xinclude(){
edition_name=$1
a=$($BASEX_BIN -bprojectId=$edition_name -bmaxPath=$DIRECTORY/.. $DIRECTORY"/xq/check_config_exists.xq")
if [ $a == 0 ]
then
echo 'Edition '$edition_name' is already declared in configuration file. Remove it before installing your edition.'
echo 'Installation stopped !'
return 1
fi
return 0
}
# cp -r $DIRECTORY/demo/demo_edition $DIRECTORY/../editions/demo_lorem
# cp $DIRECTORY/demo/demo_lorem_config_inc.xml $DIRECTORY/../editions/demo_lorem
# echo " -> resource files copy: DONE"
cd $DIRECTORY/../editions
echo "Downloading Max TEI Demo resources"
# demo edition deployment
install_demo(){
url=$1
zip_name=$2
edition_name=$3
check_project_xinclude $edition_name
if [ $? -gt 0 ]
then
exit -1
fi
wget $DEMO_RELEASE_URL
if [ ! -d $DIRECTORY/../editions ]
then
echo 'Creates "editions" directory.'
mkdir $DIRECTORY/../editions
fi
getResult=$?
if [ $getResult -ne 0 ]
then
echo 'MaX demo install error : Cannot fetch '$DEMO_RELEASE_URL
exit -1
fi
unzip $MAX_DEMO_VERSION.zip
mv $MAX_DEMO_VERSION max_tei_demo
rm $MAX_DEMO_VERSION.zip
cd $DIRECTORY
if [ -d $DIRECTORY/../editions/$edition_name ]
then
echo "Removes existing demo edition."
rm -rf $DIRECTORY/../editions/$edition_name
fi
cd $DIRECTORY/../editions
echo "Downloading Max Demo resources at "$url .
wget $url
getResult=$?
if [ $getResult -ne 0 ]
then
echo 'MaX demo install error : Cannot fetch '$url
exit -1
fi
unzip $zip_name.zip
mv $zip_name $edition_name
rm $zip_name.zip
cd $DIRECTORY
db_demo_feed $edition_name
ret_code=$?
if [ $ret_code -gt 0 ]
then echo $edition_name": installation failed"
rm -rf $DIRECTORY/../editions/$edition_name
return 1
fi
# enable project plugins
#enable plugins
if [ $edition_name == 'max_tei_demo' ]
then
enable_plugin apparat_critique max_tei_demo
enable_plugin breadcrumb max_tei_demo
enable_plugin correction max_tei_demo
enable_plugin img_viewer max_tei_demo
enable_plugin search max_tei_demo
enable_plugin tei_pdf max_tei_demo
include_project_config max_tei_demo
else
enable_plugin side_toc max_ead_demo
enable_plugin ead_basket max_ead_demo
fi
if [ $? -ne 0 ]
then
echo 'Process failed'
exit 1
else
format_configuration_file
fi
#include edition conf file in main max config one
include_project_config $edition_name
if [ $? -ne 0 ]
then
echo 'Process failed'
exit 1
else
format_configuration_file
fi
echo "INFO: The edition "$edition_name" was successfully deployed."
return 0
}
deploy_new_edition(){
read -e -p "Project ID ? " project_id
read -e -p "XML Project type (tei, ead, ...) ? " xmlns
read -e -p "Database path ? " db_path
check_project_xinclude $project_id
if [ $? -gt 0 ]
then
exit -1
fi
new_edition_build $project_id $db_path $xmlns
read -e -p "XML sources path ? " data_path
db_project_feed $db_path $data_path
ret_code=$?
if [ $ret_code -gt 0 ]
then
echo 'Process failed'
return -1
fi
mkdir -p $DIRECTORY/../editions/$project_id/fragments/fr
mkdir $DIRECTORY/../editions/$project_id/xq
mkdir $DIRECTORY/../editions/$project_id/ui
mkdir $DIRECTORY/../editions/$project_id/ui/css
mkdir $DIRECTORY/../editions/$project_id/ui/fonts
mkdir $DIRECTORY/../editions/$project_id/ui/i18n
mkdir $DIRECTORY/../editions/$project_id/ui/images
mkdir $DIRECTORY/../editions/$project_id/ui/js
mkdir $DIRECTORY/../editions/$project_id/ui/templates
mkdir $DIRECTORY/../editions/$project_id/ui/xsl
touch $DIRECTORY/../editions/$project_id/ui/css/$project_id.css
#creates about frag page
touch $DIRECTORY/../editions/$project_id/fragments/fr/about.frag.html
echo "<section>" > $DIRECTORY/../editions/$project_id/fragments/fr/about.frag.html
echo "<h1>À propos</h1>" >> $DIRECTORY/../editions/$project_id/fragments/fr/about.frag.html
echo "<p>Modifiez moi dans editions/$project_id/fragments/fr/about.frag.html.</p>" >> $DIRECTORY/../editions/$project_id/fragments/fr/about.frag.html
echo "</section>" >> $DIRECTORY/../editions/$project_id/fragments/fr/about.frag.html
cp $DIRECTORY/menu_default.xml $DIRECTORY/../editions/$project_id/menu.xml
if [ $xmlns = 'ead' ]
then
enable_plugin 'ead_basket'
enable_plugin 'side_toc'
fi
echo ''
echo "Project "$project_id" is ready !"
exit 0
}
......@@ -244,6 +342,14 @@ include_project_config(){
$BASEX_BIN -u -bprojectId=$1 $DIRECTORY"/xq/include_project_config.xq" # -u => save modified file on disk
}
format_configuration_file(){
FILE=$DIRECTORY"/../configuration/configuration.xml"
mv $FILE $FILE".bak" || exit 1
xmllint --format $FILE".bak" > $FILE
rm $FILE".bak"
}
new_edition_build(){
if [ ! -d $DIRECTORY/../editions ]
then
......@@ -258,12 +364,6 @@ new_edition_build(){
format_configuration_file(){
FILE=$DIRECTORY"/../configuration/configuration.xml"
mv $FILE $FILE".bak" || exit 1
xmllint --format $FILE".bak" > $FILE
rm $FILE".bak"
}
init_dev_max(){
cd $DIRECTORY/..
......@@ -285,6 +385,15 @@ init_dev_max(){
}
# 1 argument required
if [ $# -lt 1 ]
then
display_usage
exit 1
fi
#creates config file if not exists (.dist copy)
if [ ! -f $DIRECTORY/../configuration/configuration.xml ]
then
......@@ -293,54 +402,20 @@ then
fi
if [ $CHOOSEN_MODE == $NEW_EDITION_MODE ]
then
read -e -p "Project ID ? " project_id
read -e -p "XML Project type (tei, ead, ...) ? " xmlns
read -e -p "Database path ? " db_path
new_edition_build $project_id $db_path $xmlns
read -e -p "XML sources path ? " data_path
db_project_feed $db_path $data_path
mkdir -p $DIRECTORY/../editions/$project_id/fragments/fr
mkdir $DIRECTORY/../editions/$project_id/xq
mkdir $DIRECTORY/../editions/$project_id/ui
mkdir $DIRECTORY/../editions/$project_id/ui/css
mkdir $DIRECTORY/../editions/$project_id/ui/fonts
mkdir $DIRECTORY/../editions/$project_id/ui/i18n
mkdir $DIRECTORY/../editions/$project_id/ui/images
mkdir $DIRECTORY/../editions/$project_id/ui/js
mkdir $DIRECTORY/../editions/$project_id/ui/templates
mkdir $DIRECTORY/../editions/$project_id/ui/xsl
touch $DIRECTORY/../editions/$project_id/ui/css/$project_id.css
#creates about frag page
touch $DIRECTORY/../editions/$project_id/fragments/fr/about.frag.html
echo "<section>" > $DIRECTORY/../editions/$project_id/fragments/fr/about.frag.html
echo "<h1>À propos</h1>" >> $DIRECTORY/../editions/$project_id/fragments/fr/about.frag.html
echo "<p>Modifiez moi dans editions/$project_id/fragments/fr/about.frag.html.</p>" >> $DIRECTORY/../editions/$project_id/fragments/fr/about.frag.html
echo "</section>" >> $DIRECTORY/../editions/$project_id/fragments/fr/about.frag.html
cp $DIRECTORY/menu_default.xml $DIRECTORY/../editions/$project_id/menu.xml
if [ $xmlns = 'ead' ]
then
enable_plugin 'ead_basket'
enable_plugin 'side_toc'
fi
echo ''
echo "Project "$project_id" is ready !"
exit 0
fi
if [ $CHOOSEN_MODE == $DEMO_MODE ]
then
demo_edition_build
db_demo_feed
exit 0
fi
while [[ "$#" -gt 0 ]]; do
case $1 in
-h) display_usage
exit 0;;
-p) PORT="$2"; shift ;;
-n) deploy_new_edition;exit 0;;
-i) init_dev_max;exit 0;;
--d-tei) install_demo $TEI_DEMO_RELEASE_URL $MAX_TEI_DEMO_VERSION max_tei_demo;exit 0;;
--d-ead) install_demo $EAD_DEMO_RELEASE_URL $MAX_EAD_DEMO_VERSION max_ead_demo;exit 0;;
--list-plugins) list_plugins;exit 0;;
--enable-plugin) enable_plugin $2 $3;exit 0;;
--disable-plugin) disable_plugin $2 $3;exit 0;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
if [ $CHOOSEN_MODE == $INIT_MODE ]
then
init_dev_max
exit 0
fi
(: Check if a project is already declared in the main configuration file:)
declare variable $maxPath external;
declare variable $projectId external;
let $config:= doc($maxPath||'/configuration/configuration.xml')
return
if($config//edition[@xml:id=$projectId])
then 0
else -1
(: création du fichier de configuration de base pour un nouveau projet:)
(: Create new project configuration file :)
declare variable $maxPath external;
declare variable $projectId external;
......
(: inclusion du fichier de config d'un projet dans la configuration principale:)
(: Include a project config file into the main one:)
declare namespace xi="http://www.w3.org/2001/XInclude";
declare variable $projectId external;
declare option db:xinclude 'false'; (:pour ne pas résoudre les inclusions:)
......
(: Insertion de la configuration d'un plugin pour un projet donné:)
(: Insert plugin's config section for a specific project :)
declare variable $projectId external;
declare variable $pluginId external;
......@@ -8,7 +8,7 @@ let $plugins := $configDoc/edition/plugins
return
if($plugins/plugin[@name=$pluginId])
then () (:plugin déjà activé:)
then () (:plugin already enabled:)
else
let $pluginNode := <plugin name="{$pluginId}"/>
return insert node $pluginNode into $plugins
(: Suppression de la configuration d'un plugin pour un projet donné:)
(: Remove plugin's config section for a specific project :)
declare variable $projectId external;
declare variable $pluginId external;
......
......@@ -122,11 +122,11 @@ class MaxTEI extends AbstractMax {
//local function : find next or previous nav link
let nextOrPrevious = function (step) {
let current = document.getElementById("navigation-tool").querySelector('button').getAttribute("data-target").replace("selected-", "");//remove 'selected' prefix
let newCurrent = current.replaceAll(".", "\\.")
let links = document.getElementById('dropdown-navigation').querySelectorAll('li');
let position = -1;
console.log(links);
links.forEach((link, index) => {
if(link.dataset.target === newCurrent){
if(link.dataset.target === current){
position = index;
}
})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment