kittv
/
prezgen
Archived
1
0
Fork 0

Compare commits

..

No commits in common. '27b279b672028b2ce5f9b3531d01e8576505f3cb' and 'aeb96ecec7d471934be3ea90362a8f5a32282132' have entirely different histories.

@ -1,27 +1,20 @@
# 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.
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`.
Install rust/cargo, 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.
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:
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>

@ -1,9 +1,8 @@
use structopt::StructOpt;
use toml::Value;
use std::collections::hash_map::DefaultHasher;
use std::fs::{copy, create_dir, read_to_string};
use std::path::PathBuf;
use std::fs::{read_to_string, copy};
#[derive(StructOpt, Debug)]
/// structure representing command line arguments
@ -24,9 +23,6 @@ struct Opt {
template: PathBuf,
}
fn replace(input: String, rules: &[(&str, &str)]) -> String {
unimplemented!();
}
fn main() {
// parse command line arguments
@ -34,24 +30,10 @@ fn main() {
//println!("{:?}", opt);
// parse toml
let value = read_to_string(&opt.toml).unwrap().parse::<Value>().unwrap();
println!("{:#?}", value);
// create output directory
// if it doesn't exist
if (!opt.output.exists()) {
create_dir(&opt.output).unwrap();
}
// read template
let input = read_to_string(
&[opt.output, PathBuf::from("front.html")]
.iter()
.collect::<PathBuf>(),
);
// create rules
let page = value.get("page").unwrap().as_array().unwrap();
let value = read_to_string(opt.toml)
.unwrap()
.parse::<Value>()
.unwrap();
println!("{:?}", value);
println!("{:#?}", page);
}