10 Commits
v0.6 ... v0.7

11 changed files with 172 additions and 47 deletions

View File

@@ -33,6 +33,14 @@ pack/tultemplate2/template/LICENSE: LICENSE
@mkdir -p $(@D) @mkdir -p $(@D)
ln -f $< $@ ln -f $< $@
pack/tultemplate2/template/tul_citace.csl: template/tul_citace.csl
@mkdir -p $(@D)
cat $< | sed 's/^\s*\(.*\)$$/\1/' | tr -d '\n' > $@
pack/tultemplate2/template/lang.json: template/lang.json
@mkdir -p $(@D)
cat $< | jq -c > $@
pack/tultemplate2/template/%: template/% pack/tultemplate2/template/%: template/%
@mkdir -p $(@D) @mkdir -p $(@D)
ln -f $< $@ ln -f $< $@

View File

@@ -6,6 +6,7 @@ Easy Typst template for TUL documents. Begin by compiling `example.typ` and read
It is recommended to use either: It is recommended to use either:
- The on-line Typst editor (https://typst.app/play/) - use some zip build from releases - The on-line Typst editor (https://typst.app/play/) - use some zip build from releases
(https://git.zumepro.cz/tul/tultemplate2/releases).
- The `typst` CLI tool (available in Arch repos and Snap) - The `typst` CLI tool (available in Arch repos and Snap)
On Linux, with the `typst` command available, you can just run: On Linux, with the `typst` command available, you can just run:

View File

@@ -326,23 +326,38 @@ Zvýrazněné hodnoty jsou základní -- pokud vynecháte parametr, pak bude pou
#line() #line()
- `title` (nadpis dokumentu) - `title` (nadpis dokumentu)
- Ve formátu `(<zkratka_jazyka>: "<nadpis>")`, například `(cs: "Můj nadpis")` - Ve formátu `(<zkratka_jazyka>: "<nadpis>")`, například `(cs: "Můj nadpis")`
- Pro většinu dokumentů (kromě `other`) jsou vyžadovány verze _cs_ a _en_ (kvůli abstraktu).
#line() #line()
- `author` (autor/autoři dokumentu) - `author` (autor/autoři dokumentu)
- Příklad: `"Pavel Novák"` nebo `"Petra Velká, Jindřich Peterka"` - Příklad: `"Pavel Novák"` nebo `"Petra Velká, Jindřich Peterka"`
#line() #line()
- `author_gender` (rod autora v českém jazyce - není potřeba pro angličtinu) - `author_pronouns` (jazykový rod autora - není potřeba pro angličtinu, která základní hodnotu)
- Pro vybraný jazyk _cs_:
- `"masculine"` - Mužský rod - `"masculine"` - Mužský rod
- `"feminine"` - Ženský rod - `"feminine"` - Ženský rod
- `"we"` - Množné číslo - `"we"` - Množné číslo
- Pro vybraný jazyk _en_:
- *`"me"`* - První osoba jednotného čísla
- `"we"` - První osoba množného čísla
#line() #line()
- `supervisor` (vedoucí práce) - `supervisor` (vedoucí práce) <arg_supervisor>
- Příklad: `"prof. Jindřich Jindřich"` - V podobě textového řetězce, příklad: `"prof. Jindřich Jindřich"`
- Ve formátu `(name: "<jméno>", institute: "<institut>")` (toto lze využít například při DP)
#line() #line()
- `programme` (studijní program autora) - `consultant` (konzultant práce)
- Stejně jako u #link(<arg_supervisor>, [`supervisor`])
#line()
- `programme` (studijní program) <arg_programme>
- Ve formátu `(<zkratka_jazyka>: "<název_programu>")` - Ve formátu `(<zkratka_jazyka>: "<název_programu>")`
- Je vyžadován jazyk, který je vybrán pro celou šablonu -- tohle je pojistka, aby uživatel šablony
nevynechal vybraný jazyk
#line()
- `branch` (studijní obor)
- Stejně jako #link(<arg_programme>, [`programme`])
#line() #line()
- `abstract` (abstrakt) - `abstract` (abstrakt)
- Ve formátu `(<zkratka_jazyka>: [<abstrakt>])`, například `(cs: [Můj *krásný* abstrakt.])` - Ve formátu `(<zkratka_jazyka>: [<abstrakt>])`, například `(cs: [Můj *krásný* abstrakt.])`
- Dokumenty vyžadují _cs_ i _en_ abstrakt (kromě typu dokumentu `other`).
#line() #line()
- `keywords` (klíčová slova zobrazovaná pod abstraktem) - `keywords` (klíčová slova zobrazovaná pod abstraktem)
- Ve formátu `(<zkratka_jazyka>: ("slovo1", "slovo2", ...))` - Ve formátu `(<zkratka_jazyka>: ("slovo1", "slovo2", ...))`
@@ -388,6 +403,30 @@ Při dalších použití bude vypadat takto: #abbr("ZK").
Tedy zkratku _nepřidáváte_ přímo do seznamu zkratek, ale elegantně používáte přímo v textu. Tedy zkratku _nepřidáváte_ přímo do seznamu zkratek, ale elegantně používáte přímo v textu.
] ]
== Přílohy
V některých typech dokumentů budete chtít přidat přílohy. Přílohy se přikládají v různých podobách:
- Jako odkaz (URL/URI adresa)
- Zmínka externího souboru (například další soubor nahraný do systému)
- Přiložený obsah (vygenerovaný Typstem v tomto dokumentu -- je tedy součástí tohoto kódu)
- Externí PDF soubor přiložený jako obsah (jiný PDF dokument, vložený do příloh v kompletní
podobě -- to je dobré například do tisku, kde můžete přílohy vytisknout s dokumentem)
#highlight[
Přílohy lze definovat *pouze na jednom* místě v dokumentu, aby se zabránilo omylnému opakování
příloh. Přílohy doporučujeme definovat *na konci* souboru pro přehlednost.
]
Zde je ukázka definice příloh (je také použita na konci tohoto ukázkového souboru):
```typst
#attachments(
attach_link("Zdrojový kód této šablony", "https://git.zumepro.cz/tul/tultemplate2"),
attach_content("Testovací obsah vygenerovaný Typstem", [Sem lze psát _stylovaný_ obsah.]),
)
```
= Workflow a jak si zjednoduššit práci = Workflow a jak si zjednoduššit práci
Tyhle věci používat _nemusíte_, aby vám šablona fungovala. Nicméně často jsou poměrně fajn. Tyhle věci používat _nemusíte_, aby vám šablona fungovala. Nicméně často jsou poměrně fajn.
@@ -450,3 +489,8 @@ Takhle si můžete předpřipravit délku odstavců a vyzkoušet si, jestli se r
do požadavků. Pak můžete postupně přepisovat/vyplňovat. do požadavků. Pak můžete postupně přepisovat/vyplňovat.
Funkce `todo` vám zároveň zabrání v tom, aby se text Lorem Ipsum vyskytl ve výsledném dokumentu. Funkce `todo` vám zároveň zabrání v tom, aby se text Lorem Ipsum vyskytl ve výsledném dokumentu.
#attachments(
attach_link("Zdrojový kód této šablony", "https://git.zumepro.cz/tul/tultemplate2"),
attach_content("Testovací obsah vygenerovaný Typstem", [Sem lze psát _stylovaný_ obsah.]),
)

