Slide of the Tiger
sliger
Slide of the tiger
Slide the power of Python (and Jinja2) into Google Slides
pip install sliger
To use sliger
with a specific Google Slides presentation, the following is necessary:
.json
file)In general, sliger
needs two pieces of information in order for it to
do any automation on a specific Google Slides presentation:
1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ
)There are quite a few commands that the sliger
supports:
duplicate-presentation
To duplicate a specific presentation (in this case the presentation with the ID 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ
) to a new one with a specific name (in this case 'A new presentation test'
), one could run the following command:
sliger --creds-file mrshu-gslidesexperiments-7cd84ace2933.json --presentation-id 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ duplicate-presentation --copy-title 'A new presentation test'
delete-slide
To delete slide number 3, one can run the following:
sliger --creds-file mrshu-gslidesexperiments-7cd84ace2933.json --presentation-id 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ delete-slide --id 3
duplicate-slide
To duplicate slide number 3, one can run the following:
sliger --creds-file mrshu-gslidesexperiments-7cd84ace2933.json --presentation-id 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ duplicate-slide --id 3
jinjify
sliger
also supports Jinja Templates.
It also provides a few custom functions, such as
strftime
which can be used to format dates. For instance the string
Hi! Today is {{ strftime("%A, %O %B", now) }}
Would get rendered to
Hi! Today is Friday, 2nd September
Jinjify is also able to render Python functions. Once added the function to collector.py
and to the variable func_dict
, jinjify
will parse the Python output in plain text.
For instance the string:
{{ greet_pycon() }}
Would get render to
Hi PyCon Italy! This string is generated from a Python function.
To render the template directly inside a specific presentation, you can run
sliger --creds-file mrshu-gslidesexperiments-7cd84ace2933.json --presentation-id 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ jinjify
Note that for the apostrophes to be picked up correctly, you will need to turn off the Use smart quotes option in Tools -> Preferences, as described in the community docs.
imagify
Looks for text elements whose content is in the following format:
![image](<IMAGE_PATH>)
It then replaces the found text elements with image elements containing the images found at
IMAGE_PATH
. The image needs to be present locally. The IMAGE_PATH
can be templated with
Jinja. The used Jinja function should return the path to a locally present image that should be
uploaded.
For example the following text placeholder will call the generate_image
Jinja function which
should create an image on the disk and return the path to the image.
![image]({{ generate_image }})
To replace the placeholders with actual images in the presentation, one can run:
sliger --creds-file mrshu-gslidesexperiments-7cd84ace2933.json --presentation-id 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ imagify