]> gitweb.fluxo.info Git - httruta.git/commitdiff
Enhance PDF output support
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 25 Mar 2017 22:14:04 +0000 (19:14 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 25 Mar 2017 22:14:04 +0000 (19:14 -0300)
config.default
lib/httracker/functions

index 265701bfc9e7113475b8cc8cfd5d5c54112ec2c0..f504087674687d0bc940e3ea37740a18bdb8d657 100644 (file)
@@ -11,4 +11,5 @@ DEPTH="1"
 EXT_DEPTH="0"
 SCUTTLE_BASE="/var/sites/links"
 WEBKIT2PNG="0"
-WKHTMLTOPDF="0"
+WKHTMLTOPDF="1"
+WEBKIT2PDF="0"
index ce3dd29bb038bfadd862d7c335767a7db4d7bdc3..36286d5a4a71b72fd5c2ec5ca7d680852f24c940 100644 (file)
@@ -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