Ability to set gnusocial expire period from control panel
This commit is contained in:
parent
7d0f470389
commit
5db30ada00
|
@ -274,6 +274,40 @@ function gnusocial_set_title {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gnusocial_set_expire_months {
|
||||||
|
GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
|
||||||
|
read_config_param "GNUSOCIAL_EXPIRE_MONTHS"
|
||||||
|
|
||||||
|
data=$(tempfile 2>/dev/null)
|
||||||
|
trap "rm -f $data" 0 1 2 5 15
|
||||||
|
dialog --title $"GNU Social" \
|
||||||
|
--backtitle $"Freedombone Control Panel" \
|
||||||
|
--inputbox $'Set an expiry period for posts in months. Anything older will be deleted. Lower values help to keep the database size small and as fast as possible.' 12 60 "$GNUSOCIAL_EXPIRE_MONTHS" 2>$data
|
||||||
|
sel=$?
|
||||||
|
case $sel in
|
||||||
|
0)
|
||||||
|
new_expiry_months=$(<$data)
|
||||||
|
if [ ${#new_expiry_months} -gt 0 ]; then
|
||||||
|
# should contain no spaces
|
||||||
|
if [[ "$new_expiry_months" == *" "* ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# should be a number
|
||||||
|
re='^[0-9]+$'
|
||||||
|
if ! [[ $new_expiry_months =~ $re ]] ; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# set the new value
|
||||||
|
GNUSOCIAL_EXPIRE_MONTHS=$new_expiry_months
|
||||||
|
write_config_param "GNUSOCIAL_EXPIRE_MONTHS" "$GNUSOCIAL_EXPIRE_MONTHS"
|
||||||
|
expire_gnusocial_posts "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_EXPIRE_MONTHS"
|
||||||
|
dialog --title $"Set GNU Social post expiry period" \
|
||||||
|
--msgbox $"Expiry period set to $GNUSOCIAL_EXPIRE_MONTHS months" 6 60
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
function configure_interactive_gnusocial {
|
function configure_interactive_gnusocial {
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
|
@ -281,10 +315,11 @@ function configure_interactive_gnusocial {
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
trap "rm -f $data" 0 1 2 5 15
|
||||||
dialog --backtitle $"Freedombone Control Panel" \
|
dialog --backtitle $"Freedombone Control Panel" \
|
||||||
--title $"GNU Social" \
|
--title $"GNU Social" \
|
||||||
--radiolist $"Choose an operation:" 12 70 3 \
|
--radiolist $"Choose an operation:" 13 70 4 \
|
||||||
1 $"Set a background image" off \
|
1 $"Set a background image" off \
|
||||||
2 $"Set the title" off \
|
2 $"Set the title" off \
|
||||||
3 $"Exit" on 2> $data
|
3 $"Set post expiry period (currently $GNUSOCIAL_EXPIRE_MONTHS months)" off \
|
||||||
|
4 $"Exit" on 2> $data
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) return;;
|
1) return;;
|
||||||
|
@ -293,7 +328,8 @@ function configure_interactive_gnusocial {
|
||||||
case $(cat $data) in
|
case $(cat $data) in
|
||||||
1) gnusocial_set_background_image;;
|
1) gnusocial_set_background_image;;
|
||||||
2) gnusocial_set_title;;
|
2) gnusocial_set_title;;
|
||||||
3) break;;
|
3) gnusocial_set_expire_months;;
|
||||||
|
4) break;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,6 +258,40 @@ function postactiv_set_title {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function postactiv_set_expire_months {
|
||||||
|
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
||||||
|
read_config_param "POSTACTIV_EXPIRE_MONTHS"
|
||||||
|
|
||||||
|
data=$(tempfile 2>/dev/null)
|
||||||
|
trap "rm -f $data" 0 1 2 5 15
|
||||||
|
dialog --title $"PostActiv" \
|
||||||
|
--backtitle $"Freedombone Control Panel" \
|
||||||
|
--inputbox $'Set an expiry period for posts in months. Anything older will be deleted. Lower values help to keep the database size small and as fast as possible.' 12 60 "$POSTACTIV_EXPIRE_MONTHS" 2>$data
|
||||||
|
sel=$?
|
||||||
|
case $sel in
|
||||||
|
0)
|
||||||
|
new_expiry_months=$(<$data)
|
||||||
|
if [ ${#new_expiry_months} -gt 0 ]; then
|
||||||
|
# should contain no spaces
|
||||||
|
if [[ "$new_expiry_months" == *" "* ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# should be a number
|
||||||
|
re='^[0-9]+$'
|
||||||
|
if ! [[ $new_expiry_months =~ $re ]] ; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# set the new value
|
||||||
|
POSTACTIV_EXPIRE_MONTHS=$new_expiry_months
|
||||||
|
write_config_param "POSTACTIV_EXPIRE_MONTHS" "$POSTACTIV_EXPIRE_MONTHS"
|
||||||
|
expire_gnusocial_posts "$POSTACTIV_DOMAIN_NAME" "postactiv" "$POSTACTIV_EXPIRE_MONTHS"
|
||||||
|
dialog --title $"Set PostActiv post expiry period" \
|
||||||
|
--msgbox $"Expiry period set to $POSTACTIV_EXPIRE_MONTHS months" 6 60
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
function configure_interactive_postactiv {
|
function configure_interactive_postactiv {
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
|
@ -265,10 +299,11 @@ function configure_interactive_postactiv {
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
trap "rm -f $data" 0 1 2 5 15
|
||||||
dialog --backtitle $"Freedombone Control Panel" \
|
dialog --backtitle $"Freedombone Control Panel" \
|
||||||
--title $"PostActiv" \
|
--title $"PostActiv" \
|
||||||
--radiolist $"Choose an operation:" 12 70 3 \
|
--radiolist $"Choose an operation:" 13 70 4 \
|
||||||
1 $"Set a background image" off \
|
1 $"Set a background image" off \
|
||||||
2 $"Set the title" off \
|
2 $"Set the title" off \
|
||||||
3 $"Exit" on 2> $data
|
3 $"Set post expiry period (currently $POSTACTIV_EXPIRE_MONTHS months)" off \
|
||||||
|
4 $"Exit" on 2> $data
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) return;;
|
1) return;;
|
||||||
|
@ -277,7 +312,8 @@ function configure_interactive_postactiv {
|
||||||
case $(cat $data) in
|
case $(cat $data) in
|
||||||
1) postactiv_set_background_image;;
|
1) postactiv_set_background_image;;
|
||||||
2) postactiv_set_title;;
|
2) postactiv_set_title;;
|
||||||
3) break;;
|
3) postactiv_set_expire_months;;
|
||||||
|
4) break;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue