Screenshots.py
This script generates screenshots for the presentation slides.
from playwright.sync_api import sync_playwright
from pathlib import Path
# ↪️ Define URLs and filenames
= [
urls "https://github.com/maehr/open-research-data-template/",
# "https://github.com/new?template_name=open-research-data-template&template_owner=maehr",
# "https://codespaces.new/maehr/dh25-showcase",
"https://dokumentation.stadtgeschichtebasel.ch/",
"https://dokumentation.stadtgeschichtebasel.ch/sgb-figures/",
"https://mtwente.github.io/maxvogt-analysis/docs/workflow.html",
"https://mtwente.github.io/nordatlantisk-ft/report.html",
"https://mtwente.github.io/modelling-marti/docs/work.html",
"https://digihistch24.github.io/",
"https://dhbern.github.io/",
"https://dhbern.github.io/decoding-inequality-2025/",
"https://maehr.github.io/diskriminierungsfreie-metadaten/",
"https://maehr.github.io/one-template-to-rule-them-all/"
]= [
filenames "open_research_data_template.png",
# "open_research_data_template_repo.png",
# "open_research_data_template_codespace.png",
"dokumentation_stadtgeschichtebasel_ch.png",
"dokumentation_stadtgeschichtebasel_ch_sgb_figures.png",
"maxvogt_analysis.png",
"nordatlantisk_ft_report.png",
"modelling_marti.png",
"digihistch24.png",
"dhbern.png",
"decoding_inequality_2025.png",
"diskriminierungsfreie_metadaten.png",
"one_template_to_rule_them_all.png"
]
assert len(urls) == len(filenames), "URLs and filenames must match"
= Path("presentation/images/")
output_dir =True)
output_dir.mkdir(exist_ok
# Use MacBook Pro's native resolution and scale factor 2 for Retina
= {"width": 2940, "height": 1654}
viewport = 2 # high-resolution (Retina)
scale
with sync_playwright() as p:
= p.chromium.launch()
browser = browser.new_context(viewport=viewport, device_scale_factor=scale)
context for url, fname in zip(urls, filenames):
= context.new_page()
page ="networkidle")
page.goto(url, wait_until"document.body.style.zoom=2.0")
page.evaluate(
# Example: Click a button
# Replace 'button_selector' with the actual selector for the button
# page.click('button_selector')
# Example: Scroll down to a specific element
# Replace 'element_selector' with the actual selector for the element
# page.scroll_into_view('element_selector')
# Example: Scroll down by a certain amount
# page.evaluate("window.scrollBy(0, 1000)") # Scroll down by 1000 pixels
= output_dir / fname
path =path)
page.screenshot(pathprint(f"✅ Saved {path} for {url}")
browser.close()
The script uses playwright to take screenshots in different formats. These are used in the presentation slides.
[project]
name = "one-template-to-rule-them-all"
version = "0.1.0"
description = "Interactive Research Data Documentation with Quarto - presentation materials for DHTech Symposium at DH2025"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"playwright>=1.53.0",
]
It can be run in a GitHub Codespace or locally with uv.
uv run presentation/screenshots.py