From 0ae7db2cd3b8c7c32b387ea1d21485c019c03a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Mekina?= Date: Fri, 10 Oct 2025 19:53:40 +0200 Subject: [PATCH] call bp/dp definitions only where necessary --- template/classic/bp.typ | 36 +++++++----------------------- template/classic/classic.typ | 14 ++++++++---- template/classic/dp.typ | 38 ++++++++------------------------ template/classic/thesis_base.typ | 7 +++++- 4 files changed, 33 insertions(+), 62 deletions(-) diff --git a/template/classic/bp.typ b/template/classic/bp.typ index 785a89c..aa9e507 100644 --- a/template/classic/bp.typ +++ b/template/classic/bp.typ @@ -4,36 +4,16 @@ #import "thesis_base.typ": thesis_base #let bp(args, content) = { - let force_langs = ("cs", "en"); - - let title = req_arg(args, "title"); - let abstract_content = req_arg(args, "abstract.content"); - let keywords = req_arg(args, "abstract.keywords"); - let title_pages = get_arg(args, "title_pages"); let language = req_arg(args, "document.language"); - - assert_dict_has(force_langs, title, "title"); - assert_dict_has(force_langs, abstract_content, "abstract"); - if not is_none(keywords) { - assert_dict_has(force_langs, keywords, "keywords"); - } - - if is_none(title_pages) { - let programme = req_arg(args, "author.programme"); - assert_dict_has((language,), programme, "study programme"); - let specialization = req_arg(args, "author.specialization"); - assert_dict_has((language,), specialization, "study specialization"); - if language == "cs" { - let _ = req_arg(args, "author.pronouns"); - } - } - - if is_none(title_pages) { - mainpage(args); - assignment(args); - } else { - external_title_pages(title_pages); + let programme = req_arg(args, "author.programme"); + assert_dict_has((language,), programme, "study programme"); + let specialization = req_arg(args, "author.specialization"); + assert_dict_has((language,), specialization, "study specialization"); + if language == "cs" { + let _ = req_arg(args, "author.pronouns"); } + mainpage(args); + assignment(args); thesis_base(args, content); } diff --git a/template/classic/classic.typ b/template/classic/classic.typ index 2e89189..d9d71d1 100644 --- a/template/classic/classic.typ +++ b/template/classic/classic.typ @@ -1,14 +1,15 @@ // tools & utils #import "../theme.typ": faculty_logotype, tul_logomark, faculty_color #import "../lang.typ": lang_id, get_lang_item -#import "../utils.typ": assert_in_dict, assert_in_arr, map_none, assert_dict_has -#import "../arguments.typ": req_arg, map_arg -#import "common.typ": default_styling +#import "../utils.typ": assert_in_dict, assert_in_arr, map_none, assert_dict_has, is_none +#import "../arguments.typ": req_arg, map_arg, get_arg +#import "common.typ": default_styling, external_title_pages // thesis types #import "bp.typ": bp #import "dp.typ": dp #import "other.typ": other +#import "thesis_base.typ": thesis_base #let template_classic(args, content) = { let language = req_arg(args, "document.language"); @@ -33,5 +34,10 @@ args.citations = map_arg(args, "citations", (v) => "../../" + v); args.title_pages = map_arg(args, "title_pages", (v) => "../../" + v); - document_types.at(req_arg(args, "document.type"))(args, content); + if not is_none(get_arg(args, "title_pages")) and not req_arg(args, "document.type") == "other" { + external_title_pages(req_arg(args, "title_pages")); + thesis_base(args, content); + } else { + document_types.at(req_arg(args, "document.type"))(args, content); + } } diff --git a/template/classic/dp.typ b/template/classic/dp.typ index 597f218..c655bf2 100644 --- a/template/classic/dp.typ +++ b/template/classic/dp.typ @@ -4,37 +4,17 @@ #import "thesis_base.typ": thesis_base #let dp(args, content) = { - let force_langs = ("cs", "en"); - - let title = req_arg(args, "title"); - let abstract_content = req_arg(args, "abstract.content"); - let keywords = req_arg(args, "abstract.keywords"); - let title_pages = get_arg(args, "title_pages"); let language = req_arg(args, "document.language"); - - assert_dict_has(force_langs, title, "title"); - assert_dict_has(force_langs, abstract_content, "abstract"); - if not is_none(keywords) { - assert_dict_has(force_langs, keywords, "keywords"); - } - - if is_none(title_pages) { - let programme = req_arg(args, "author.programme"); - assert_dict_has((language,), programme, "study programme"); - map_arg(args, "author.specialization", (v) => { - assert_dict_has((language,), v, "study specialization"); - }); - if language == "cs" { - let _ = req_arg(args, "author.pronouns"); - } - } - - if is_none(title_pages) { - mainpage(args); - assignment(args); - } else { - external_title_pages(title_pages); + let programme = req_arg(args, "author.programme"); + assert_dict_has((language,), programme, "study programme"); + map_arg(args, "author.specialization", (v) => { + assert_dict_has((language,), v, "study specialization"); + }); + if language == "cs" { + let _ = req_arg(args, "author.pronouns"); } + mainpage(args); + assignment(args); thesis_base(args, content); } diff --git a/template/classic/thesis_base.typ b/template/classic/thesis_base.typ index 92d27f5..dec24f4 100644 --- a/template/classic/thesis_base.typ +++ b/template/classic/thesis_base.typ @@ -1,6 +1,6 @@ #import "../theme.typ": faculty_color #import "../arguments.typ": get_arg, req_arg -#import "../utils.typ": is_none +#import "../utils.typ": is_none, assert_dict_has #import "common.typ": ( default_styling, disclaimer, @@ -15,6 +15,11 @@ #import "../attachments.typ": attachment_list #let thesis_base(args, content) = { + let force_langs = ("cs", "en"); + assert_dict_has(force_langs, req_arg(args, "title"), "title"); + assert_dict_has(force_langs, req_arg(args, "abstract.content"), "abstract"); + assert_dict_has(force_langs, req_arg(args, "abstract.keywords"), "keywords"); + let language = req_arg(args, "document.language"); default_styling(false, faculty_color(req_arg(args, "document.faculty")), { if is_none(get_arg(args, "title_pages")) {