View File

@@ -60,7 +60,8 @@
} }
} }
#let attachments(attachments) = { #let attachments(..attachments) = {
let attachments = attachments.pos();
assert_type_signature( assert_type_signature(
attachments, "array[array[string | content]] | array[string | content]", "attachments" attachments, "array[array[string | content]] | array[string | content]", "attachments"
); );
@@ -117,6 +118,9 @@
return; return;
} }
let data = eval(data); let data = eval(data);
if data == false {
return;
}
heading(get_lang_item(language, "attachments"), numbering: none); heading(get_lang_item(language, "attachments"), numbering: none);
// listing // listing

View File

@@ -5,6 +5,7 @@
assignment, assignment,
disclaimer, disclaimer,
abstract, abstract,
acknowledgement,
toc, toc,
abbrlist, abbrlist,
imagelist, imagelist,
@@ -12,15 +13,15 @@
bibliogr bibliogr
) )
#import "../attachments.typ": attachment_list #import "../attachments.typ": attachment_list
#import "../utils.typ": is_none, assert_dict_has, assert_not_none #import "../utils.typ": is_none, assert_dict_has, assert_not_none, assert_type_signature
#let bp( #let bp(
// general settings // general settings
faculty_id, faculty_color, language, assignment_document, citation_file, faculty_id, faculty_color, language, assignment_document, citation_file,
// document info // document info
title, author, author_gender, supervisor, consultant, study_programme, study_branch, abstract_content, title, author, author_pronouns, supervisor, consultant, study_programme, study_branch,
keywords, year_of_study, abstract_content, acknowledgement_content, keywords,
content content
) = { ) = {
@@ -38,20 +39,28 @@
if not is_none(keywords) { if not is_none(keywords) {
assert_dict_has(force_langs, keywords, "keywords"); assert_dict_has(force_langs, keywords, "keywords");
} }
assert_not_none(acknowledgement_content, "acknowledgement content");
if language == "cs" { if language == "cs" {
assert_not_none(author_gender, "author gender"); assert_not_none(author_pronouns, "author gender");
} }
mainpage(faculty_id, language, "bp", title, author, supervisor, consultant, study_programme, study_branch); assert_type_signature(supervisor, "string | none", "supervisor");
assert_type_signature(consultant, "string | none", "consultant");
mainpage(
faculty_id, language, "bp", title, author, supervisor, consultant, study_programme,
study_branch, year_of_study,
);
assignment(language, assignment_document); assignment(language, assignment_document);
default_styling(false, faculty_color, { default_styling(false, faculty_color, {
disclaimer(language, faculty_id, "bp", author, author_gender); disclaimer(language, faculty_id, "bp", author, author_pronouns);
abstract("cs", title, abstract_content, keywords); abstract("cs", title, abstract_content, keywords);
abstract("en", title, abstract_content, keywords); abstract("en", title, abstract_content, keywords);
acknowledgement(language, author, acknowledgement_content);
toc(language); toc(language);
abbrlist(language);
imagelist(language);
tablelist(language); tablelist(language);
imagelist(language);
abbrlist(language);
pagebreak(weak: true); pagebreak(weak: true);
content; content;
bibliogr(language, citation_file); bibliogr(language, citation_file);

View File

@@ -12,7 +12,8 @@
language, faculty_id, document_type, citation_file, assignment_document, language, faculty_id, document_type, citation_file, assignment_document,
// document info // document info
title, author, author_gender, supervisor, consultant, study_programme, study_branch, abstract, keywords, title, author, author_pronouns, supervisor, consultant, study_programme, study_branch,
year_of_study, abstract, acknowledgement, keywords,
// content // content
content, content,
@@ -26,22 +27,24 @@
map_none(title, (v) => assert_dict_has((language,), v, "title")); map_none(title, (v) => assert_dict_has((language,), v, "title"));
map_none(study_programme, (v) => assert_dict_has((language,), v, "study programme")); map_none(study_programme, (v) => assert_dict_has((language,), v, "study programme"));
map_none(study_branch, (v) => assert_dict_has((language,), v, "study branch")); map_none(study_branch, (v) => assert_dict_has((language,), v, "study branch"));
map_none(acknowledgement, (v) => assert_dict_has((language,), v, "acknowledgement content"));
document_types.at(document_type)( document_types.at(document_type)(
faculty_id, faculty_id,
faculty_color(faculty_id), faculty_color(faculty_id),
language, language,
assignment_document, map_none(assignment_document, (v) => "../../" + v),
map_none(citation_file, (v) => "../../" + v), map_none(citation_file, (v) => "../../" + v),
title, title,
author, author,
author_gender, author_pronouns,
supervisor, supervisor,
consultant, consultant,
study_programme, study_programme,
study_branch, study_branch,
year_of_study,
abstract, abstract,
acknowledgement,
keywords, keywords,
content, content,
); );

View File

@@ -1,6 +1,6 @@
#import "../theme.typ": faculty_logotype, tul_logomark, faculty_color #import "../theme.typ": faculty_logotype, tul_logomark, faculty_color
#import "../lang.typ": get_lang_item #import "../lang.typ": get_lang_item
#import "../utils.typ": is_none #import "../utils.typ": is_none, assert_dict_has, map_none
#let base_font = "Inter"; #let base_font = "Inter";
#let mono_font = "Noto Sans Mono"; #let mono_font = "Noto Sans Mono";
@@ -92,14 +92,38 @@
// DOCUMENT INFO // DOCUMENT INFO
#let person_info(record, item_name) = {
if is_none(record) {
none
} else if type(record) == str {
record
} else if type(record) == dictionary {
if "name" in record {
record.at("name");
if "institute" in record {
text("\n " + record.at("institute"), style: "italic")
}
} else {
let panic_message = (
item_name + " name is required (or try not specifying " + item_name + " at all)"
);
panic(panic_message);
}
} else {
let panic_message = "invalid " + item_name + " - expected a string or a dictionary";
panic(panic_message);
}
}
#let info( #let info(
faculty_id, faculty_id,
language, language,
document_type, document_type,
title, author, supervisor, consultant, study_programme, study_branch, title, author, supervisor, consultant, study_programme, study_branch, year_of_study,
) = { ) = {
let info_name_value_padding = 5em; let info_name_value_padding = 5em;
let info_name_min_width = 10em; let info_name_min_width = 10em;
let gutter = .7em;
// document type // document type
if type(document_type) != type(none) { if type(document_type) != type(none) {
@@ -117,11 +141,12 @@
// other info // other info
// [field_name, field_value, bold] // [field_name, field_value, bold]
let info_fields = ( let info_fields = (
("author", author, true),
("supervisor", person_info(supervisor, "supervisor"), false),
("consultant", person_info(consultant, "consultant"), false),
("study_programme", study_programme, false), ("study_programme", study_programme, false),
("study_branch", study_branch, false), ("study_branch", study_branch, false),
("author", author, true), ("year_of_study", map_none(year_of_study, (v) => str(v) + "."), false),
("supervisor", supervisor, false),
("consultant", consultant, false),
) )
context { context {
let max_field_name_width = calc.max(..info_fields.map((v) => { let max_field_name_width = calc.max(..info_fields.map((v) => {
@@ -133,7 +158,7 @@
}), info_name_min_width.to-absolute()); }), info_name_min_width.to-absolute());
grid( grid(
columns: 2, columns: 2,
gutter: .5em, gutter: gutter,
..info_fields.filter((v) => { type(v.at(1)) != type(none) }).map((v) => { ..info_fields.filter((v) => { type(v.at(1)) != type(none) }).map((v) => {
( (
align(top, block( align(top, block(
@@ -145,7 +170,7 @@
}).flatten(), }).flatten(),
); );
v(1em); v(1em);
h(max_field_name_width + info_name_value_padding); h(max_field_name_width + info_name_value_padding + gutter);
text(get_lang_item(language, "city") + " " + str(datetime.today().year()), font: base_font); text(get_lang_item(language, "city") + " " + str(datetime.today().year()), font: base_font);
} }
} }
@@ -156,7 +181,7 @@
faculty_id, faculty_id,
language, language,
document_type, document_type,
title, author, supervisor, consultant, study_programme, study_branch title, author, supervisor, consultant, study_programme, study_branch, year_of_study,
) = { ) = {
import "../utils.typ": has_all_none, map_none import "../utils.typ": has_all_none, map_none
let nonetype = type(none); let nonetype = type(none);
@@ -171,7 +196,7 @@
info( info(
faculty_id, language, document_type, map_none(title, (v) => v.at(language)), faculty_id, language, document_type, map_none(title, (v) => v.at(language)),
author, supervisor, consultant, map_none(study_programme, (v) => v.at(language)), author, supervisor, consultant, map_none(study_programme, (v) => v.at(language)),
map_none(study_branch, (v) => v.at(language)), map_none(study_branch, (v) => v.at(language)), year_of_study,
); );
v(5em); v(5em);
}, bottom); }, bottom);
@@ -203,11 +228,11 @@
// DISCLAIMER PAGE // DISCLAIMER PAGE
#let disclaimer(language, faculty_id, disclaimer_type, author, author_gender) = { #let disclaimer(language, faculty_id, disclaimer_type, author, author_pronouns) = {
import "../lang.typ": disclaimer import "../lang.typ": disclaimer
heading(get_lang_item(language, "disclaimer"), numbering: none, outlined: false); heading(get_lang_item(language, "disclaimer"), numbering: none, outlined: false);
par( par(
text(disclaimer(language, disclaimer_type, author_gender)) text(disclaimer(language, disclaimer_type, author_pronouns))
); );
v(5em); v(5em);
grid( grid(
@@ -220,6 +245,18 @@
); );
} }
// ACKNOWLEDGEMENT PAGE
#let acknowledgement(language, author, content) = {
if is_none(content) {
return;
}
heading(get_lang_item(language, "acknowledgement"), numbering: none, outlined: false);
par(content.at(language));
v(2em);
align(right, author);
}
// ABSTRACT // ABSTRACT
#let abstract(language, title, content, keywords) = { #let abstract(language, title, content, keywords) = {

View File

@@ -18,19 +18,23 @@
faculty_id, faculty_color, language, assignment_document, citation_file, faculty_id, faculty_color, language, assignment_document, citation_file,
// document info // document info
title, author, _, supervisor, consultant, study_programme, study_branch, abstract_content, keywords, title, author, _, supervisor, consultant, study_programme, study_branch, year_of_study,
abstract_content, _, keywords,
content content
) = { ) = {
assert_not_none(title, "title"); assert_not_none(title, "title");
assert_dict_has((language,), title, "title"); assert_dict_has((language,), title, "title");
mainpage(faculty_id, language, none, title, author, supervisor, consultant, study_programme, study_branch); mainpage(
faculty_id, language, none, title, author, supervisor, consultant, study_programme,
study_branch, year_of_study,
);
default_styling(true, faculty_color, { default_styling(true, faculty_color, {
toc(language); toc(language);
abbrlist(language);
imagelist(language);
tablelist(language); tablelist(language);
imagelist(language);
abbrlist(language);
pagebreak(to: "even", weak: true); pagebreak(to: "even", weak: true);
content; content;
bibliography(citation_file, style: "../tul_citace.csl"); bibliography(citation_file, style: "../tul_citace.csl");

View File

@@ -6,6 +6,7 @@
"consultant": "Konzultant práce", "consultant": "Konzultant práce",
"study_programme": "Studijní program", "study_programme": "Studijní program",
"study_branch": "Studijní obor", "study_branch": "Studijní obor",
"year_of_study": "Ročník",
"bp": "Bakalářská práce", "bp": "Bakalářská práce",
@@ -36,6 +37,7 @@
"date": "[day]. [month]. [year]", "date": "[day]. [month]. [year]",
"abstract": "Abstrakt", "abstract": "Abstrakt",
"acknowledgement": "Poděkování",
"keywords": "Klíčová slova", "keywords": "Klíčová slova",
"abbrs": "Seznam zkratek", "abbrs": "Seznam zkratek",
"image_list": "Seznam obrázků", "image_list": "Seznam obrázků",
@@ -55,6 +57,7 @@
"consultant": "Consultant", "consultant": "Consultant",
"study_programme": "Study programme", "study_programme": "Study programme",
"study_branch": "Study branch", "study_branch": "Study branch",
"year_of_study": "Year of study",
"bp": "Bachelor thesis", "bp": "Bachelor thesis",
@@ -74,6 +77,7 @@
"date": "[year]-[month]-[day]", "date": "[year]-[month]-[day]",
"abstract": "Abstract", "abstract": "Abstract",
"acknowledgement": "Acknowledgement",
"keywords": "Keywords", "keywords": "Keywords",
"abbrs": "List of abbreviations", "abbrs": "List of abbreviations",
"image_list": "List of images", "image_list": "List of images",

View File

@@ -45,13 +45,13 @@
}); });
} }
#let disclaimer(language, document_type, author_gender) = { #let disclaimer(language, document_type, author_pronouns) = {
let disclaimer = get_lang_item(language, "disclaimer_content"); let disclaimer = get_lang_item(language, "disclaimer_content");
let replacements = get_lang_item(language, "disclaimer_replace").at(document_type); let replacements = get_lang_item(language, "disclaimer_replace").at(document_type);
if language == "cs" { if language == "cs" {
disclaimer = replace_czech_gender(disclaimer, author_gender); disclaimer = replace_czech_gender(disclaimer, author_pronouns);
} else if language == "en" { } else if language == "en" {
disclaimer = replace_english_pronounce(disclaimer, author_gender); disclaimer = replace_english_pronounce(disclaimer, author_pronouns);
} }
for (key, value) in replacements.pairs() { for (key, value) in replacements.pairs() {
disclaimer = disclaimer.replace("{" + key + "}", value); disclaimer = disclaimer.replace("{" + key + "}", value);

View File

@@ -28,9 +28,11 @@
// - document (str): Type of document. This can be "bp" or "other". // - document (str): Type of document. This can be "bp" or "other".
// - title (dictionary): The title of the document. // - title (dictionary): The title of the document.
// - author (str): The name of the document's author. // - author (str): The name of the document's author.
// - author_gender (str): The gender of the document's author. Needed only for the `cs` language. // - author_pronouns (str): The gender of the document's author. Needed only for the `cs` language.
// - supervisor (str): The name of the document's supervisor. // - supervisor (str): The name of the document's supervisor.
// - consultant (str): The name of the document's consultant.
// - programme (dictionary): Study programme. // - programme (dictionary): Study programme.
// - branch (disctionary): Study branch
// - abstract (dictionary): The abstract. // - abstract (dictionary): The abstract.
// - keywords (dictionary): The abstract keywords. // - keywords (dictionary): The abstract keywords.
// - assignment (str): Filepath of the assignment document/page. // - assignment (str): Filepath of the assignment document/page.
@@ -43,8 +45,9 @@
style: "classic", faculty: "tul", lang: "cs", document: "other", style: "classic", faculty: "tul", lang: "cs", document: "other",
// document info // document info
title: none, keywords: none, abstract: none, author: none, author_gender: none, title: none, keywords: none, abstract: none, acknowledgement: none, author: none,
supervisor: none, consultant: none, programme: none, branch: none, author_pronouns: none, supervisor: none, consultant: none, programme: none,
branch: none, year_of_study: none,
// links // links
assignment: none, citations: "citations.bib", assignment: none, citations: "citations.bib",
@@ -64,14 +67,22 @@
assert_type_signature( assert_type_signature(
abstract, "dictionary[string : string | content] | none", "abstract argument" abstract, "dictionary[string : string | content] | none", "abstract argument"
); );
assert_type_signature(
acknowledgement, "dictionary[string : string] | none", "acknowledgement content"
);
assert_type_signature(author, "string | none", "author argument"); assert_type_signature(author, "string | none", "author argument");
assert_type_signature(author_gender, "string | none", "author gender argument"); assert_type_signature(author_pronouns, "string | none", "author gender argument");
assert_type_signature(supervisor, "string | none", "supervisor argument"); assert_type_signature(
assert_type_signature(consultant, "string | none", "consultant argument"); supervisor, "string | dictionary[string : string] | none", "supervisor argument"
);
assert_type_signature(
consultant, "string | dictionary[string : string] | none", "consultant argument"
);
assert_type_signature( assert_type_signature(
programme, "dictionary[string : string] | none", "study programme argument" programme, "dictionary[string : string] | none", "study programme argument"
); );
assert_type_signature(branch, "dictionary[string : string] | none", "study branch argument"); assert_type_signature(branch, "dictionary[string : string] | none", "study branch argument");
assert_type_signature(year_of_study, "integer | none", "year of study");
assert_type_signature(assignment, "string | none", "assignment document argument"); assert_type_signature(assignment, "string | none", "assignment document argument");
assert_type_signature(citations, "string", "citations file argument"); assert_type_signature(citations, "string", "citations file argument");
@@ -90,8 +101,8 @@
// template call // template call
templates.at(style)( templates.at(style)(
lang, faculty, document, citations, assignment, lang, faculty, document, citations, assignment,
title, author, author_gender, supervisor, consultant, title, author, author_pronouns, supervisor, consultant,
programme, branch, abstract, keywords, content programme, branch, year_of_study, abstract, acknowledgement, keywords, content
); );
import "prototyping.typ": assert_release_ready import "prototyping.typ": assert_release_ready