Browse Source

Remove google links from edith app

Bob Mottram 7 years ago
parent
commit
92bf79c545
1 changed files with 31 additions and 0 deletions
  1. 31
    0
      src/freedombone-app-edith

+ 31
- 0
src/freedombone-app-edith View File

@@ -47,6 +47,33 @@ edith_variables=(MY_USERNAME
47 47
                  EDITH_CODE
48 48
                  DEFAULT_LANGUAGE)
49 49
 
50
+function remove_bad_links_edith {
51
+    read_config_param EDITH_DOMAIN_NAME
52
+
53
+    edith_dir=/var/www/$EDITH_DOMAIN_NAME/htdocs
54
+
55
+    # copy jquery locally
56
+    jquery_version='1.12.4'
57
+    if [ ! -f $edith_dir/jquery-${jquery_version}.js ]; then
58
+        cd $edith_dir
59
+        wget https://code.jquery.com/jquery-${jquery_version}.js
60
+        if [ -f $edith_dir/jquery-${jquery_version}.js ]; then
61
+            jquery_hash=$(sha256sum $edith_dir/jquery-${jquery_version}.js | awk -F ' ' '{print $1}')
62
+            if [[ "$jquery_hash" != '430f36f9b5f21aae8cc9dca6a81c4d3d84da5175eaedcf2fdc2c226302cb3575' ]]; then
63
+                echo $'Unexpected jquery hash value'
64
+                exit 6783653856
65
+            fi
66
+        else
67
+            echo $"Unable to download https://code.jquery.com/jquery-${jquery_version}.js"
68
+            exit 7384673583
69
+        fi
70
+    fi
71
+
72
+    sed -i "s|//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js|jquery-${jquery_version}.js|g" $edith_dir/templates/default.php
73
+    sed -i '/googleapi/d' $edith_dir/templates/remark.php
74
+    sed -i "s|//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js|jquery-${jquery_version}.js|g" $edith_dir/templates/html.php
75
+}
76
+
50 77
 function change_password_edith {
51 78
     curr_username="$1"
52 79
     new_user_password="$2"
@@ -140,6 +167,7 @@ function upgrade_edith {
140 167
     function_check set_repo_commit
141 168
     set_repo_commit /var/www/$EDITH_DOMAIN_NAME/htdocs "edith commit" "$EDITH_COMMIT" $EDITH_REPO
142 169
 
170
+    remove_bad_links_edith
143 171
     chown -R www-data:www-data /var/www/$EDITH_DOMAIN_NAME/htdocs
144 172
     chmod a+w /var/www/$EDITH_DOMAIN_NAME/htdocs/data
145 173
 }
@@ -414,6 +442,9 @@ function install_edith {
414 442
 
415 443
     set_completion_param "edith domain" "$EDITH_DOMAIN_NAME"
416 444
     set_completion_param "edith onion domain" "$EDITH_ONION_HOSTNAME"
445
+
446
+    remove_bad_links_edith
447
+
417 448
     chown -R www-data:www-data /var/www/$EDITH_DOMAIN_NAME/htdocs
418 449
     chmod a+w /var/www/$EDITH_DOMAIN_NAME/htdocs/data
419 450
     nginx_ensite $EDITH_DAEMON_NAME