From 58228b69d454c835e90a4eb3219ac6a6653d0836 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 16 Oct 2015 15:04:51 -0300 Subject: Initial code for webkit2png and wkhtmltopdf --- .gitmodules | 3 +++ README.mdwn | 6 ++++++ TODO.mdwn | 5 +++-- config.default | 2 ++ httracker | 1 + lib/httracker/functions | 10 ++++++++++ scuttler | 4 ++++ webkit2png | 1 + 8 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 .gitmodules create mode 160000 webkit2png diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c68f047 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "webkit2png"] + path = webkit2png + url = https://github.com/adamn/python-webkit2png diff --git a/README.mdwn b/README.mdwn index 6d9bbbf..dcee8e5 100644 --- a/README.mdwn +++ b/README.mdwn @@ -10,3 +10,9 @@ Usage Place this script somewhere and setup a cronjob like this: `*/5 * * * * /var/sites/cache/httruta/httracker &> /dev/null` + +Features +-------- + +- Integration with http://wkhtmltopdf.org +- Integration with [webkit2png](http://www.paulhammond.org/webkit2png/). diff --git a/TODO.mdwn b/TODO.mdwn index 259a6f9..847759e 100644 --- a/TODO.mdwn +++ b/TODO.mdwn @@ -4,5 +4,6 @@ TODO - OPML support to retrieve URLs from multiple feeds. - Support for other fetchers like youtube-dl and quvi. - Cleanup content no longer pointed in scuttle database. -- Integration with http://wkhtmltopdf.org -- Integration with [webkit2png](http://www.paulhammond.org/webkit2png/). +- Scuttler: + - Support to generate only an index of all URLs. + - Support to retrieve posts using the API. diff --git a/config.default b/config.default index 7b9543a..6b7f44b 100644 --- a/config.default +++ b/config.default @@ -10,3 +10,5 @@ GROUP="cache" DEPTH="1" EXT_DEPTH="0" SCUTTLE_BASE="/var/sites/links" +WEBKIT2PNG="1" +WKHTMLTOPDF="1" diff --git a/httracker b/httracker index f899f06..bf97a6c 100755 --- a/httracker +++ b/httracker @@ -7,6 +7,7 @@ source `dirname $0`/lib/httracker/functions || exit 1 # Parameters +DIRNAME="`dirname $0`" BASENAME="`basename $0`" FILE="$1" diff --git a/lib/httracker/functions b/lib/httracker/functions index d847769..ce3dd29 100644 --- a/lib/httracker/functions +++ b/lib/httracker/functions @@ -66,6 +66,16 @@ function httracker_get { rm -rf $TARGET fi + # Get a screenshot + if [ "$WEBKIT2PNG" == "1" ]; then + $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 + fi + # Fix permissions again if [ "`whoami`" != "$USER" ] && [ "`whoami`" == "root" ]; then echo "Fixing $TARGET permissions..." diff --git a/scuttler b/scuttler index e4f7419..3275712 100755 --- a/scuttler +++ b/scuttler @@ -6,6 +6,10 @@ # Load and initialize source `dirname $0`/lib/httracker/functions || exit 1 +# Parameters +DIRNAME="`dirname $0`" +BASENAME="`basename $0`" + # Other parameters SCUTTLEDIR="`basename $( find ${SCUTTLE_BASE} -maxdepth 1 -iname "SemanticScuttle-*" | head -n 1 )`" CONFIGFILE="${SCUTTLE_BASE}/${SCUTTLEDIR}/data/config.php" diff --git a/webkit2png b/webkit2png new file mode 160000 index 0000000..4a82a81 --- /dev/null +++ b/webkit2png @@ -0,0 +1 @@ +Subproject commit 4a82a81cb0fd95faac721792951bd15ea82a11b9 -- cgit v1.2.3