DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:snap

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:snap [2010-03-03 11:37] 145.242.11.3plugin:snap [2017-11-25 21:09] (current) Aleksandr
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description: Affiche un site sous forme de miniature / Displays a site as a snapshot+description: Displays a site as a snapshot (fr: Affiche un site sous forme de miniature)
 author     : Etienne M. author     : Etienne M.
 email      : emauvaisfr@yahoo.fr email      : emauvaisfr@yahoo.fr
Line 13: Line 13:
 tags       : media, images, links tags       : media, images, links
  
-^downloadurl: http://emauvaisfr.free.fr/dokuwiki/snap.tar.gz+downloadurl: http://emauvaisfr.free.fr/dokuwiki/snap.tar.gz
 bugtracker : bugtracker :
 sourcerepo : sourcerepo :
Line 20: Line 20:
  
 ===== Description ===== ===== Description =====
 +
   * helper: do the snapshot of a given URL (DokuWiki page ID or full URL). View [[#helper_reference|helper reference]].   * helper: do the snapshot of a given URL (DokuWiki page ID or full URL). View [[#helper_reference|helper reference]].
   * syntax: calls the helper to insert a snapshot into your pages using an [[#syntax|easy syntax]].   * syntax: calls the helper to insert a snapshot into your pages using an [[#syntax|easy syntax]].
Line 26: Line 27:
  
 ===== Requirements ===== ===== Requirements =====
 +
   * This plugin will only work on Linux (not the plugin itself, but the snapshot server...)   * This plugin will only work on Linux (not the plugin itself, but the snapshot server...)
-    * The whole snap process was tested on a Debian distribution v4.0.+    * The whole snap process was tested on a Debian distribution v.4.0.
     * Tell me if you make it work on a Windows box (or another)!     * Tell me if you make it work on a Windows box (or another)!
     * Use it at your own risks! ;-)     * Use it at your own risks! ;-)
Line 33: Line 35:
     * This may not be possible if your DokuWiki is hosted...     * This may not be possible if your DokuWiki is hosted...
  
-  * Softwares needed to do the snapshot:+  * Software needed to do the snapshot:
     * ''html2image'': the tool that does the URL snapshot.     * ''html2image'': the tool that does the URL snapshot.
       * See http://www.guangmingsoft.net/htmlsnapshot/html2image.htm       * See http://www.guangmingsoft.net/htmlsnapshot/html2image.htm
     * ''Xvfb'': a virtual X server.     * ''Xvfb'': a virtual X server.
-      * See http://en.wikipedia.org/wiki/Xvfb+      * See [[wp>Xvfb]]
     * ''convert'': an image processing command from ''ImageMagick'', that allows to resize and crop images (and much more).     * ''convert'': an image processing command from ''ImageMagick'', that allows to resize and crop images (and much more).
       * See http://www.imagemagick.org/script/convert.php       * See http://www.imagemagick.org/script/convert.php
Line 43: Line 45:
   * Software needed to set up the snap server:   * Software needed to set up the snap server:
     * ''netcat'': a small network software that does a lot of things, such as listen on a port and answer with a specified program.     * ''netcat'': a small network software that does a lot of things, such as listen on a port and answer with a specified program.
-      * See http://en.wikipedia.org/wiki/Netcat+      * See [[wp>Netcat]]
  
   * See [[#installation|this chapter]] for installation how-to.   * See [[#installation|this chapter]] for installation how-to.
Line 49: Line 51:
  
 ===== How it works? ===== ===== How it works? =====
 +
   * Some modules are needed to do the snapshot:   * Some modules are needed to do the snapshot:
   - A snapshot server (''server.sh'')   - A snapshot server (''server.sh'')
Line 62: Line 65:
  
   * Why is it so complicated?!   * Why is it so complicated?!
-    * Because when you try to call ''html2image'' directly from a php page, you get a ''pagination fault'' error.+    * Because when you try to call ''html2image'' directly from a PHP page, you get a ''pagination fault'' error.
  
-  * After the snapshot, the snap image is available as a ''.jpg'' file on the HD (into ''./data/snap'' for example). +  * After the snapshot, the snap image is available as a ''.jpg'' file on the hard drive (into ''./data/snap'' for example). 
-    * The name of this file keeps track of the url that was "snaped" and the snap size (ex: ''start_300x200.jpg'')+    * The name of this file keeps track of the URL that was "snapped" and the snap size (ex: ''start_300x200.jpg'')
     * A snap cache mechanism is used to avoid generating a snapshot over and over. If the snap is found on the drive, having the same dimensions and not too old (regarding ''$conf['cachetime']''), it is not generated again (unless you ask to force snapshot without using the cache (see [[#syntax|below]]))     * A snap cache mechanism is used to avoid generating a snapshot over and over. If the snap is found on the drive, having the same dimensions and not too old (regarding ''$conf['cachetime']''), it is not generated again (unless you ask to force snapshot without using the cache (see [[#syntax|below]]))
  
  
 ===== Important ===== ===== Important =====
 +
   * Be aware that people can read snap of pages they may not have right to access (this is due to snap caching). However, the snap is normally small enough to prevent a comfortable reading ;-)   * Be aware that people can read snap of pages they may not have right to access (this is due to snap caching). However, the snap is normally small enough to prevent a comfortable reading ;-)
-  * If your DokuWiki is not open for reading to everyone (use of authentication), you must configure the helper to add login parameters to the url to snap. See the ''helper.php'' file to do this right. +  * If your DokuWiki is not open for reading to everyone (use of authentication), you must configure the helper to add login parameters to the URL to snap. See the ''helper.php'' file to do this right. 
-    * It is recommended to use [[:tips:phashlogin|this tip]] to avoid clear password into the urls, but an password hash instead.+    * It is recommended to use [[:tips:phashlogin|this tip]] to avoid clear password into the URLs, but an password hash instead.
   * By now, the snap server and the DokuWiki server have to be on the same computer.   * By now, the snap server and the DokuWiki server have to be on the same computer.
     * A next version will try to make it possible to have separate computers.     * A next version will try to make it possible to have separate computers.
Line 79: Line 83:
  
 ===== Installation ===== ===== Installation =====
-  * Given examples are valid for a linux Debian v4.0 distribution.+ 
 +  * Given examples are valid for a Linux Debian v4.0 distribution.
  
 ==== html2image ==== ==== html2image ====
 +
   * As user ''root'', install ''html2image'' into ''/usr/lib/html2image'' for example (download it here: http://www.guangmingsoft.net/htmlsnapshot/html2image.htm)   * As user ''root'', install ''html2image'' into ''/usr/lib/html2image'' for example (download it here: http://www.guangmingsoft.net/htmlsnapshot/html2image.htm)
   * Configure the proxy options into ''./html2image/greprefs/all.js''. Example :<code javascript>   * Configure the proxy options into ''./html2image/greprefs/all.js''. Example :<code javascript>
Line 92: Line 98:
  
 ==== Xvfb ==== ==== Xvfb ====
 +
   * Verify if ''Xvfb'' is installed (''Xvfb -'' -> doit afficher la liste des options)   * Verify if ''Xvfb'' is installed (''Xvfb -'' -> doit afficher la liste des options)
     * If not: ''apt-get install xvfb''     * If not: ''apt-get install xvfb''
Line 97: Line 104:
  
 ==== Test if html2image is working ==== ==== Test if html2image is working ====
 +
   * Run ''Xvfb :1 -screen 0 640x480x24 -nolisten tcp -fp /usr/share/fonts/X11/misc&'' (provide another ''fp'' if your fonts are elsewhere (''fp=font path'')   * Run ''Xvfb :1 -screen 0 640x480x24 -nolisten tcp -fp /usr/share/fonts/X11/misc&'' (provide another ''fp'' if your fonts are elsewhere (''fp=font path'')
   * Define the DISPLAY variable: ''export DISPLAY=:1''   * Define the DISPLAY variable: ''export DISPLAY=:1''
Line 104: Line 112:
  
 ==== netcat ==== ==== netcat ====
 +
   * Verify that ''nc'' is installed (''nc -h'' -> v1.10)   * Verify that ''nc'' is installed (''nc -h'' -> v1.10)
     * If not: ''apt-get install netcat''     * If not: ''apt-get install netcat''
  
 ==== convert ==== ==== convert ====
 +
   * Verify that ''convert'' is installed (''convert -version'' -> v6.2.4)   * Verify that ''convert'' is installed (''convert -version'' -> v6.2.4)
     * If not: ''apt-get install imagemagick''     * If not: ''apt-get install imagemagick''
Line 113: Line 123:
  
 ==== snap plugin ==== ==== snap plugin ====
 +
   * Use the Plugin Manager to install the snap plugin (see download at the top of this page).   * Use the Plugin Manager to install the snap plugin (see download at the top of this page).
  
 ===== Configuration ===== ===== Configuration =====
 +
   * Still as user ''root'':   * Still as user ''root'':
     * Create this directory ''/var/www/wiki/data/snap'' (for example)     * Create this directory ''/var/www/wiki/data/snap'' (for example)
Line 128: Line 140:
  
 ==== Test ==== ==== Test ====
 +
   * Add this into your playground page: <nowiki>{{[[start]]}}</nowiki>   * Add this into your playground page: <nowiki>{{[[start]]}}</nowiki>
-  * → The snapshot must appear. +  * -> The snapshot must appear.
- +
  
  
 ===== Syntax ===== ===== Syntax =====
 +
   * Like a link (''<nowiki>[[site_url]]</nowiki>'') changed into a picture (''<nowiki>{{picture_url}}</nowiki>'') -> ''<nowiki>{{[[site_url]]}}</nowiki>''   * Like a link (''<nowiki>[[site_url]]</nowiki>'') changed into a picture (''<nowiki>{{picture_url}}</nowiki>'') -> ''<nowiki>{{[[site_url]]}}</nowiki>''
     * The site url can be a "normal" one ([[http://www.dokuwiki.org]]) or a DokuWiki page ID (''start'', ''fr:plugin:snap'', aso...)     * The site url can be a "normal" one ([[http://www.dokuwiki.org]]) or a DokuWiki page ID (''start'', ''fr:plugin:snap'', aso...)
Line 148: Line 160:
  
 ===== Notes ===== ===== Notes =====
 +
   * The default snap size is 200x150 pixels.   * The default snap size is 200x150 pixels.
   * There are also maxWidth and maxHeight parameters to avoid too big snaps (400x300).   * There are also maxWidth and maxHeight parameters to avoid too big snaps (400x300).
Line 154: Line 167:
  
 ===== Helper reference ===== ===== Helper reference =====
 +
   * The getSnap() function is used to do the snapshot of a site.   * The getSnap() function is used to do the snapshot of a site.
     * Parameters:     * Parameters:
-      * Url to snap or DokuWiki page ID (required)+      * URL to snap or DokuWiki page ID (required)
       * Snap width (optional)       * Snap width (optional)
       * Snap height (optional)       * Snap height (optional)
Line 164: Line 178:
     * Returns an array with:     * Returns an array with:
       * The path and name of the snapshot.       * The path and name of the snapshot.
-      * The page title (if a DokuWiki page id was submited). +      * The page title (if a DokuWiki page id was submitted). 
-      * The target frame for the link to the "snaped" site.+      * The target frame for the link to the "snapped" site.
     * All the snap object properties are also available (see below).     * All the snap object properties are also available (see below).
  
Line 198: Line 212:
     [snapPorts] => 8888 8889 8890 8891 8892                            //Snap server port(s).     [snapPorts] => 8888 8889 8890 8891 8892                            //Snap server port(s).
     [snapTimeout] => 5                                                 //Max duration for a snap (seconds).     [snapTimeout] => 5                                                 //Max duration for a snap (seconds).
-    [tryTimeout] => 3                                                  //Max retries to connect snap serveur.+    [tryTimeout] => 3                                                  //Max retries to connect snap server.
     [checkCache] => 1                                                  //Use snap cache (true/false).     [checkCache] => 1                                                  //Use snap cache (true/false).
     [width] => 200                                                     //Snap width.     [width] => 200                                                     //Snap width.
Line 220: Line 234:
 Output image :/var/www/wiki/data/pages/../snap/start_200x150.jpg Output image :/var/www/wiki/data/pages/../snap/start_200x150.jpg
 content size:1280X1281 content size:1280X1281
-Convert html to image succeeds+Convert HTML to image succeeds
 Resize 200 Resize 200
 Crop 200x150+0+0 Crop 200x150+0+0
Line 228: Line 242:
                                                                        //Can be greater than the snap duration itself if more than one retry was done to connect the snap server.                                                                        //Can be greater than the snap duration itself if more than one retry was done to connect the snap server.
     [tries] => 1                                                       //Tries to connect the snap server.     [tries] => 1                                                       //Tries to connect the snap server.
-    [url] => http://myDokuwikiServer/wiki/doku.php?id=start            //"Snaped" page address.+    [url] => http://myDokuwikiServer/wiki/doku.php?id=start            //"Snapped" page address.
  
     //Inherited properties ------------------------------------------------------------------------------------------     //Inherited properties ------------------------------------------------------------------------------------------
Line 249: Line 263:
  
 ===== Version history ===== ===== Version history =====
 +
   * 2008-10-17: first one!   * 2008-10-17: first one!
  
  
 ===== Discussion ===== ===== Discussion =====
 +
   * Tell me...   * Tell me...
  
plugin/snap.txt · Last modified: 2017-11-25 21:09 by Aleksandr

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki