Created
April 18, 2012 13:55
-
-
Save shellexy/2413736 to your computer and use it in GitHub Desktop.
生成网页版 hotot
This file contains hidden or 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=$PWD/data/ | |
DEST=$PWD/web.hotot.org/ | |
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 yui-compressor && find "$DEST" -name '*.css' -exec yui-compressor -o "{}" "{}" \; | |
which uglifyjs && find "$DEST" -name '*.js' -exec uglifyjs --overwrite "{}" \; |
跑题下,错误代码大概还是用 404 比较好些,已经删除?
402 的话有这个是用来牟利的嫌疑?
虽然我自己是用的 401
啊呜…402是我昨天耍宝耍213,自己弄着玩儿的……
配置文件直接粘贴过来了……没想到居然还遗漏了一处402没改回去
已经改了w
另外yui-compressor 和 uglifyjs的相关也做了更新。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
赞下阿喵
噢,是酱紫的,debian/ubuntu 里可以直接 apt 安装 yui-compressor 和 uglifyjs
或许需要再强调下这俩是可选的?尤其是 java 程序实在有些那啥,
不过如果装过 nodejs 的话,可以选择用无需 java 的 uglifycss 来压缩 css