chore: updates

* Update `run` tasks to use the Nix Flake instead of Docker.
* Output PDFs into a `dist` directory and name them as the talk name.
* Move the stylesheets into a common place.
This commit is contained in:
Oliver Davies 2023-10-11 20:00:46 +01:00
parent d9f3cae654
commit 1f271a2655
5 changed files with 346 additions and 27 deletions

1
.gitignore vendored
View file

@ -4,6 +4,7 @@
# rst2df. # rst2df.
/**/*.pdf /**/*.pdf
/**/*.rst.build_temp /**/*.rst.build_temp
/dist/
# pdfpc. # pdfpc.
/**/*.pdfpc /**/*.pdfpc

View file

@ -12,7 +12,11 @@
formatter = pkgs.nixpkgs-fmt; formatter = pkgs.nixpkgs-fmt;
devshells.default = { devshells.default = {
packages = with pkgs; [ python310Packages.rst2pdf ]; packages = with pkgs; [
pdfpc
python310Packages.rst2pdf
tree
];
}; };
}; };
}; };

45
run
View file

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
@ -6,8 +6,9 @@ PDF_FILENAME=slides.pdf
RST_FILENAME=slides.rst RST_FILENAME=slides.rst
THUMBNAIL_FILENAME=thumbnail.jpg THUMBNAIL_FILENAME=thumbnail.jpg
function clean:all { function clean {
# Clean all generated files. mkdir -p dist
rm -fr dist/*
find . \ find . \
-type f \( -name "${PDF_FILENAME}*" -o -name *.build_temp -o -name ${THUMBNAIL_FILENAME} \) \ -type f \( -name "${PDF_FILENAME}*" -o -name *.build_temp -o -name ${THUMBNAIL_FILENAME} \) \
@ -23,37 +24,28 @@ function help {
} }
function pdf:generate { function pdf:generate {
# Generate a new PDF file.
DIRECTORY_NAME=$1 DIRECTORY_NAME=$1
shift 1 shift 1
pushd "${DIRECTORY_NAME}"
docker run --rm -it \ rst2pdf "${RST_FILENAME}" \
-v $HOME/.local/share/fonts:/usr/share/fonts \ --break-level 1 \
-v $PWD/${DIRECTORY_NAME}:/rst2pdf \ -e preprocess \
-w /rst2pdf \ --fit-background-mode scale \
opdavies/rst2pdf \ --font-path ../fonts \
${RST_FILENAME} \ --output "../dist/${DIRECTORY_NAME}.pdf" \
--break-level 1 \ --stylesheets ../styles/style-light,tango \
--extension-module preprocess \ "${@}"
--fit-background-mode scale \
--font-path /usr/share/fonts \ popd
--output ${PDF_FILENAME} \ tree dist
--stylesheets main,tango \
"${@}"
} }
function pdf:present { function pdf:present {
TALK_PATH=$1 TALK_PATH=$1
shift 1 shift 1
pdfpc "${@}" "$TALK_PATH/$PDF_FILENAME" \ pdfpc "${@}" "dist/${TALK_PATH}.pdf" --switch-screens
--switch-screens
}
function pdf:watch {
# Generate a new PDF file and watch for changes.
echo "TODO: pdf:watch"
} }
function thumbnail:generate { function thumbnail:generate {
@ -61,4 +53,5 @@ function thumbnail:generate {
echo "TODO: thumbnail:generate" echo "TODO: thumbnail:generate"
} }
eval "${@:-help}" TIMEFORMAT=$'\nTask completed in %3lR'
time "${@:-help}"

164
styles/style-dark.yaml Normal file
View file

@ -0,0 +1,164 @@
embeddedFonts:
- - Inconsolata.ttf
- Inconsolata.ttf
- Inconsolata.ttf
- Inconsolata.ttf
- - Helvetica.ttf
- Helvetica-Bold.ttf
- Helvetica.ttf
- Helvetica-Bold.ttf
fontsAlias:
fontBold: Helvetica-Bold
fontFont: Helvetica
fontItalic: Helvetica
fontMono: Inconsolata
fontMonoBold: Inconsolata
fontMonoBoldItalic: Inconsolata
fontMonoItalic: Inconsolata
linkColor: '#60a5fa'
pageSetup:
firstTemplate: coverPage
height: 18cm
margin-bottom: 0cm
margin-gutter: 0cm
margin-left: 0cm
margin-right: 0cm
margin-top: 0cm
size: null
spacing-footer: 2mm
spacing-header: 2mm
width: 32cm
pageTemplates:
coverPage:
background: ./images/bg-dark.png
frames:
- - 12%
- 10%
- 76%
- 75%
showFooter: false
showHeader: false
imagePage:
alignment: TA_CENTER
background: ./images/bg-dark.png
frames:
- - 3%
- 3%
- 92%
- 92%
showFooter: true
showHeader: false
outputPage:
background: ./images/bg-dark.png
frames:
- - 8%
- 10%
- 82%
- 65%
showFooter: false
showHeader: false
standardPage:
background: ./images/bg-dark.png
frames:
- - 3%
- 3%
- 92%
- 92%
showFooter: true
showHeader: false
titlePage:
alignment: TA_CENTER
background: ./images/bg-dark.png
frames:
- - 8%
- 8%
- 85%
- 65%
showFooter: true
showHeader: false
styles:
bodytext:
alignment: TA_LEFT
bullet-list:
colWidths:
- '20'
- null
commands:
- - LEFTPADDING
- - 0
- 0
- - 1
- -1
- 5
- - RIGHTPADDING
- - 0
- 0
- - 1
- -1
- 0
textColor: '#ffffff'
bullet-list-item:
spaceAfter: 0
spaceBefore: 18
centred:
alignment: TA_CENTER
parent: normal
centredtitle:
alignment: TA_CENTER
fontName: fontBold
fontSize: 48
leading: 64
parent: heading
code:
backColor: '#111111'
borderWidth: 0
fontSize: 24
leading: 26
parent: literal
spaceBefore: 4
footer:
alignment: TA_RIGHT
fontName: fontMono
fontSize: 20
rightIndent: 16
spaceBefore: 0
textColor: '#24608a'
heading:
fontName: fontBold
fontSize: 20
spaceAfter: 16
textColor: '#60a5fa'
literal:
backColor: '#111111'
fontName: fontMono
normal:
fontSize: 24
textColor: '#ffffff'
title:
fontSize: 300%
parent: heading
titleslideinfo:
alignment: TA_CENTER
fontSize: 140%
parent: normal

157
styles/style-light.yaml Normal file
View file

@ -0,0 +1,157 @@
embeddedFonts:
- - Inconsolata.ttf
- Inconsolata.ttf
- Inconsolata.ttf
- Inconsolata.ttf
- - Helvetica.ttf
- Helvetica-Bold.ttf
- Helvetica.ttf
- Helvetica-Bold.ttf
fontsAlias:
fontBold: Helvetica-Bold
fontFont: Helvetica
fontItalic: Helvetica
fontMono: Inconsolata
fontMonoBold: Inconsolata
fontMonoBoldItalic: Inconsolata
fontMonoItalic: Inconsolata
linkColor: '#24608a'
pageSetup:
firstTemplate: coverPage
height: 18cm
margin-bottom: 0cm
margin-gutter: 0cm
margin-left: 0cm
margin-right: 0cm
margin-top: 0cm
size: null
spacing-footer: 2mm
spacing-header: 2mm
width: 32cm
pageTemplates:
coverPage:
frames:
- - 12%
- 10%
- 76%
- 75%
showFooter: false
showHeader: false
imagePage:
alignment: TA_CENTER
frames:
- - 3%
- 3%
- 92%
- 92%
showFooter: true
showHeader: false
outputPage:
frames:
- - 8%
- 10%
- 82%
- 65%
showFooter: false
showHeader: false
standardPage:
frames:
- - 3%
- 3%
- 92%
- 92%
showFooter: true
showHeader: false
titlePage:
alignment: TA_CENTER
frames:
- - 8%
- 8%
- 85%
- 65%
showFooter: true
showHeader: false
styles:
bodytext:
alignment: TA_LEFT
bullet-list:
colWidths:
- '20'
- null
commands:
- - LEFTPADDING
- - 0
- 0
- - 1
- -1
- 5
- - RIGHTPADDING
- - 0
- 0
- - 1
- -1
- 0
textColor: '#aaaaaa'
bullet-list-item:
spaceAfter: 0
spaceBefore: 18
centred:
alignment: TA_CENTER
parent: normal
centredtitle:
alignment: TA_CENTER
fontName: fontBold
fontSize: 48
leading: 64
parent: heading
code:
backColor: white
borderWidth: 0
fontSize: 22
leading: 24
parent: literal
spaceBefore: 0
footer:
alignment: TA_RIGHT
fontSize: 20
rightIndent: 16
spaceBefore: 0
textColor: '#aaaaaa'
heading:
fontName: fontBold
fontSize: 20
spaceAfter: 16
textColor: '#24608a'
literal:
backColor: white
fontName: fontMono
normal:
fontSize: 24
textColor: '#383745'
title:
fontSize: 300%
parent: heading
titleslideinfo:
alignment: TA_CENTER
fontSize: 140%
parent: normal