Make cutycapt options configurable
authorChristian Weiske <cweiske@cweiske.de>
Thu, 6 Nov 2014 20:33:15 +0000 (21:33 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Thu, 6 Nov 2014 20:33:15 +0000 (21:33 +0100)
README.rst
src/phancap/Adapter/Cutycapt.php
src/phancap/Config.php

index 102586c27f6f7c7faf75aff9777d431a849e8c5f..ca063f16042ed9b55ec33bd8c5f3242bef48f769 100644 (file)
@@ -126,6 +126,14 @@ Configuration variables
 
   ``true`` to allow access to anyone, ``false`` to disable it completely.
   ``array`` of username - secret key combinations otherwise.
 
   ``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``
 ``$disableSetup``
   Disable ``setup.php`` which will leak file system paths
 ``$redirect``
index a006a44574955ec4f3f6191b2e3e7097977a898c..13f972e22c8c3511d7a780f06cd131ae71acc536 100644 (file)
@@ -83,7 +83,16 @@ class Adapter_Cutycapt
         if ($format == 'jpg') {
             $format = 'jpeg';
         }
         if ($format == 'jpg') {
             $format = 'jpeg';
         }
+
         $maxWaitTime = 30;//seconds
         $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';
 
         $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 ($options->values['bheight'] !== null) {
             $cmd .= ' --min-height=' . $options->values['bheight'];
         }
+        if (strlen($parameters) > 0) {
+            $cmd .= ' ' . $parameters;
+        }
 
         $xvfbcmd = 'xvfb-run'
             . ' -e /dev/stdout'
 
         $xvfbcmd = 'xvfb-run'
             . ' -e /dev/stdout'
index b5194545e5ff9ccef0f91c906ec2c48db9b81e9e..b2d42b1dfefde141bfde8be217fd56002a68e296 100644 (file)
@@ -110,6 +110,11 @@ class Config
      */
     public $screenshotMinAge = 'PT1H';
 
      */
     public $screenshotMinAge = 'PT1H';
 
+    /**
+     * Cutycapt adapter options
+     */
+    public $cutycapt = array();
+
 
     /**
      * Initialize default values and loads configuration file paths
 
     /**
      * Initialize default values and loads configuration file paths