From 241452bab4bdcafa38a98c63e9c433cee7b2195a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Petazzoni?= Date: Sat, 4 Nov 2017 11:45:18 -0700 Subject: [PATCH] Add script to check images and show slide count --- slides/README.md | 9 +++++++++ slides/slidechecker.js | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 slides/slidechecker.js diff --git a/slides/README.md b/slides/README.md index 55e5f0f8..650d2d7d 100644 --- a/slides/README.md +++ b/slides/README.md @@ -45,3 +45,12 @@ and publish them to http://container.training/. Pull requests are automatically deployed to testing subdomains. I had no idea that I would ever say this about a static page hosting service, but it is seriously awesome. ⚡️💥 + + +## Extra bells and whistles + +You can run `./slidechecker foo.yml.html` to check for +missing images and show the number of slides in that deck. +It requires `phantomjs` to be installed. It takes some +time to run so it is not yet integrated with the publishing +pipeline. \ No newline at end of file diff --git a/slides/slidechecker.js b/slides/slidechecker.js new file mode 100755 index 00000000..71ef205c --- /dev/null +++ b/slides/slidechecker.js @@ -0,0 +1,21 @@ +#!/usr/bin/env phantomjs +var system = require('system'); +var filename = system.args[1]; +var url = 'file://' + system.env.PWD + '/' + filename; + +var page = require('webpage').create(); + +page.onResourceError = function(resourceError) { + console.log('ResourceError: ' + resourceError.url); +} + +console.log('Loading: ' + url); +page.open(url, function(status) { + console.log('Loaded: ' + url + '(' + status + ')'); + var slides = page.evaluate(function() { + return document.getElementsByClassName('remark-slide-container'); + }); + console.log('Number of slides: ' + slides.length); + console.log('Done: ' + url + '(' + status + ')'); + phantom.exit(); +});