| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #!/bin/bash
- # info: list web templates
- # options: USER [FORMAT]
- #
- # The function for obtaining the list of web templates available to a user.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Argument definition
- format=${1-shell}
- # Includes
- source $VESTA/func/main.sh
- source $VESTA/conf/vesta.conf
- # JSON list function
- json_list() {
- objects=$(echo "$templates" |wc -w)
- i=1
- echo '['
- for template in $templates; do
- if [ "$i" -lt "$objects" ]; then
- echo -e "\t\"$template\","
- else
- echo -e "\t\"$template\""
- fi
- (( ++i))
- done
- echo "]"
- }
- # SHELL list function
- shell_list() {
- echo "TEMPLATE"
- echo "--------"
- for template in $templates; do
- echo "$template"
- done
- }
- # PLAIN list function
- plain_list() {
- for template in $templates; do
- echo "$template"
- done
- }
- # CSV list function
- csv_list() {
- echo "TEMPLATE"
- for template in $templates; do
- echo "$template"
- done
- }
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- # Parsing templates
- templates=$(ls -v $WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/)
- templates=$(echo "$templates" |grep '\.tpl' |sed 's/\.tpl$//')
- # Listing data
- case $format in
- json) json_list ;;
- plain) plain_list ;;
- csv) csv_list ;;
- shell) shell_list ;;
- esac
- #----------------------------------------------------------#
- # Vesta #
- #----------------------------------------------------------#
- exit
|