w3mepub

Text-based EPUB reader
git clone git://efe.kim/w3mepub
Log | Files | Refs | README | LICENSE

w3mepub (605B)


      1 #!/bin/sh
      2 
      3 tmpdir=$(mktemp -d /tmp/w3mepub-XXXXXX)
      4 confdir=/usr/local/share/w3mepub
      5 export LESSKEY=${confdir}/less.conf
      6 unset LESS_IS_MORE
      7 unset LESSSECURE
      8 
      9 trap 'rm -r "$tmpdir"' 0 1 15
     10 
     11 xmltr() {
     12 	xsltproc --stringparam rootdir "${rootdir:-na}" \
     13 		"${confdir}/${1}.xsl" "${tmpdir}/${2}"
     14 }
     15 
     16 unzip -q "$1" -d "$tmpdir" || {
     17 	echo Cannot extract
     18 	exit 1
     19 }
     20 
     21 fullpath=$(xmltr fullpath META-INF/container.xml)
     22 title=$(xmltr title "$fullpath")
     23 abspath=${tmpdir}/${fullpath}
     24 rootdir=${abspath%/*}
     25 
     26 IFS="
     27 "
     28 w3m -config "${confdir}/w3m.conf" -T text/html \
     29 	-cols 65 -dump $(xmltr content "$fullpath") | \
     30 	less