Ver código fonte

Select mesh blog theme using zenity

Bob Mottram 7 anos atrás
pai
commit
db3cc4f5af
2 arquivos alterados com 27 adições e 28 exclusões
  1. 26
    27
      src/freedombone-mesh-blog
  2. 1
    1
      src/freedombone-mesh-visit-site

+ 26
- 27
src/freedombone-mesh-blog Ver arquivo

@@ -41,6 +41,13 @@ CURRENT_BLOG_INDEX=/home/$USER/.blog-index
41 41
 BLOG_EDITOR='pluma'
42 42
 DEFAULT_BLOG_TITLE=$"Freedombone Blog"
43 43
 
44
+function remove_bad_blog_links {
45
+    current_theme=$1
46
+    if [ -f $BLOG_PATH/themes/$current_theme/static/css/style.css ]; then
47
+        sed -i '/googleapi/d' $BLOG_PATH/themes/$current_theme/static/css/style.css
48
+    fi
49
+}
50
+
44 51
 function ipfs_publish {
45 52
     DIR_TO_CHECK=/home/$USER/Public
46 53
     if [ ! -d $DIR_TO_CHECK ]; then
@@ -165,44 +172,36 @@ function change_theme {
165 172
         THEMES+=("$THEME_NAME")
166 173
     done
167 174
 
168
-    themelist=""
169 175
     n=1
170
-    theme_index=0
171 176
     curr_theme_index=
172 177
     if [ -f /home/$USER/.blog-theme-index ]; then
173 178
         curr_theme_index=$(cat /home/$USER/.blog-theme-index)
174 179
     fi
180
+    if [ -f /tmp/.blog-themes ]; then
181
+        rm /tmp/.blog-themes
182
+    fi
175 183
     for a in "${THEMES[@]}"
176 184
     do
177
-        is_selected='off'
178
-        if [ $curr_theme_index ]; then
179
-            if [ $n -eq $curr_theme_index ]; then
180
-                is_selected='on'
181
-            fi
182
-        else
183
-            if [[ "$a" == 'nice-blog' ]]; then
184
-                is_selected='on'
185
-            fi
186
-        fi
187
-
188
-        themelist="$themelist $n $a $is_selected"
185
+        echo "$n $a" >> /tmp/.blog-themes
189 186
         n=$[n+1]
190
-        theme_index=$[theme_index+1]
191 187
     done
192 188
 
193
-    data=$(tempfile 2>/dev/null)
194
-    trap "rm -f $data" 0 1 2 5 15
195
-    dialog --backtitle $"Freedombone Mesh" \
196
-           --title $"Select Blog Theme" \
197
-           --radiolist $'Choose:' \
198
-           80 40 20 $themelist 2> $data
189
+    CHOSEN_THEME_INDEX=$(
190
+    cat /tmp/.blog-themes | \
191
+        awk -F ' ' '{
192
+        for(i=1;i<=NF;i++){
193
+            print $i;
194
+        }
195
+}' | \
196
+        zenity --list \
197
+           --title=$'Select Blog Theme' \
198
+           --column=$'Index' --column=$'Theme' \
199
+           --print-column=1 --hide-column=1 --width=300 --height=400)
200
+    rm /tmp/.blog-themes
201
+    if [ ! $CHOSEN_THEME_INDEX ]; then
202
+        exit 1
203
+    fi
199 204
 
200
-    sel=$?
201
-    case $sel in
202
-        1) exit 1;;
203
-        255) exit 1;;
204
-    esac
205
-    CHOSEN_THEME_INDEX=$(cat $data)
206 205
     echo "$CHOSEN_THEME_INDEX" > /home/$USER/.blog-theme-index
207 206
     CHOSEN_THEME_INDEX=$((CHOSEN_THEME_INDEX - 1))
208 207
 

+ 1
- 1
src/freedombone-mesh-visit-site Ver arquivo

@@ -96,7 +96,7 @@ else
96 96
            --column='Username' --column='Tox ID' \
97 97
            --print-column=2 --hide-column=2 --width=300 --height=400)
98 98
     if [ ! $TOX_ID ]; then
99
-    exit 0
99
+        exit 0
100 100
     fi
101 101
     IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}')
102 102
     pkill $BROWSER