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 shred -zu /home/$MY_USERNAME/.blog-index
fi 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 if [ -f /home/$MY_USERNAME/.ipfs-id ]; then
shred -zu /home/$MY_USERNAME/.ipfs-id shred -zu /home/$MY_USERNAME/.ipfs-id
fi fi

View File

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