Remember previously selected blog theme

This commit is contained in:
Bob Mottram 2016-09-09 14:49:23 +01:00
parent 0b5cdc30bb
commit 196b953902
No known key found for this signature in database
GPG Key ID: 0452CC7CEA982E38
2 changed files with 20 additions and 4 deletions

View File

@ -786,6 +786,10 @@ function setup_ipfs {
shred -zu /home/$MY_USERNAME/.blog-index
fi
if [ -f /home/$MY_USERNAME/.blog-theme-index ]; then
shred -zu /home/$MY_USERNAME/.blog-theme-index
fi
if [ -f /home/$MY_USERNAME/.ipfs-id ]; then
shred -zu /home/$MY_USERNAME/.ipfs-id
fi

View File

@ -50,7 +50,7 @@ function ipfs_publish {
echo ''
echo $'Publishing to IPFS. This may take some time...'
OLD_STAT_FILE=/home/$MY_USERNAME/.old_stat.txt
OLD_STAT_FILE=/home/$USER/.old_stat.txt
NEW_STAT=$(stat -t $DIR_TO_CHECK)
echo $($IPFS_COMMAND add -rq /home/$USER/Public | tail -n 1) > $IPFS_PUBLIC
echo "$NEW_STAT" > $OLD_STAT_FILE
@ -171,13 +171,24 @@ function change_theme {
themelist=""
n=1
theme_index=0
curr_theme_index=
if [ -f /home/$USER/.blog-theme-index ]; then
curr_theme_index=$(cat /home/$USER/.blog-theme-index)
fi
for a in "${THEMES[@]}"
do
if [[ $a == "basic" ]]; then
themelist="$themelist $n $a on"
else
themelist="$themelist $n $a off"
is_selected='off'
if [ $curr_theme_index ]; then
if [ $n -eq $curr_theme_index ]; then
is_selected='on'
fi
else
if [[ $a == 'Just-Read' ]]; then
is_selected='on'
fi
fi
themelist="$themelist $n $a $is_selected"
n=$[n+1]
theme_index=$[theme_index+1]
done
@ -195,6 +206,7 @@ function change_theme {
255) exit 1;;
esac
CHOSEN_THEME_INDEX=$(cat $data)
echo "$CHOSEN_THEME_INDEX" > /home/$USER/.blog-theme-index
CHOSEN_THEME_INDEX=$((CHOSEN_THEME_INDEX - 1))
CHOSEN_THEME=${THEMES[$CHOSEN_THEME_INDEX]}