Skip to content
Permalink
Browse files

Add missing files for new screenshot infra

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Mar 25, 2018
1 parent be97dd1 commit e63e33d825d3b44af291bb7cd4932ac635d6a4fa
Showing with 361 additions and 3 deletions.
  1. +1 −3 .gitignore
  2. +301 −0 site/package-lock.json
  3. +10 −0 site/pages/v8.rst
  4. +2 −0 site/setup-puppeteer.sh
  5. +45 −0 site/take_screenshot.js
  6. +1 −0 site/themes/bootstrap3
  7. +1 −0 site/v8
@@ -4,6 +4,7 @@ site/demo_sites
site/cache
site/builtin_themes
site/state_data.json
site/node_modules

# Created by https://www.gitignore.io/api/pydev,nikola,python,pycharm

@@ -174,7 +175,4 @@ ENV/
# Rope project settings
.ropeproject

# mkdocs documentation
/site

# End of https://www.gitignore.io/api/pydev,nikola,python,pycharm

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,10 @@
.. title: Version 8
.. slug: v8
.. date: 1970-01-01 00:00:00 UTC
.. category: version_page
.. post-list::
:sort: slug_sortable
:tags: v8
:post_type: pages
:template: theme_list.tmpl
@@ -0,0 +1,2 @@
#!/bin/bash
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 npm i --save puppeteer
@@ -0,0 +1,45 @@
const fs = require('fs');
const path = require('path');
const puppeteer = require('puppeteer');

// Simple error checking
var arg_count = process.argv.length - 1;
if (arg_count < 4 || arg_count > 5) {
console.log('Usage: take_screenshot.js HTML_FILE WIDTH HEIGHT IMAGE_PATH');
process.exit(1);
}

var executablePath = '';

var pathsToTest = [
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
'/usr/bin/chromium-browser',
'/usr/bin/google-chrome',
'/usr/bin/google-chrome-dev',
'/usr/bin/chromium'
];
var pathFound = false;

for (var i = 0; i < pathsToTest.length; i++) {
var executablePath = pathsToTest[i];
if (fs.existsSync(executablePath)) {
pathFound = true;
break;
}
}

if (!pathFound) {
console.log('Chrome(ium) not found. Please add it to take-screenshot.js.');
process.exit(1);
}

(async () => {
const browser = await puppeteer.launch({executablePath: executablePath});
const page = await browser.newPage();

await page.goto('file://' + path.resolve(process.argv[2]));
await page.setViewport({width: parseInt(process.argv[3]), height: parseInt(process.argv[4])});
await page.screenshot({path: process.argv[5], type: 'png', fullPage: true});

await browser.close();
})();

0 comments on commit e63e33d

Please sign in to comment.
You can’t perform that action at this time.