From 6c6604ab9240617f5d67b75586930eadb2bfc8d5 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 6 Nov 2014 21:33:15 +0100 Subject: [PATCH] Make cutycapt options configurable --- README.rst | 8 ++++++++ src/phancap/Adapter/Cutycapt.php | 12 ++++++++++++ src/phancap/Config.php | 5 +++++ 3 files changed, 25 insertions(+) diff --git a/README.rst b/README.rst index 102586c..ca063f1 100644 --- a/README.rst +++ b/README.rst @@ -126,6 +126,14 @@ Configuration variables ``true`` to allow access to anyone, ``false`` to disable it completely. ``array`` of username - secret key combinations otherwise. +``$cutycapt['parameters']`` + Additional command line parameters for cutycapt. + Can be used to e.g. enable browser plugins: + + ``$cutycapt['parameters'] = '--plugins=on';`` +``$cutycapt['maxWaitTime']`` + Maximal time in seconds to wait for cutycapt to finish rendering. + Defaults to 30 seconds. ``$disableSetup`` Disable ``setup.php`` which will leak file system paths ``$redirect`` diff --git a/src/phancap/Adapter/Cutycapt.php b/src/phancap/Adapter/Cutycapt.php index a006a44..13f972e 100644 --- a/src/phancap/Adapter/Cutycapt.php +++ b/src/phancap/Adapter/Cutycapt.php @@ -83,7 +83,16 @@ class Adapter_Cutycapt if ($format == 'jpg') { $format = 'jpeg'; } + $maxWaitTime = 30;//seconds + if (isset($this->config->cutycapt['maxWaitTime'])) { + $maxWaitTime = (int) $this->config->cutycapt['maxWaitTime']; + } + + $parameters = ''; + if (isset($this->config->cutycapt['parameters'])) { + $parameters = $this->config->cutycapt['parameters']; + } $serverNumber = $this->getServerNumber($options); $tmpPath = $img->getPath() . '-tmp'; @@ -96,6 +105,9 @@ class Adapter_Cutycapt if ($options->values['bheight'] !== null) { $cmd .= ' --min-height=' . $options->values['bheight']; } + if (strlen($parameters) > 0) { + $cmd .= ' ' . $parameters; + } $xvfbcmd = 'xvfb-run' . ' -e /dev/stdout' diff --git a/src/phancap/Config.php b/src/phancap/Config.php index b519454..b2d42b1 100644 --- a/src/phancap/Config.php +++ b/src/phancap/Config.php @@ -110,6 +110,11 @@ class Config */ public $screenshotMinAge = 'PT1H'; + /** + * Cutycapt adapter options + */ + public $cutycapt = array(); + /** * Initialize default values and loads configuration file paths -- 2.30.2