Skip to content

Instantly share code, notes, and snippets.

@oquno
Created February 23, 2011 10:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oquno/840249 to your computer and use it in GitHub Desktop.
Save oquno/840249 to your computer and use it in GitHub Desktop.
# /bin/sh
if [ -z "$1" ];
then
echo "url parameter is required."
exit
fi
HOMEDIR="/home/oquno/tokindle"
SAVEDIR="${HOMEDIR}/savedpages"
KINDLEGEN="${HOMEDIR}/kindlegen"
RUBY="/usr/bin/ruby1.8"
# メール添付して送るスクリプト
RUBYMAIL="${HOMEDIR}/mail.rb"
# kconvとか使って文字コード変えたりencoding=の部分変えたりする
TOUTF8="${HOMEDIR}/toutf8.rb"
TIME=`date "+%s"`
echo ${TIME}
INDEX="${SAVEDIR}/${TIME}/index.html"
URL=$1
echo ${URL}
FILENAME=`echo "${URL}" | sed -e "s/^.*\///"`
echo ${#FILENAME}
if [ -n "${FILENAME}" ]
then
echo "not index file"
else
FILENAME="index.html"
fi
HTML="${SAVEDIR}/${TIME}/${FILENAME}"
MOBI="${TIME}.mobi"
mvcommand="mv ${HTML} ${INDEX}"
charsetcommand="${RUBY} ${TOUTF8} ${INDEX}"
gencommand="${KINDLEGEN} ${INDEX} -o ${MOBI}"
sizematchcommand="find ${SAVEDIR}/ -name \"${MOBI}\" -size -5M"
sendcommand="${RUBY} ${RUBYMAIL} ${TIME}/${MOBI}"
mvcommand2="mv ${TIME}/${MOBI} ${SAVEDIR}/sent/"
rmcommand="rm -rf ${TIME}"
echo "html path ${HTML}"
cd $SAVEDIR
pavuk -singlepage -index_name index.html -fnrules F "*" "${TIME}/%n" -quiet -disable_html_tag 'embed' -disable_html_tag 'object' -disable_html_tag 'script' -disable_html_tag 'link' "${URL}"
echo "${mvcommand}"
${mvcommand}
echo "${charsetcommand}"
${charsetcommand}
echo "${gencommand}"
${gencommand}
echo "${sizematchcommand}"
SIZEMATCH=`${sizematchcommand}`
echo ${SIZEMATCH}
if [ -n "${SIZEMATCH}" ]
then
echo "too large"
else
echo "${sendcommand}"
${sendcommand}
fi
echo "${mvcommand2}"
${mvcommand2}
echo "${rmcommand}"
${rmcommand}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment