refactor: replace workspace.yml with run
This commit is contained in:
parent
c7fb60a2cf
commit
017713a063
56
run
Executable file
56
run
Executable file
|
@ -0,0 +1,56 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
PDF_FILENAME=slides.pdf
|
||||||
|
RST_FILENAME=slides.rst
|
||||||
|
THUMBNAIL_FILENAME=thumbnail.jpg
|
||||||
|
|
||||||
|
function clean:all {
|
||||||
|
# Clean all generated files.
|
||||||
|
|
||||||
|
find . \
|
||||||
|
-type f \( -name "${PDF_FILENAME}*" -o -name *.build_temp -o -name ${THUMBNAIL_FILENAME} \) \
|
||||||
|
-delete
|
||||||
|
}
|
||||||
|
|
||||||
|
function help {
|
||||||
|
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
||||||
|
|
||||||
|
compgen -A function | grep -v "^_" | cat -n
|
||||||
|
|
||||||
|
printf "\nExtended help:\n Each task has comments for general usage\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
function pdf:generate {
|
||||||
|
# Generate a new PDF file.
|
||||||
|
|
||||||
|
DIRECTORY_NAME=$1
|
||||||
|
shift 1
|
||||||
|
|
||||||
|
docker run --rm -it \
|
||||||
|
-v $HOME/.local/share/fonts:/usr/share/fonts \
|
||||||
|
-v $PWD/${DIRECTORY_NAME}:/rst2pdf \
|
||||||
|
-w /rst2pdf \
|
||||||
|
opdavies/rst2pdf \
|
||||||
|
${RST_FILENAME} \
|
||||||
|
--break-level 1 \
|
||||||
|
--extension-module preprocess \
|
||||||
|
--fit-background-mode scale \
|
||||||
|
--font-path /usr/share/fonts \
|
||||||
|
--output ${PDF_FILENAME} \
|
||||||
|
--stylesheets main,tango \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function pdf:watch {
|
||||||
|
# Generate a new PDF file and watch for changes.
|
||||||
|
echo "TODO: pdf:watch"
|
||||||
|
}
|
||||||
|
|
||||||
|
function thumbnail:generate {
|
||||||
|
# Generate a thumbnail image of the first slide in the presentation.
|
||||||
|
echo "TODO: thumbnail:generate"
|
||||||
|
}
|
||||||
|
|
||||||
|
eval "${@:-help}"
|
|
@ -1,46 +0,0 @@
|
||||||
workspace('talks'):
|
|
||||||
description: 'My slide decks'
|
|
||||||
|
|
||||||
attributes:
|
|
||||||
rst2pdf:
|
|
||||||
command: |
|
|
||||||
= 'docker run --rm -it -v $PWD:/rst2pdf -v $HOME/.local/share/fonts:/usr/share/fonts -w /rst2pdf opdavies/rst2pdf ' ~ @('rst2pdf.filename.rst') ~ '
|
|
||||||
--break-level 1
|
|
||||||
--stylesheets main,tango
|
|
||||||
--fit-background-mode scale
|
|
||||||
--extension-module preprocess
|
|
||||||
--output ' ~ @('rst2pdf.filename.pdf') ~ '
|
|
||||||
--font-path /usr/share/fonts'
|
|
||||||
filename:
|
|
||||||
pdf: slides.pdf
|
|
||||||
rst: slides.rst
|
|
||||||
thumbnail:
|
|
||||||
filename: thumbnail.png
|
|
||||||
|
|
||||||
command('clean all'):
|
|
||||||
env:
|
|
||||||
PDF_FILENAME: = @('rst2pdf.filename.pdf')
|
|
||||||
RST_FILENAME: = @('rst2pdf.filename.rst')
|
|
||||||
THUMBNAIL_FILENAME: = @('thumbnail.filename')
|
|
||||||
exec: |
|
|
||||||
#!bash
|
|
||||||
run "find . -type f \( -name '$PDF_FILENAME*' -o -name *.build_temp -o -name $THUMBNAIL_FILENAME \) -delete"
|
|
||||||
|
|
||||||
command('pdf generate <talk>'): |
|
|
||||||
#!bash|=
|
|
||||||
cd ={ input.argument('talk') }
|
|
||||||
passthru ={ @('rst2pdf.command') }
|
|
||||||
|
|
||||||
command('pdf watch <talk>'): |
|
|
||||||
#!bash|=
|
|
||||||
cd ={ input.argument('talk') }
|
|
||||||
passthru nodemon -e rst,style,txt,jpg,png -x "={ @('rst2pdf.command') }"
|
|
||||||
|
|
||||||
command('thumbnail <talk>'):
|
|
||||||
env:
|
|
||||||
PDF_FILENAME: = @('rst2pdf.filename.pdf')
|
|
||||||
THUMBNAIL_FILENAME: = @('thumbnail.filename')
|
|
||||||
exec: |
|
|
||||||
#!bash|=
|
|
||||||
cd ={ input.argument('talk') }
|
|
||||||
passthru gs -sDEVICE=png16m -r300 -dDownScaleFactor=4 -sOutputFile=$THUMBNAIL_FILENAME -dLastPage=1 $PDF_FILENAME
|
|
Loading…
Reference in a new issue