aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-03-25 20:43:16 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-03-25 20:43:16 -0300
commit5a4c3a1a97d64cccb0fa9cfe9b5ba17fb3abcee3 (patch)
treed8040137d8f69412fb6206ce69c801e1c01aad95
parent567c3ea429d7d4f02ff8bff51f0a540dbcb8aed0 (diff)
downloadhttruta-5a4c3a1a97d64cccb0fa9cfe9b5ba17fb3abcee3.tar.gz
httruta-5a4c3a1a97d64cccb0fa9cfe9b5ba17fb3abcee3.tar.bz2
Support for saving URL as a PNG using wkhtmltoimage
-rw-r--r--config.default1
-rw-r--r--lib/httracker/functions25
2 files changed, 17 insertions, 9 deletions
diff --git a/config.default b/config.default
index f504087..258c8c8 100644
--- a/config.default
+++ b/config.default
@@ -12,4 +12,5 @@ EXT_DEPTH="0"
SCUTTLE_BASE="/var/sites/links"
WEBKIT2PNG="0"
WKHTMLTOPDF="1"
+WKHTMLTOIMAGE="1"
WEBKIT2PDF="0"
diff --git a/lib/httracker/functions b/lib/httracker/functions
index 36286d5..7d3b4b5 100644
--- a/lib/httracker/functions
+++ b/lib/httracker/functions
@@ -66,19 +66,16 @@ function httracker_get {
rm -rf $TARGET
fi
- # Get a screenshot
- # 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
+ # Save as PDF
if [ "$WKHTMLTOPDF" == "1" ] && which xvfb-run &> /dev/null && which wkhtmltopdf &> /dev/null; then
xvfb-run -a wkhtmltopdf "$url" $TARGET/screenshot.pdf
fi
+ # Save as PNG
+ if [ "$WKHTMLTOIMAGE" == "1" ] && which xvfb-run &> /dev/null && which wkhtmltoimage &> /dev/null; then
+ xvfb-run -a wkhtmltoimage "$url" $TARGET/screenshot.png
+ 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
@@ -87,6 +84,16 @@ function httracker_get {
fi
fi
+ # Get a screenshot
+ # 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 [ ! -d "$TARGET/screenshot.png" ]; then
+ if [ "$WEBKIT2PNG" == "1" ] && which xvfb-run &> /dev/null; then
+ xvfb-run -a $DIRNAME/webkit2png/webkit2png/webkit2png.py -o $TARGET/screenshot.png "$url"
+ fi
+ fi
+
# Fix permissions again
if [ "`whoami`" != "$USER" ] && [ "`whoami`" == "root" ]; then
echo "Fixing $TARGET permissions..."