-
-
Save xufan6/4476048 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
SRC=/home/xf/git/Hotot/data/ | |
DEST=/opt/www/hotot/ | |
echo "\033[1;31;40m[i]Sync ...\033[0m" | |
# ignore .*.swp, .hgignore, etc | |
rsync -av --exclude '.*.*' --exclude '*.coffee' --exclude 'test*' $SRC $DEST | |
# replace conf.vars.platform, key and secret | |
echo "\033[1;31;40m[i] Replace platform, key and secret ...\033[0m" | |
sed -i "s/'platform': '\w*'/'platform': 'Web'/g" ${DEST}js/conf.js | |
sed -i "s/'consumer_key': '\w*'/'consumer_key': '604L17uwIwWsT1TIyjBTQA'/g" ${DEST}js/conf.js | |
sed -i "s/'consumer_secret': '\w*'/'consumer_secret': 'eB7cjPzO9QGZi50jpdrlIPtpPvlKkdt18uahit5oYE'/g" ${DEST}js/conf.js | |
echo "\033[1;31;40m[i] Done!\033[0m" | |
## ########################### | |
cat >> ${DEST}js/hotot.js <<OOO | |
if (conf.vars.platform === 'Web') { | |
var URL = document.URL.replace(/\/[^\/]+$/, '/'); | |
window.XMLHttpRequest.prototype.open_ = window.XMLHttpRequest.prototype.open; | |
window.XMLHttpRequest.prototype.open = function(method, url, async, user, password) { | |
url = url.replace('https://', '/'); | |
url = url.replace('http://', '/'); | |
return this.open_(method, url, async, user, password); | |
} | |
ui.PinDlg.set_auth_url_ = ui.PinDlg.set_auth_url; | |
ui.PinDlg.set_auth_url = function(url){ | |
return ui.PinDlg.set_auth_url_(url.replace('https://api.twitter.com/', URL + 'itap/')); | |
} | |
} | |
OOO | |
## html5 cache | |
( | |
cd ${DEST:-.} | |
echo -e 'CACHE MANIFEST\n' > cache.manifest | |
echo -e 'NETWORK:\n*\n' >> cache.manifest | |
echo 'CACHE:' >> cache.manifest | |
find . -type f | grep -Ev '^\./itap|\.gz$|cache\.manifest|cache\.html|index\.html' | sed 's/^\.\///; s/ /%20/g' >> cache.manifest | |
echo "# `date -R`" >> cache.manifest | |
sed -i 's/<html.*>/<html lang="en" manifest="cache.manifest">/' index.html | |
mv index.html hotot.html | |
echo '<html><head><meta http-equiv="no-cache" /><title>Hotot</title></head><frameset><frame src="hotot.html"></frameset></html>' > index.html | |
) | |
sed -i "s/'use_alt_reply': \w*/'use_alt_reply': true/g" ${DEST}js/conf.js | |
convert -quality 30 ${DEST}/image/welcome_bg.jpg ${DEST}/image/welcome_bg.jpg | |
which uglifycss && which sponge && find "$DEST" -name '*.css' -exec sh -c 'uglifycss "{}" |sponge "{}" ' \; | |
which uglifyjs && find "$DEST" -name '*.js' -exec uglifyjs --overwrite "{}" \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment