voxmedia / autotune

Platform for reusable news tools
BSD 3-Clause "New" or "Revised" License
415 stars 37 forks source link

Multiple screenshots #436

Closed ryanmark closed 5 years ago

ryanmark commented 5 years ago

Add support for taking screenshots for all html pages in a deployed project. Screenshot functionality still requires phantomjs to be installed on your build server.

This adds a new field to autotune-config.json: screenshots. This field in the config file is optional, and will default to the value index. The previous behavior of the screenshot functionality is the same as the default value index.

The screenshots field has 3 possible values:

Where do the screenshots go?

Screenshots are saved to a screenshots path in your project. There are 6 screenshots generated for each page.

Screenshots for the top-level index.html file will follow the form:

screenshots/screenshot_s@2.png
screenshots/screenshot_s.png
screenshots/screenshot_m@2.png
screenshots/screenshot_m.png
screenshots/screenshot_l.png
screenshots/screenshot_l@2.png

For screenshots beyond the top-level index, the path to the html file will be converted to a slug and prefixed to the screenshot filename. So for example, a page with the name /page2/index.html will have screenshots named:

screenshots/page2_screenshot_s@2.png
screenshots/page2_screenshot_s.png
screenshots/page2_screenshot_m@2.png
screenshots/page2_screenshot_m.png
screenshots/page2_screenshot_l.png
screenshots/page2_screenshot_l@2.png

Similarly, a page with the name /page2.html will have the same slug as /page2/index.html and will have the same screenshot filenames generated.

Warning: screenshots take a while to generate so be careful with this feature on large projects.