From ea9a92cd7b0740a28b321c83f6082f2254d83b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 20 Mar 2015 14:47:01 +0100 Subject: [PATCH] totally automate production of mini screens However the result is currently buggy for Meyzieu and Montpellier (uncentered page content) (phantomjs 0.9.0). --- .../integrations-graphiques/capture.js | 12 +++++++ .../integrations-graphiques/generate.py | 34 ++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 static/img/sources/integrations-graphiques/capture.js diff --git a/static/img/sources/integrations-graphiques/capture.js b/static/img/sources/integrations-graphiques/capture.js new file mode 100644 index 0000000..7225d0b --- /dev/null +++ b/static/img/sources/integrations-graphiques/capture.js @@ -0,0 +1,12 @@ +var page = require('webpage').create(); +var system = require('system'); + +var address = system.args[1]; +var filename = system.args[2]; + +page.viewportSize = { width: 1100, height: 640 }; +page.clipRect = { top: 0, left: 0, width: page.viewportSize.width, height: page.viewportSize.height }; +page.open(address, function() { + page.render(filename); + phantom.exit(); +}); diff --git a/static/img/sources/integrations-graphiques/generate.py b/static/img/sources/integrations-graphiques/generate.py index 9d6d105..6f87c26 100644 --- a/static/img/sources/integrations-graphiques/generate.py +++ b/static/img/sources/integrations-graphiques/generate.py @@ -3,8 +3,33 @@ import os import subprocess +captures = [ + ('https://cournonterral.test-eservices.montpellier3m.fr/', + 'cournonterral.png'), + ('https://fabregues.eservices.montpellier3m.fr/', + 'fabregues.png'), + ('https://marcoussis.au-quotidien.com/etat-civil/copie-d-acte-de-naissance/', + 'marcoussis.png'), + ('https://meyzieu.au-quotidien.com/inscriptions/ramassage-des-accueils-de-loisirs-du-mercredi-inscription-mensuelle-1/', + 'meyzieu.png'), + ('https://eservices.montpellier3m.fr/', + 'montpellier.png'), + ('https://sussargues.test-eservices.montpellier3m.fr/', + 'sussargues.png'), + ('https://vendargues.test-eservices.montpellier3m.fr/', + 'vendargues.png'), + ('https://demarches.vincennes.fr/question/votre-question-jeunesse/', + 'vincennes.png'), + ] + svg_src = open('screen-with-capture.svg').read() -for filename in os.listdir('captures'): +for url, filename in captures: + print url + print 'creating capture' + subprocess.call(['phantomjs', '--ssl-protocol=any', + '--ignore-ssl-errors=yes', 'capture.js', url, 'captures/%s' % filename]) + + print 'putting it in a mini screen' svg_dst = svg_src.replace('xxx.png', 'captures/%s' % filename) svg_path = open('/tmp/.xxx.svg', 'w') svg_path.write(svg_dst) @@ -16,6 +41,13 @@ for filename in os.listdir('captures'): '--export-png', 'screen-%s' % filename, '--export-width', '250']) +filenames = [x[1] for x in captures] + + # gm montage screen-*.png -geometry +10+0 -tile 8x1 -background none ../screens.png # +10+0 <- 10 is the margin # 8x1 <- 8 is the number of images +print 'assembling mini screens' +subprocess.call(['gm', 'montage'] + ['screen-%s' % x for x in filenames] + + ['-geometry', '+10+0', '-tile', '%sx1' % len(captures), + '-background', 'none', '../../screens.png'])