kittv
/
prezgen
Archived
1
0
Fork 0
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

71 lines
2.2 KiB
Markdown

# prezgen
A software for automatic generation of attendance lists for use at school.
Our faculty/department uses physical attendance lists for logging every class and all the attendees.
This program is written in Rust in order to run as a single binary.
## Installation
Install rust/cargo (nightly edition), clone this repository and run `cargo build --release`. The binary will be saved to `target/build/release`.
## Usage
In order to generate a full set of lists (PDF files), you need to have a TOML source file and a template written in HTML.
The program reads the input file, checks all relevant variables and tries to find them in the template.
If a variable is found, it gets filled with data from the source file variable of the same name.
In case the variable is not found in the template, it gets ignored and the program continues to the next variable.
### Template
The template has two sides, front and back.
Both are static HTML files (with styles) ready for clean printing (`@media print` query).
The template should contain variables, which would be later replaced by the generator.
The format, in which a variable should be written, is `{{ variable_name }}` anywhere in the HTML document, for example:
```html
<h2>{{ title }}</h2>
<p>Taught in the year {{ year }}.</p>
<table>
<tr>
<td>Teacher:</td>
<td>{{ techer }}</td>
</tr>
<tr>
<td>IS code:</td>
<td>{{ code }}</td>
</tr>
</table>
```
### Source file
The source file is written in [TOML format](https://toml.io). It should contain a *global* section and other sections (pages), which would later turn into individual PDF files.
```toml
year = "2021/2022"
[[page]]
title = "Unix-based operating systems"
teacher = "Theo de Raadt"
code = "BSD1"
[[page]]
title = "The C Programming Language"
teacher = "Brian Kernighan, Dennis Ritchie"
code = "C1978"
year = "2022/2023"
```
In case the same global and page variable is set, the page variable takes priority. In this particular case, the value `2022/2023` would be used for the variable `year` on the second page, whereas the first page would use `2021/2022` from the global variable.
### Building PDF outputs
Simply run the program and specify the input file.
```
prezgen sample_input.toml
```
All the PDF files will be saved into `output/`.