mirror of
https://github.com/YunoHost-Apps/cops_ynh.git
synced 2024-09-03 18:25:57 +02:00
Use automatic function to remove trailing / on calibrepath
This commit is contained in:
parent
72a238f6ff
commit
74034f5513
5 changed files with 21 additions and 8 deletions
|
@ -1,19 +1,19 @@
|
|||
<?php
|
||||
if (!isset($config))
|
||||
$config = array();
|
||||
|
||||
|
||||
/*
|
||||
* The directory containing calibre's metadata.db file, with sub-directories
|
||||
* containing all the formats.
|
||||
* BEWARE : it has to end with a /
|
||||
*/
|
||||
$config['calibre_directory'] = 'CALIBRETOCHANGE';
|
||||
|
||||
$config['calibre_directory'] = 'CALIBRETOCHANGE/';
|
||||
|
||||
/*
|
||||
* Catalog's title
|
||||
*/
|
||||
$config['cops_title_default'] = "COPS";
|
||||
|
||||
|
||||
/*
|
||||
* use URL rewriting for downloading of ebook in HTML catalog
|
||||
* See README for more information
|
||||
|
|
|
@ -54,11 +54,11 @@
|
|||
"name": "calibrepath",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Indicate the location of Calibre library. It MUST end with a / and DON'T store it in your /var/www/cops !!",
|
||||
"fr": "Indiquez le chemin de votre bibliotheque Calibre. Cela DOIT se terminer par un / et ne la mettez pas dans /var/www/cops !!!"
|
||||
"en": "Indicate the location of Calibre library. DON'T store it in your /var/www/cops or it will be removed on next upgrade !!",
|
||||
"fr": "Indiquez le chemin de votre bibliotheque Calibre. Ne la mettez pas dans /var/www/cops ou elle sera supprimée à la prochaine upgrade !!!"
|
||||
},
|
||||
"example": "/home/yunohost.app/owncloud/data/johndoe/files/eBooks/",
|
||||
"default": "/home/yunohost.app/owncloud/data/johndoe/files/eBooks/"
|
||||
"example": "/home/yunohost.app/owncloud/data/johndoe/files/eBooks",
|
||||
"default": "/home/yunohost.app/owncloud/data/johndoe/files/eBooks"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
|
|
|
@ -44,6 +44,15 @@ CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence
|
|||
fi
|
||||
}
|
||||
|
||||
CHECK_CALIBREPATH () { # Vérifie la présence du / en début de path. Et son absence à la fin.
|
||||
if [ "${calibrepath:0:1}" != "/" ]; then # Si le premier caractère n'est pas un /
|
||||
path="/$calibrepath" # Ajoute un / en début de path
|
||||
fi
|
||||
if [ "${calibrepath:${#calibrepath}-1}" == "/" ] && [ ${#calibrepath} -gt 1 ]; then # Si le dernier caractère est un / et que ce n'est pas le seul caractère.
|
||||
path="${calibrepath:0:${#calibrepath}-1}" # Supprime le dernier caractère
|
||||
fi
|
||||
}
|
||||
|
||||
CHECK_DOMAINPATH () { # Vérifie la disponibilité du path et du domaine.
|
||||
sudo yunohost app checkurl $domain$path -a $app
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ CHECK_VAR "$app" "app name not set"
|
|||
|
||||
# Check the path value and correct it (adds / at begining and removes it at the end)
|
||||
CHECK_PATH
|
||||
CHECK_CALIBREPATH
|
||||
|
||||
# Check domain and path availibility
|
||||
CHECK_DOMAINPATH
|
||||
|
|
|
@ -25,6 +25,9 @@ runninguser=$(ynh_app_setting_get $app runninguser)
|
|||
calibrepath=$(ynh_app_setting_get $app calibrepath)
|
||||
basicauthcreate=$(ynh_app_setting_get $app basicauthcreate)
|
||||
|
||||
# We check that calibrepath is correct
|
||||
CHECK_CALIBREPATH
|
||||
|
||||
# Add basic auth if requested
|
||||
if [ "$basicauthcreate" = "Yes" ];
|
||||
then
|
||||
|
|
Loading…
Add table
Reference in a new issue