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.

93 lines
2.7 KiB
Markdown

---
title: Post it generator
description: Prototype for web-to-print postit
categories:
- Web
- Print
- SI17
git: https://git.xpub.nl/kamo/postit-gen
cover: susi.jpg
cover_alt: fake sushi
date: 08/03/2022
---
## POST-IT GENERATOR
~~TO AUGMENT OUR PRODUCTIVITY HERE IS A SCRIPT THAT~~
Generate post-it blocks from markdown files.
### Install
Clone the repo
`git clone https://git.xpub.nl/kamo/postit-gen.git`
Move to the cloned folder
`cd postit-gen`
Create a virtual environment
`python3 -m venv venv`
and activate it
`. venv/bin/activate`
Then you can install the repo
`pip3 install -e .`
### How to use
The package offers two scripts: `template.py` and `generate.py`.
`template.py` generate a template folder with a markdown file that can be used as a starting point for formatting the contents.
`python3 template.py -f test`
Will generate a `test` folder, with the markdown template for the contents.
The `contents.md` file has these properties:
- `title`, the title of the block
- `folder`, the base folder in which the files are
- `page_width`, the width of the page for the printing
- `page_height`, the height of the page for the printing
- `post_width`, the width of the post-it for the printing
- `post_height`, the height of the post-it for the printing
- `margin`, the margin for the page
- `unit`, the measure unit in which the measures are expressed, default is _mm_
- `background`, the color of the post-its. Accept all the format CSS specs accept. Default is _white_.
- `contents`, a list of contents to put in the post-it block. Each entry is a post-it.
All these parameters are formatted in [YAML](https://it.wikipedia.org/wiki/YAML).
After setting all the parameters to match your needs, you can fill the contents. ATM you can insert text and images, in the form of a list.
```yaml
contents:
- A flat with no floors
- Hello, where are you, what can you see from there?
- type: image
src: game.png
```
Usually each entry of the list will be considered as a string. If you want to insert an image you will need to provide a `type: image`, and a `src: <filename>`.
In this way:
```yaml
contents:
- type: image
src: <filename>
```
Once you inserted your contents, you can run the `generate.py` script, specifying the working folder from which you want to take the contents.
`python3 generate.py -f test`
It will take the contents inside the `test` folder and will generate a ready-to-print HTML file, serving it with a simple http-server at `http://localhost:8000/test`. Opening that link you can preview your post-it blocks. Each entry of the `contents` list is now a page in the document (in the print mode!)
TODO: link css file in the template to work directly on the preview.