diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-03-25 19:14:04 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-03-25 19:14:04 -0300 |
commit | 567c3ea429d7d4f02ff8bff51f0a540dbcb8aed0 (patch) | |
tree | 2491e16826370b8cc5dd1349c914b1e7e5e14ce7 | |
parent | 0c025d8c41eb3271b6fabda8c4dd6c8f3d2fa33d (diff) | |
download | httruta-567c3ea429d7d4f02ff8bff51f0a540dbcb8aed0.tar.gz httruta-567c3ea429d7d4f02ff8bff51f0a540dbcb8aed0.tar.bz2 |
Enhance PDF output support
-rw-r--r-- | config.default | 3 | ||||
-rw-r--r-- | lib/httracker/functions | 19 |
2 files changed, 17 insertions, 5 deletions
diff --git a/config.default b/config.default index 265701b..f504087 100644 --- a/config.default +++ b/config.default @@ -11,4 +11,5 @@ DEPTH="1" EXT_DEPTH="0" SCUTTLE_BASE="/var/sites/links" WEBKIT2PNG="0" -WKHTMLTOPDF="0" +WKHTMLTOPDF="1" +WEBKIT2PDF="0" diff --git a/lib/httracker/functions b/lib/httracker/functions index ce3dd29..36286d5 100644 --- a/lib/httracker/functions +++ b/lib/httracker/functions @@ -67,13 +67,24 @@ function httracker_get { fi # Get a screenshot - if [ "$WEBKIT2PNG" == "1" ]; then - $DIRNAME/webkit2png/webkit2png/webkit2png.py -o $TARGET/screenshot.png "$url" + # https://github.com/paulhammond/webkit2png/ + # https://github.com/adamn/python-webkit2png + # https://snippets.aktagon.com/snippets/504-how-to-generate-screenshots-on-debian-linux-with-python-webkit2png + if [ "$WEBKIT2PNG" == "1" ] && which xvfb-run &> /dev/null; then + xvfb-run -a $DIRNAME/webkit2png/webkit2png/webkit2png.py -o $TARGET/screenshot.png "$url" fi # Build a PDF - if [ "$WKHTMLTOPDF" == "1" ] && which wkhtmltopdf &> /dev/null; then - wkhtmltopdf "$url" $TARGET/screenshot.pdf + if [ "$WKHTMLTOPDF" == "1" ] && which xvfb-run &> /dev/null && which wkhtmltopdf &> /dev/null; then + xvfb-run -a wkhtmltopdf "$url" $TARGET/screenshot.pdf + fi + + # See https://www.insecure.ws/linux/serverless_screenshot.html + # http://gfdsa.gfdsa.org/2012/08/15/making-web-pages-screenshots-with-webkit2png-flash-included/ + if [ ! -d "$TARGET/screenshot.pdf" ]; then + if [ "$WEBKIT2PDF" == "1" ] && which xvfb-run &> /dev/null && which webkit2pdf &> /dev/null; then + ( cd $TARGET && xvfb-run -a webkit2pdf "$url" && mv 0000.pdf screenshot.pdf ) + fi fi # Fix permissions again |