You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.9 KiB
Bash

#!/bin/bash
# Capturing the wiki page
# ---------------------------------------------------------------
# the wiki page that you wrote as an argument in the command line,
# is stored in this variable
WIKIPAGE=$1
echo ">>> making a booklet from the wiki page: $WIKIPAGE"
# Feature: local CSS edits first!
# ---------------------------------------------------------------
# The script will only download a local "booklet-stylesheet.css"
# if you don't have this file on your computer yet;
# In other words: it never overwrites your local edits.
# This allows for making custom modifications to the stylesheet
# for a specific booklet. :)
if [[ $(ls booklet-stylesheet.css) ]]; then
echo ">>> local booklet-sylesheet.css found"
else
echo ">>> downloading booklet-sylesheet.css"
curl --silent https://pzwiki.wdka.nl/mediadesign/User:Manetta/Booklet-stylesheet.css?action=raw > booklet-stylesheet.css
fi
curl --silent https://pzwiki.wdka.nl/mediadesign/User:Manetta/Booklet-stylesheet.css?action=raw > booklet-stylesheet.css.tmp
DIFF=$(diff booklet-stylesheet.css.tmp booklet-stylesheet.css)
if [[ $DIFF ]]; then
echo ">>> checking booklet-sylesheet.css: local edits were made"
else
echo ">>> checking booklet-sylesheet.css: in sync with User:Manetta/Booklet-stylesheet.css"
fi
rm booklet-stylesheet.css.tmp
# Turn the HTML page into a PDF with weasyprint
# ---------------------------------------------------------------
echo ">>> generating $WIKIPAGE.pdf (with weasyprint)"
weasyprint https://pzwiki.wdka.nl/mediadesign/$WIKIPAGE?action=render --stylesheet booklet-stylesheet.css $WIKIPAGE.pdf
# And turn the PDF into an A5 booklet PDF for printing
# ---------------------------------------------------------------
# pdfbook2 is part of the texlive-extra-utils package in Debian
echo ">>> generating $WIKIPAGE-book.pdf (with pdfbook2)"
pdfbook2 --paper=a4paper --short-edge --no-crop $WIKIPAGE.pdf