Dawid J. Kubis 62b20e4dc9 | 3 years ago | |
---|---|---|
src | 3 years ago | |
templates | 3 years ago | |
.gitignore | 3 years ago | |
.rustfmt.toml | 3 years ago | |
Cargo.lock | 3 years ago | |
Cargo.toml | 3 years ago | |
README.md | 3 years ago |
README.md
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:
<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. It should contain a global section and other sections (pages), which would later turn into individual PDF files.
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/
.