Skip to content

Commit 3937afa

Browse files
author
Kristan Kenney
committed
Merge branch 'feature/themes' into main
2 parents 47c71f9 + f52c87a commit 3937afa

File tree

1 file changed

+21
-41
lines changed

1 file changed

+21
-41
lines changed

bin/v-list-sys-themes

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,63 +22,40 @@ source $HESTIA/conf/hestia.conf
2222

2323
# JSON list function
2424
json_list() {
25-
object1=$(echo "$themes" |wc -w)
26-
object2=$(echo "$themes_custom" |wc -w)
2725
i=1
2826
echo '['
29-
for theme in $themes; do
30-
if [ "$i" -lt "$object1" ]; then
27+
for theme in "${available_themes[@]}"; do
28+
if [ "$i" -lt "$theme_count" ]; then
3129
echo -e "\t\"$theme\","
3230
else
33-
if [ $object2 -gt 0 ]; then
34-
echo -e "\t\"$theme\","
35-
else
36-
echo -e "\t\"$theme\""
37-
fi
31+
echo -e "\t\"$theme\""
3832
fi
3933
(( ++i))
4034
done
41-
for custom_theme in $themes_custom; do
42-
if [ "$i" -lt "$object2" ]; then
43-
echo -e "\t\"$custom_theme\","
44-
else
45-
echo -e "\t\"$custom_theme\""
46-
fi
47-
(( ++i))
48-
done
49-
echo "]"
35+
echo ']'
5036
}
5137

5238
# SHELL list function
5339
shell_list() {
5440
echo "THEME"
55-
echo "------"
56-
for theme in $themes; do
57-
echo "$theme"
58-
done
59-
for custom_theme in $themes_custom; do
60-
echo "$custom_theme"
41+
echo "-----"
42+
for theme in "${available_themes[@]}"; do
43+
echo $theme
6144
done
6245
}
6346

6447
# PLAIN list function
6548
plain_list() {
66-
for theme in $themes; do
67-
echo "$theme"
68-
done
69-
for custom_theme in $themes_custom; do
70-
echo "$custom_theme"
49+
for theme in "${available_themes[@]}"; do
50+
echo $theme
7151
done
7252
}
7353

7454
# CSV list function
7555
csv_list() {
7656
echo "THEME"
77-
for theme in $themes; do
78-
echo "$theme"
79-
done
80-
for custom_theme in $themes_custom; do
81-
echo "$custom_theme"
57+
for theme in "${available_themes[@]}"; do
58+
echo $theme
8259
done
8360
}
8461

@@ -87,16 +64,19 @@ csv_list() {
8764
# Action #
8865
#----------------------------------------------------------#
8966

90-
# Parsing templates
67+
# Parse system provided themes
68+
provided_themes=$(ls -v $HESTIA/web/css/themes | grep '\.min.css' | sed 's/\.min.css$//')
9169

92-
# System provided themes
93-
themes=$(ls -v $HESTIA_THEMES/)
94-
themes=$(echo "$themes" | grep '\.min.css' | sed 's/\.min.css$//')
70+
# Parse custom themes
71+
custom_themes=$(ls -v $HESTIA/web/css/themes/custom/ | grep '\.css' | sed 's/\.css$//')
9572

96-
# Custom themes
97-
themes_custom=$(ls -v $HESTIA_THEMES_CUSTOM/)
98-
themes_custom=$(echo "$themes_custom" | grep '\.css' | sed 's/\.css$//')
73+
# Create array with all available themes
74+
for theme in $provided_themes $custom_themes; do
75+
available_themes=(${available_themes[@]} $theme)
76+
done
9977

78+
# Get count of themes (for proper JSON formatting)
79+
theme_count="${#available_themes[@]}"
10080

10181
# Listing data
10282
case $format in

0 commit comments

Comments
 (0)