Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
73e0c700ad
|
|||
|
57e97bf64d
|
|||
| 7e635c2c06 | |||
| 0f03fc2788 | |||
| bece26ad41 | |||
| 1494ef0ba5 | |||
| a77505683c | |||
| 72771bcbe8 | |||
|
cb7131d0ae
|
|||
|
49fbe34ea5
|
|||
|
cecc5c8f00
|
|||
|
db1e83fad6
|
|||
|
359a0da640
|
|||
|
d21e0d3857
|
|||
|
54ea1bfb8e
|
|||
|
972cc19ecb
|
|||
|
|
c72eb5ef34 | ||
|
|
2aab573c07 |
94
Makefile
94
Makefile
@@ -2,23 +2,32 @@ TYPST_PACKAGES ?=
|
||||
|
||||
BUILD_DIR := target
|
||||
PACKS_ROOT := $(BUILD_DIR)/pack
|
||||
PACKSTAGING := $(PACKS_ROOT)/staging
|
||||
PACKDIR := $(PACKS_ROOT)/tultemplate2
|
||||
BUNDLEDIR := $(PACKS_ROOT)/bundle
|
||||
MINIMALDIR := $(PACKS_ROOT)/minimal
|
||||
|
||||
LIBDIR := template/lib
|
||||
LIB_MUCHPDFTOOLS := $(LIBDIR)/much_pdf_tools
|
||||
LIB_TARGETS_MUCHPDFTOOLS := lib.typ much_pdf_tools.wasm
|
||||
LIB_URL_MUCHPDFTOOLS := https://tulsablona.zumepro.cz/lib/much_pdf_tools
|
||||
|
||||
TEMPLATE_SRCS := $(shell find template -type f) \
|
||||
$(LIB_TARGETS_MUCHPDFTOOLS:%=$(LIB_MUCHPDFTOOLS)/%) template/example_appendix.pdf
|
||||
TO_PACK := $(TEMPLATE_SRCS) template/LICENSE
|
||||
BUNDLE_THESES := bp_cs bp_en dp_cs dp_en prj_cs prj_en sp_cs sp_en presentation_cs
|
||||
MINIMAL_ASSET_ROOTS := template/assets template/fonts template/citations
|
||||
MINIMAL_SRCS := $(shell find template -type f -regex '^.*\.typ$$') \
|
||||
$(shell find $(MINIMAL_ASSET_ROOTS) -type f) \
|
||||
template/lang.json \
|
||||
$(LIB_TARGETS_MUCHPDFTOOLS:%=$(LIB_MUCHPDFTOOLS)/%)
|
||||
TEMPLATE_SRCS := $(MINIMAL_SRCS) template/example_appendix.pdf
|
||||
ADD_TO_PACK := template/LICENSE
|
||||
TO_PACK_MINIMAL := $(MINIMAL_SRCS) $(ADD_TO_PACK)
|
||||
TO_PACK := $(TEMPLATE_SRCS) $(ADD_TO_PACK)
|
||||
BUNDLE_THESES := bp_cs bp_en dp_cs dp_en prj_cs prj_en sp_cs sp_en presentation_cs presentation_en
|
||||
BUNDLE_TARGETS := $(TO_PACK:%=$(BUNDLEDIR)/%) $(BUNDLEDIR)/citations.bib $(BUNDLEDIR)/bp_cs.typ \
|
||||
$(BUNDLE_THESES:%=$(BUNDLEDIR)/%.typ) $(BUNDLEDIR)/Makefile \
|
||||
$(BUNDLEDIR)/title-pages.pdf $(BUNDLEDIR)/assignment.pdf
|
||||
PACK_TARGETS := $(TO_PACK:%=$(PACKDIR)/%) $(PACKDIR)/documentation.typ \
|
||||
$(PACKDIR)/documentation.pdf $(PACKDIR)/citations.bib $(PACKDIR)/Makefile
|
||||
MINIMAL_TARGETS := $(TO_PACK_MINIMAL:%=$(MINIMALDIR)/%)
|
||||
|
||||
# == MAIN TARGETS ==
|
||||
|
||||
@@ -35,6 +44,9 @@ pack: $(PACKDIR)/tultemplate2.zip
|
||||
bundle: $(BUNDLE_TARGETS)
|
||||
@echo "!! Bundles are made for tultemplategen and not for direct use !!"
|
||||
|
||||
.PHONY: minimal
|
||||
minimal: $(MINIMAL_TARGETS) $(MINIMALDIR)/tultemplate2_minimal.zip
|
||||
|
||||
.PHONY: watch_documentation
|
||||
watch_documentation: $(BUILD_DIR)/documentation.pdf
|
||||
xdg-open $< & typst watch --font-path template/fonts documentation.typ $<
|
||||
@@ -59,12 +71,18 @@ $(BUILD_DIR):
|
||||
$(PACKS_ROOT): | $(BUILD_DIR)
|
||||
mkdir $@
|
||||
|
||||
$(PACKSTAGING): | $(PACKS_ROOT)
|
||||
mkdir $@
|
||||
|
||||
$(PACKDIR): | $(PACKS_ROOT)
|
||||
mkdir $@
|
||||
|
||||
$(BUNDLEDIR): | $(PACKS_ROOT)
|
||||
mkdir $@
|
||||
|
||||
$(MINIMALDIR): | $(PACKS_ROOT)
|
||||
mkdir $@
|
||||
|
||||
# == UTILS ==
|
||||
|
||||
define minify_csl
|
||||
@@ -136,61 +154,51 @@ $(BUILD_DIR)/%.pdf: $(BUILD_DIR)/%.typ $(TEMPLATE_SRCS) | $(BUILD_DIR)
|
||||
template/example_appendix.pdf: theses/example_appendix.typ
|
||||
$(call typst_compile) $< $@
|
||||
|
||||
# == PACKS - clean builds for direct use ==
|
||||
# == PACK STAGING - files prepared for packing or bundling ==
|
||||
|
||||
$(PACKDIR)/%: % | $(PACKDIR)
|
||||
ln -f $< $@
|
||||
|
||||
$(PACKDIR)/template: | $(PACKDIR)
|
||||
$(PACKSTAGING)/template: | $(PACKSTAGING)
|
||||
mkdir $@
|
||||
|
||||
$(PACKDIR)/template/LICENSE: LICENSE | $(PACKDIR)/template
|
||||
$(PACKSTAGING)/template/citations: | $(PACKSTAGING)/template
|
||||
mkdir $@
|
||||
|
||||
$(PACKSTAGING)/template/LICENSE: LICENSE | $(PACKSTAGING)/template
|
||||
ln -f $< $@
|
||||
|
||||
$(PACKDIR)/Makefile: packed.mk | $(PACKDIR)
|
||||
ln -f $< $@
|
||||
|
||||
$(PACKDIR)/template/tul_citace.csl: template/tul_citace.csl | $(PACKDIR)/template
|
||||
$(PACKSTAGING)/template/citations/%: template/citations/% | $(PACKSTAGING)/template/citations
|
||||
$(call minify_csl,$<,$@)
|
||||
|
||||
$(PACKDIR)/template/lang.json: template/lang.json | $(PACKDIR)/template
|
||||
$(PACKSTAGING)/template/lang.json: template/lang.json | $(PACKSTAGING)/template
|
||||
$(call minify_json,$<,$@)
|
||||
|
||||
$(PACKDIR)/template/%: template/% | $(PACKDIR)/template
|
||||
$(PACKSTAGING)/documentation.pdf: $(BUILD_DIR)/documentation.pdf | $(PACKSTAGING)
|
||||
ln -f $< $@
|
||||
|
||||
$(PACKSTAGING)/%.pdf: $(BUILD_DIR)/%.pdf | $(PACKSTAGING)
|
||||
ln -f $< $@
|
||||
|
||||
$(PACKSTAGING)/%: % | $(PACKSTAGING)
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
$(PACKDIR)/%.pdf: $(BUILD_DIR)/%.pdf | $(PACKDIR)
|
||||
# == PACKS - clean builds for direct use ==
|
||||
|
||||
$(PACKDIR)/Makefile: packed.mk | $(PACKDIR)
|
||||
ln -f $< $@
|
||||
|
||||
$(PACKDIR)/tultemplate2.zip: $(PACK_TARGETS) | $(PACKDIR)
|
||||
rm -f $@
|
||||
cd $(PACKS_ROOT) && zip -r tultemplate2.zip tultemplate2
|
||||
|
||||
$(PACKDIR)/%: $(PACKSTAGING)/% | $(PACKDIR)
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
# == BUNDLES - packs for tultemplategen ==
|
||||
|
||||
$(BUNDLEDIR)/template: | $(BUNDLEDIR)
|
||||
mkdir $@
|
||||
|
||||
$(BUNDLEDIR)/template/LICENSE: LICENSE | $(BUNDLEDIR)/template
|
||||
ln -f $< $@
|
||||
|
||||
$(BUNDLEDIR)/Makefile: templategen.mk | $(BUNDLEDIR)
|
||||
ln -f $< $@
|
||||
|
||||
$(BUNDLEDIR)/template/tul_citace.csl: template/tul_citace.csl | $(BUNDLEDIR)/template
|
||||
$(call minify_csl,$<,$@)
|
||||
|
||||
$(BUNDLEDIR)/template/lang.json: template/lang.json | $(BUNDLEDIR)/template
|
||||
$(call minify_json,$<,$@)
|
||||
|
||||
$(BUNDLEDIR)/citations.bib: citations.bib | $(BUNDLEDIR)
|
||||
ln -f $< $@
|
||||
|
||||
$(BUNDLEDIR)/template/%: template/% | $(BUNDLEDIR)/template
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
$(BUNDLEDIR)/presentation_%.typ: theses/presentation_%.typ | $(BUNDLEDIR)
|
||||
cat $< | awk 'BEGIN{RS=""; ORS="\n\n"} NR>2{print}' > $@
|
||||
|
||||
@@ -203,6 +211,20 @@ $(BUNDLEDIR)/title-pages.pdf: theses/title_pages.typ | $(BUNDLEDIR)
|
||||
$(BUNDLEDIR)/assignment.pdf: theses/assignment.typ | $(BUNDLEDIR)
|
||||
$(call typst_compile) $< $@
|
||||
|
||||
$(BUNDLEDIR)/%: $(PACKSTAGING)/% | $(BUNDLEDIR)
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
# == MINIMAL - stripped-down template packs ==
|
||||
|
||||
$(MINIMALDIR)/%: $(PACKSTAGING)/% | $(MINIMALDIR)
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
$(MINIMALDIR)/tultemplate2_minimal.zip: $(MINIMAL_TARGETS) | $(MINIMALDIR)
|
||||
rm -f $@
|
||||
cd $(MINIMALDIR) && zip -r $(notdir $@) template
|
||||
|
||||
# == TESTS ==
|
||||
|
||||
include tests/make.mk
|
||||
|
||||
@@ -143,4 +143,7 @@ We also have (at the moment):
|
||||
- `dp_en`
|
||||
- `prj_cs`
|
||||
- `prj_en`
|
||||
- `sp_cs`
|
||||
- `sp_en`
|
||||
- `presentation_cs`
|
||||
- `presentation_en`
|
||||
|
||||
@@ -426,6 +426,18 @@ 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.
|
||||
|
||||
#pagebreak(weak: true)
|
||||
= Argumenty šablony
|
||||
|
||||
Následujících pár stránek je kompletní soupis argumentů, které tato šablona přijímá.
|
||||
Pokud s šablonou nemáte rozsáhlé zkušenosti, doporučujeme raději využít generátoru
|
||||
(https://tulsablona.zumepro.cz/generate/).
|
||||
|
||||
// Automaticky generovaný seznam argumentů
|
||||
#import "template/arguments.typ": print_argument_docs
|
||||
#print_argument_docs(lang: "cs")
|
||||
|
||||
|
||||
#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.]),
|
||||
|
||||
18
flake.nix
18
flake.nix
@@ -97,18 +97,32 @@
|
||||
in
|
||||
{
|
||||
devShell = with pkgs; mkShell {
|
||||
inherit buildInputs;
|
||||
buildInputs = buildInputs ++ [ (pkgs.stdenv.mkDerivation {
|
||||
name = name + "-typstfmt";
|
||||
dontUnpack = true;
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
ln -s ${typstyle}/bin/typstyle $out/bin/typstyle
|
||||
ln -s ${writeShellScript "tultypstfmt" ''
|
||||
typstyle --inplace -l 100 $@
|
||||
''} $out/bin/ttfmt
|
||||
'';
|
||||
}) ];
|
||||
shellHook = envSetup;
|
||||
};
|
||||
packages.bundle = build_with_targets "bundle" ["bundle"] ["target/pack/bundle/."] [];
|
||||
packages.theses = build "theses" (builtins.map (file: "${file}.pdf") [
|
||||
"documentation"
|
||||
"bp_cs" "bp_en"
|
||||
"dp_cs" "dp_en"
|
||||
"prj_cs" "prj_en"
|
||||
"sp_cs" "sp_en"
|
||||
"presentation_cs"
|
||||
"presentation_cs" "presentation_en"
|
||||
]) typstPkgs;
|
||||
packages.pack = build_with_targets "pack" ["pack"] ["target/pack/."] [];
|
||||
packages.minimal = build_with_targets "minimal" ["minimal"] [
|
||||
"target/pack/minimal/."
|
||||
] [];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,156 +1,464 @@
|
||||
#import "utils.typ": assert_type_signature, is_none, map_none, deref, assert_dict_has
|
||||
|
||||
#let arguments_structure = (
|
||||
document: (
|
||||
visual_style: "string",
|
||||
faculty: "string",
|
||||
language: "string",
|
||||
type: "string",
|
||||
),
|
||||
title_pages: "string | boolean | none",
|
||||
title: "dictionary[string : string | content] | none",
|
||||
author: (
|
||||
name: "string | content | none",
|
||||
pronouns: "string | none",
|
||||
programme: "dictionary[string : string | content] | none",
|
||||
specialization: "dictionary[string : string | content] | none",
|
||||
year_of_study: "string | content | none",
|
||||
),
|
||||
project: (
|
||||
supervisor: "string | content | dictionary[string : string | content] | none",
|
||||
consultant: "string | content | dictionary[string : string | content] | none",
|
||||
),
|
||||
abstract: (
|
||||
content: "dictionary[string : string | content] | none",
|
||||
keywords: "dictionary[string : string | content | array[string]] | none",
|
||||
),
|
||||
acknowledgement: "dictionary[string : string | content] | none",
|
||||
assignment: "dictionary[string : any] | content | string | none",
|
||||
presentation_info: "dictionary[string: any] | none",
|
||||
citations: "string",
|
||||
);
|
||||
|
||||
#let assignment_structure = (
|
||||
personal_number: "string | content",
|
||||
department: "string | content",
|
||||
academical_year: "string | content",
|
||||
content: "content",
|
||||
);
|
||||
|
||||
#let presentation_structure = (
|
||||
append_thanks: "boolean",
|
||||
wide: "boolean",
|
||||
first_heading_is_fullpage: "boolean",
|
||||
)
|
||||
#import "utils.typ": assert_dict_has, assert_type_signature, deref, is_none, map_none
|
||||
#import "type_signature.typ": *
|
||||
|
||||
|
||||
#let check_arguments(args, structure: arguments_structure, namespace: none) = {
|
||||
let check_arguments_dict(structure, args, argument_path) = {
|
||||
for (key, value) in structure.pairs() {
|
||||
argument_path.push(str(key).replace("_", " "));
|
||||
#let arguments_structure = {
|
||||
let lang_keys = variants(literal("cs"), literal("en"))
|
||||
let nonrec_str = doc(string, none, (
|
||||
cs: "Je doporučeno použít 'content', pokud je to možné",
|
||||
en: "It is recommended to use 'content' where that's possible",
|
||||
))
|
||||
let cont_or_str = variants(cont, nonrec_str)
|
||||
let opt_cont_or_str = variants(cont, nonrec_str, null)
|
||||
|
||||
if not key in args {
|
||||
panic("invalid arguments definition");
|
||||
}
|
||||
let arg = args.at(key);
|
||||
// == DOCUMENT ==
|
||||
let document = {
|
||||
let visual_style = doc(keyval(literal("visual_style"), variants(literal("classic"))), "style", (
|
||||
cs: "Vizuální styl šablony",
|
||||
en: "Visual style of the template",
|
||||
))
|
||||
|
||||
if type(value) == dictionary {
|
||||
check_arguments_dict(value, arg, argument_path);
|
||||
} else if type(value) == str {
|
||||
assert_type_signature(arg, value, argument_path.join(" "));
|
||||
} else {
|
||||
panic("invalid arguments definition");
|
||||
}
|
||||
let faculty = doc(
|
||||
keyval(literal("faculty"), variants(
|
||||
doc(literal("fs"), none, (cs: "Fakulta strojní", en: "Faculty of mechanical engineering")),
|
||||
doc(literal("ft"), none, (cs: "Fakulta textilní", en: "Faculty of textile engineering")),
|
||||
doc(literal("fp"), none, (
|
||||
cs: "Fakulta přírodovědně-humanitní a pedagogická",
|
||||
en: "Faculty of science, humanities and education",
|
||||
)),
|
||||
doc(literal("ef"), none, (cs: "Ekonomická fakulta", en: "Faculty of economics")),
|
||||
doc(literal("fua"), none, (
|
||||
cs: "Fakulta umění a architektury",
|
||||
en: "Faculty of arts and architecture",
|
||||
)),
|
||||
doc(literal("fm"), none, (
|
||||
cs: "Fakulta mechatroniky, informatiky a mezioborových studií",
|
||||
en: "Faculty of mechatronics, informatics and interdisciplinary studies",
|
||||
)),
|
||||
doc(literal("fzs"), none, (
|
||||
cs: "Fakulta zdravotnických studií",
|
||||
en: "Faculty of health studies",
|
||||
)),
|
||||
doc(literal("cxi"), none, (
|
||||
cs: "Ústav pro nanomateriály, pokročilé technologie a inovace",
|
||||
en: "Institute for nanomaterials, advanced technology and innovation",
|
||||
)),
|
||||
doc(literal("tul"), none, (cs: "Obecný styl TUL", en: "Generic TUL theme")),
|
||||
)),
|
||||
"faculty",
|
||||
(
|
||||
cs: "Fakulta (na základě toho budou vybrány barvy, logotypy, ...)",
|
||||
en: "Faculty (based on this, the theme of the document will be chosen)",
|
||||
),
|
||||
)
|
||||
|
||||
let _ = argument_path.pop();
|
||||
}
|
||||
let language = doc(
|
||||
keyval(literal("language"), variants(
|
||||
doc(literal("cs"), none, (cs: "Čeština", en: "Czech")),
|
||||
doc(literal("en"), none, (cs: "Angličtina", en: "English")),
|
||||
)),
|
||||
"lang",
|
||||
(cs: "Primární jazyk dokumentu", en: "Primary language of the document"),
|
||||
)
|
||||
|
||||
let type = doc(
|
||||
keyval(literal("type"), variants(
|
||||
doc(literal("bp"), none, (cs: "Bakalářská práce", en: "Bachelor's thesis")),
|
||||
doc(literal("dp"), none, (cs: "Diplomová práce", en: "Diploma thesis")),
|
||||
doc(literal("prj"), none, (
|
||||
cs: "Projekt (ročník před odevzdáním bakalářské práce)",
|
||||
en: "Project (the year before bachelor's thesis)",
|
||||
)),
|
||||
doc(literal("sp"), none, (cs: "Semestrální práce", en: "Term paper")),
|
||||
doc(literal("presentation"), none, (cs: "Prezentace", en: "Presentation")),
|
||||
doc(literal("other"), none, (cs: "Obecný dokument", en: "Generic dokument")),
|
||||
)),
|
||||
"document",
|
||||
(cs: "Typ dokumentu", en: "The type of the document"),
|
||||
)
|
||||
|
||||
let content_only = doc(
|
||||
keyval(literal("content_only"), bool),
|
||||
"content_only",
|
||||
(
|
||||
cs: "Zda u dokumentu typu `other` generovat pouze obsah",
|
||||
en: "Whether to generate only content for document of type `other`",
|
||||
),
|
||||
)
|
||||
|
||||
keyval(literal("document"), struct(visual_style, faculty, language, type, content_only))
|
||||
}
|
||||
|
||||
check_arguments_dict(structure, args, if is_none(namespace) { () } else { (namespace,) });
|
||||
// == TITLE PAGES ==
|
||||
let title_pages = doc(
|
||||
keyval(
|
||||
literal("title_pages"),
|
||||
variants(
|
||||
doc(string, none, (
|
||||
cs: "Cesta k souboru PDF, který má být vložen",
|
||||
en: "The path to the PDF document to insert",
|
||||
)),
|
||||
doc(
|
||||
null,
|
||||
none,
|
||||
(
|
||||
cs: "Stránky jsou generovány pomocí šablony. Tohle u některých prací může vyžadovat doplnění informací (argumentů).",
|
||||
en: "The pages are generated through the template. This can require more arguments for certain documents.",
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
"title_pages",
|
||||
(
|
||||
cs: "Způsob generování stránek na začátku dokumentu",
|
||||
en: "Method of inserting/generating the first few pages of the document",
|
||||
),
|
||||
)
|
||||
|
||||
// == TITLE ==
|
||||
let title = doc(
|
||||
keyval(literal("title"), dict(keyval(
|
||||
variants(
|
||||
// title
|
||||
doc(literal("cs"), none, (cs: "Název práce v češtině", en: "Document title in Czech")),
|
||||
doc(literal("en"), none, (cs: "Název práce v angličtině", en: "Document title in English")),
|
||||
),
|
||||
cont_or_str,
|
||||
))),
|
||||
"title",
|
||||
(cs: "Název práce", en: "Document title"),
|
||||
)
|
||||
|
||||
// == AUTHOR ==
|
||||
let author = {
|
||||
let name = doc(keyval(literal("name"), opt_cont_or_str), "author", (
|
||||
cs: "Jméno autora včetně titulů",
|
||||
en: "The name of the author including titles",
|
||||
))
|
||||
|
||||
let pronouns = doc(
|
||||
keyval(literal("pronouns"), variants(
|
||||
doc(literal("masculine"), none, (
|
||||
cs: "Pro češtinu, oslovení v mužském rodě",
|
||||
en: "For Czech (masculine)",
|
||||
)),
|
||||
doc(literal("feminine"), none, (
|
||||
cs: "Pro češtinu, oslovení v ženském rodě",
|
||||
en: "For Czech (feminine)",
|
||||
)),
|
||||
doc(literal("we"), none, (
|
||||
cs: "Pro češtinu a angličtinu, oslovení v množném čísle",
|
||||
en: "For Czech and English, plural",
|
||||
)),
|
||||
doc(literal("me"), none, (
|
||||
cs: "Pro angličtinu, oslovení v jednotném čísle",
|
||||
en: "For English, singular",
|
||||
)),
|
||||
doc(null, none, (
|
||||
cs: "Pro angličtinu, oslovení v jednotném čísle",
|
||||
en: "Fallback for English, singular",
|
||||
)),
|
||||
)),
|
||||
"author",
|
||||
(cs: "Oslovení autora / autorů", en: "Author pronouns"),
|
||||
)
|
||||
|
||||
let programme = doc(
|
||||
keyval(literal("programme"), variants(dict(keyval(lang_keys, cont_or_str)), null)),
|
||||
"programme",
|
||||
(
|
||||
cs: "Studijní program, pod kterým byl tento dokument vytvořen",
|
||||
en: "Study programme of the author",
|
||||
),
|
||||
)
|
||||
|
||||
let specialization = doc(
|
||||
keyval(literal("specialization"), variants(dict(keyval(lang_keys, cont_or_str)), null)),
|
||||
"specialization",
|
||||
(
|
||||
cs: "Specializace, pod kterou byl tento dokument vytvořen",
|
||||
en: "Specialization of the author",
|
||||
),
|
||||
)
|
||||
|
||||
let year_of_study = doc(keyval(literal("year_of_study"), opt_cont_or_str), "year_of_study", (
|
||||
cs: "Ročník studia autora",
|
||||
en: "The year of study of the author",
|
||||
))
|
||||
|
||||
keyval(literal("author"), struct(name, pronouns, programme, specialization, year_of_study))
|
||||
}
|
||||
|
||||
// == PROJECT ==
|
||||
let project = {
|
||||
let supervisor = doc(
|
||||
keyval(literal("supervisor"), variants(
|
||||
cont,
|
||||
nonrec_str,
|
||||
struct(
|
||||
doc(keyval(literal("name"), cont_or_str), none, (
|
||||
cs: "Jméno vedoucího projektu",
|
||||
en: "The name of the project's supervisor",
|
||||
)),
|
||||
doc(keyval(literal("institute"), cont_or_str), none, (
|
||||
cs: "Ústav vedoucího projektu",
|
||||
en: "The institute of the project's supervisor",
|
||||
)),
|
||||
),
|
||||
null,
|
||||
)),
|
||||
"supervisor",
|
||||
(cs: "Vedoucí projektu", en: "Project supervisor"),
|
||||
)
|
||||
|
||||
let consultant = doc(
|
||||
keyval(literal("consultant"), variants(
|
||||
cont,
|
||||
nonrec_str,
|
||||
struct(
|
||||
doc(keyval(literal("name"), cont_or_str), none, (
|
||||
cs: "Jméno konzultanta projektu",
|
||||
en: "Name of the project's consultant",
|
||||
)),
|
||||
doc(keyval(literal("institute"), cont_or_str), none, (
|
||||
cs: "Ústav konzultanta projektu",
|
||||
en: "The institute of the project's consultant",
|
||||
)),
|
||||
),
|
||||
null,
|
||||
)),
|
||||
"consultant",
|
||||
(cs: "Konzultant projektu", en: "Project's consultant"),
|
||||
)
|
||||
|
||||
keyval(literal("project"), struct(supervisor, consultant))
|
||||
}
|
||||
|
||||
// == ABSTRACT ==
|
||||
let abstract = {
|
||||
let content = doc(
|
||||
keyval(literal("content"), variants(
|
||||
struct(..lang_keys.variants.map(k => {
|
||||
keyval(k, variants(cont, nonrec_str, slice(string)))
|
||||
})),
|
||||
null,
|
||||
)),
|
||||
"abstract",
|
||||
(cs: "Abstrakt projektu", en: "Project's abstract"),
|
||||
)
|
||||
|
||||
let keywords = doc(
|
||||
keyval(literal("keywords"), variants(
|
||||
struct(..lang_keys.variants.map(k => {
|
||||
keyval(k, variants(cont, nonrec_str, slice(string)))
|
||||
})),
|
||||
null,
|
||||
)),
|
||||
"keywords",
|
||||
(cs: "Klíčová slova projektu", en: "Project's keywords"),
|
||||
)
|
||||
|
||||
keyval(literal("abstract"), struct(content, keywords))
|
||||
}
|
||||
|
||||
// == ACKNOWLEDGEMENT ==
|
||||
let acknowledgement = doc(
|
||||
keyval(literal("acknowledgement"), variants(dict(keyval(lang_keys, cont_or_str)), null)),
|
||||
"acknowledgement",
|
||||
(cs: "Poděkování", en: "Acknowledgement"),
|
||||
)
|
||||
|
||||
// == ASSIGNMENT ==
|
||||
let assignment = doc(
|
||||
// assignment
|
||||
keyval(
|
||||
literal("assignment"),
|
||||
variants(
|
||||
doc(string, none, (
|
||||
cs: "Zadání bude vloženo z PDF souboru s touto cestou",
|
||||
en: "The assignment will be inserted from a PDF file with this path",
|
||||
)),
|
||||
doc(
|
||||
struct(
|
||||
keyval(literal("personal_number"), cont_or_str),
|
||||
keyval(literal("department"), cont_or_str),
|
||||
keyval(literal("academical_year"), cont_or_str),
|
||||
doc(keyval(literal("content"), cont), none, (
|
||||
cs: "Obsah zadání (zobrazen pod informacemi)",
|
||||
en: "Content of the assignment (shown bellow informations)",
|
||||
)),
|
||||
),
|
||||
none,
|
||||
(
|
||||
cs: "Zadání bude vygenerováno šablonou",
|
||||
en: "The assignment will be creating through this template",
|
||||
),
|
||||
),
|
||||
doc(
|
||||
null,
|
||||
none,
|
||||
(
|
||||
cs: "Pokud je zadání vyžadováno typem dokumentu, bude vložena strana s upozorněním na vložení",
|
||||
en: "If the assignment is required by the document type, a page with a warning will be inserted",
|
||||
),
|
||||
),
|
||||
doc(cont, none, (
|
||||
cs: "Zdrojový kód se zadáním (tato možnost se nedoporučuje)",
|
||||
en: "Source code for the page (is not recommended)",
|
||||
)),
|
||||
),
|
||||
),
|
||||
"assignment",
|
||||
(cs: "Stránka / stránky se zadáním", en: "Page / pages with the assignment"),
|
||||
)
|
||||
|
||||
// == PRESENTATION ==
|
||||
let presentation_info = {
|
||||
let append_thanks = doc(keyval(literal("append_thanks"), bool), none, (
|
||||
cs: "Zda na konec prezentace vložit poděkování za pozornost",
|
||||
en: "Whether to thank for attention at the end of the presentation",
|
||||
))
|
||||
|
||||
let wide = doc(keyval(literal("wide"), bool), none, (
|
||||
cs: "Jestli použít široký režim (16:9 - `true`) nebo úzký (4:3 - `false`)",
|
||||
en: "Whether to use widescreen format (16:9 - `true`) or narrow format (4:3 - `false`)",
|
||||
))
|
||||
|
||||
let first_heading_is_fullpage = doc(
|
||||
keyval(literal("first_heading_is_fullpage"), bool),
|
||||
none,
|
||||
(
|
||||
cs: "Pokud je nastaveno `true`, pak se nadpisy první úrovně budou vkládat na samostatnou stránku",
|
||||
en: "When set to `true`, headings of first level will be on a separate page",
|
||||
),
|
||||
)
|
||||
|
||||
doc(
|
||||
keyval(literal("presentation_info"), variants(null, struct(
|
||||
append_thanks,
|
||||
wide,
|
||||
first_heading_is_fullpage,
|
||||
))),
|
||||
"presentation",
|
||||
(
|
||||
cs: "Argumenty pro dokument typu `presentation`",
|
||||
en: "Arguments for a document of type `presentation`",
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
// == CITATIONS ==
|
||||
let citations = doc(
|
||||
// citations
|
||||
keyval(literal("citations"), variants(
|
||||
doc(string, none, (
|
||||
cs: "Cesta k souboru s bibliografií",
|
||||
en: "The path to the bibliography file",
|
||||
)),
|
||||
doc(slice(string), none, (
|
||||
cs: "Cesty k souborům s bibliografií",
|
||||
en: "Paths to the bibliography files",
|
||||
)),
|
||||
)),
|
||||
"citations",
|
||||
(cs: "Zdroj bibliografie", en: "Bibliography source"),
|
||||
)
|
||||
|
||||
struct(
|
||||
document,
|
||||
title_pages,
|
||||
title,
|
||||
author,
|
||||
project,
|
||||
abstract,
|
||||
acknowledgement,
|
||||
assignment,
|
||||
presentation_info,
|
||||
citations,
|
||||
)
|
||||
}
|
||||
|
||||
#let print_argument_docs(lang: "en") = {
|
||||
signature_docs(arguments_structure, lang: lang)
|
||||
}
|
||||
|
||||
#let check_arguments(args, structure: arguments_structure, namespace: none) = {
|
||||
let res = signature_check(args, structure, "")
|
||||
if not res.at(0) {
|
||||
let panic_message = res.at(1)
|
||||
panic(panic_message)
|
||||
}
|
||||
}
|
||||
|
||||
#let get_arg_single(args, path) = {
|
||||
let args = args;
|
||||
let args = args
|
||||
for segment in path.split(".") {
|
||||
if segment not in args {
|
||||
panic("invalid argument query path: " + str(path));
|
||||
panic("invalid argument query path: " + str(path))
|
||||
}
|
||||
args = args.at(segment);
|
||||
args = args.at(segment)
|
||||
}
|
||||
args
|
||||
}
|
||||
|
||||
#let get_arg(args, path) = {
|
||||
if type(path) == array {
|
||||
let res = ();
|
||||
let res = ()
|
||||
for path in path {
|
||||
res.push(get_arg_single(args, path));
|
||||
res.push(get_arg_single(args, path))
|
||||
}
|
||||
res
|
||||
} else if type(path) == str {
|
||||
get_arg_single(args, path)
|
||||
} else {
|
||||
panic("invalid argument path");
|
||||
panic("invalid argument path")
|
||||
}
|
||||
}
|
||||
|
||||
#let req_arg_single(args, path) = {
|
||||
let arg = get_arg_single(args, path);
|
||||
let arg = get_arg_single(args, path)
|
||||
if is_none(arg) {
|
||||
let panic_message = path.split(".").join(" ").replace("_", " ") + " is missing";
|
||||
panic(panic_message);
|
||||
let panic_message = (
|
||||
path.split(".").join(" ").replace("_", " ") + " is missing"
|
||||
)
|
||||
panic(panic_message)
|
||||
}
|
||||
arg
|
||||
}
|
||||
|
||||
#let req_arg(args, path) = {
|
||||
if type(path) == array {
|
||||
let res = ();
|
||||
let res = ()
|
||||
for path in path {
|
||||
res.push(req_arg_single(args, path));
|
||||
res.push(req_arg_single(args, path))
|
||||
}
|
||||
res
|
||||
} else if type(path) == str {
|
||||
req_arg_single(args, path)
|
||||
} else {
|
||||
panic("invalid argument path");
|
||||
panic("invalid argument path")
|
||||
}
|
||||
}
|
||||
|
||||
#let map_arg_single(args, path, mapper) = {
|
||||
let arg = get_arg(args, path);
|
||||
let arg = get_arg(args, path)
|
||||
map_none(arg, mapper)
|
||||
}
|
||||
|
||||
#let map_arg(args, path, mapper) = {
|
||||
if type(path) == array {
|
||||
let res = ();
|
||||
let res = ()
|
||||
for path in path {
|
||||
res.push(map_arg_single(args, path, mapper));
|
||||
res.push(map_arg_single(args, path, mapper))
|
||||
}
|
||||
res
|
||||
} else if type(path) == str {
|
||||
map_arg_single(args, path, mapper)
|
||||
} else {
|
||||
panic("invalid argument path");
|
||||
panic("invalid argument path")
|
||||
}
|
||||
}
|
||||
|
||||
#let assignment_info(assignment) = {
|
||||
if type(assignment) == dictionary {
|
||||
assert_dict_has(assignment_structure.keys(), assignment, "assignment");
|
||||
check_arguments(assignment, structure: assignment_structure, namespace: "assignment");
|
||||
}
|
||||
assignment
|
||||
}
|
||||
|
||||
#let presentation_info(presentation) = {
|
||||
if not is_none(presentation) {
|
||||
check_arguments(presentation, structure: presentation_structure, namespace: "presentation")
|
||||
}
|
||||
presentation
|
||||
}
|
||||
|
||||
#let arguments(
|
||||
document_info,
|
||||
title_pages,
|
||||
@@ -171,18 +479,25 @@
|
||||
project: project_info,
|
||||
abstract: abstract_info,
|
||||
acknowledgement: acknowledgement,
|
||||
assignment: assignment_info(assignment),
|
||||
presentation_info: presentation_info(presentation),
|
||||
assignment: assignment,
|
||||
presentation_info: presentation,
|
||||
citations: citations,
|
||||
)
|
||||
}
|
||||
|
||||
#let document_info(visual_style, faculty_abbreviation, language_abbreviation, document_type) = {
|
||||
#let document_info(
|
||||
visual_style,
|
||||
faculty_abbreviation,
|
||||
language_abbreviation,
|
||||
document_type,
|
||||
content_only,
|
||||
) = {
|
||||
(
|
||||
visual_style: visual_style,
|
||||
faculty: faculty_abbreviation,
|
||||
language: language_abbreviation,
|
||||
type: document_type,
|
||||
content_only: content_only,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// 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, is_none
|
||||
#import "../arguments.typ": req_arg, map_arg, get_arg
|
||||
#import "../theme.typ": faculty_color, faculty_logotype, tul_logomark
|
||||
#import "../lang.typ": get_lang_item, lang_id
|
||||
#import "../utils.typ": assert_dict_has, assert_in_arr, assert_in_dict, is_none, map_none
|
||||
#import "../arguments.typ": get_arg, map_arg, req_arg
|
||||
#import "common.typ": default_styling, external_title_pages
|
||||
|
||||
// thesis types
|
||||
@@ -10,7 +10,7 @@
|
||||
#import "dp.typ": dp
|
||||
#import "prj.typ": prj
|
||||
#import "sp.typ": sp
|
||||
#import "other.typ": other_title_page, other_base
|
||||
#import "other.typ": other_base, other_title_page
|
||||
#import "thesis_base.typ": thesis_base, thesis_base_title_pages
|
||||
#import "presentation.typ": presentation
|
||||
|
||||
@@ -18,69 +18,85 @@
|
||||
"bp": (root: bp, base: thesis_base, title_pages: thesis_base_title_pages),
|
||||
"dp": (root: dp, base: thesis_base, title_pages: thesis_base_title_pages),
|
||||
"prj": (root: prj, base: thesis_base, title_pages: thesis_base_title_pages),
|
||||
"sp": (root: sp, base: thesis_base.with(
|
||||
show_disclaimer: false,
|
||||
require_abstract: false,
|
||||
), title_pages: thesis_base_title_pages),
|
||||
"sp": (
|
||||
root: sp,
|
||||
base: thesis_base.with(
|
||||
show_disclaimer: false,
|
||||
require_abstract: false,
|
||||
),
|
||||
title_pages: thesis_base_title_pages,
|
||||
),
|
||||
"other": (root: other_title_page, base: other_base),
|
||||
"presentation": (base: presentation,),
|
||||
"presentation": (base: presentation),
|
||||
)
|
||||
|
||||
#let prep_args(args) = {
|
||||
let language = req_arg(args, "document.language");
|
||||
let language = req_arg(args, "document.language")
|
||||
|
||||
// argument pre-checking
|
||||
assert_in_dict(req_arg(args, "document.type"), document_types, "document type");
|
||||
map_arg(args, "title", (v) => assert_dict_has((language,), v, "title"));
|
||||
map_arg(args, "author.programme", (v) => assert_dict_has((language,), v, "study programme"));
|
||||
assert_in_dict(req_arg(args, "document.type"), document_types, "document type")
|
||||
map_arg(args, "title", v => assert_dict_has((language,), v, "title"))
|
||||
map_arg(args, "author.programme", v => assert_dict_has((language,), v, "study programme"))
|
||||
map_arg(
|
||||
args, "author.specialization", (v) => assert_dict_has((language,), v, "study specialization")
|
||||
);
|
||||
args,
|
||||
"author.specialization",
|
||||
v => assert_dict_has((language,), v, "study specialization"),
|
||||
)
|
||||
map_arg(
|
||||
args, "acknowledgement", (v) => assert_dict_has((language,), v, "acknowledgement content")
|
||||
);
|
||||
args,
|
||||
"acknowledgement",
|
||||
v => assert_dict_has((language,), v, "acknowledgement content"),
|
||||
)
|
||||
|
||||
args.assignment = map_arg(args, "assignment", (v) => {
|
||||
args.assignment = map_arg(args, "assignment", v => {
|
||||
if type(v) == str {
|
||||
"../../" + v
|
||||
} else {
|
||||
v
|
||||
}
|
||||
});
|
||||
args.citations = map_arg(args, "citations", (v) => "../../" + v);
|
||||
args.title_pages = map_arg(args, "title_pages", (v) => "../../" + v);
|
||||
})
|
||||
args.citations = map_arg(args, "citations", v => {
|
||||
if type(v) == array {
|
||||
v.map(v => { "../../" + v })
|
||||
} else if type(v) == str {
|
||||
"../../" + v
|
||||
} else {
|
||||
panic()
|
||||
}
|
||||
})
|
||||
args.title_pages = map_arg(args, "title_pages", v => "../../" + v)
|
||||
|
||||
args
|
||||
}
|
||||
|
||||
#let template_classic(args, content) = {
|
||||
let args = prep_args(args);
|
||||
let args = prep_args(args)
|
||||
|
||||
let doctype = req_arg(args, "document.type");
|
||||
let doc = document_types.at(doctype);
|
||||
let doctype = req_arg(args, "document.type")
|
||||
let doc = document_types.at(doctype)
|
||||
if "root" in doc {
|
||||
if not is_none(get_arg(args, "title_pages")) {
|
||||
external_title_pages(req_arg(args, "title_pages"));
|
||||
doc.at("base")(args, content);
|
||||
external_title_pages(req_arg(args, "title_pages"))
|
||||
doc.at("base")(args, content)
|
||||
} else {
|
||||
doc.at("root")(args);
|
||||
doc.at("base")(args, content);
|
||||
doc.at("root")(args)
|
||||
doc.at("base")(args, content)
|
||||
}
|
||||
} else {
|
||||
doc.at("base")(args, content);
|
||||
doc.at("base")(args, content)
|
||||
}
|
||||
}
|
||||
|
||||
#let title_pages_classic(args) = {
|
||||
let args = prep_args(args);
|
||||
let args = prep_args(args)
|
||||
|
||||
let doctype = req_arg(args, "document.type");
|
||||
let doc = document_types.at(doctype);
|
||||
let doctype = req_arg(args, "document.type")
|
||||
let doc = document_types.at(doctype)
|
||||
if "title_pages" in doc {
|
||||
doc.at("root")(args);
|
||||
doc.at("title_pages")(args);
|
||||
doc.at("root")(args)
|
||||
doc.at("title_pages")(args)
|
||||
} else {
|
||||
let panic_message = "document of type '" + doctype + "' can't generate title pages";
|
||||
panic(panic_message);
|
||||
let panic_message = "document of type '" + doctype + "' can't generate title pages"
|
||||
panic(panic_message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
if type(it.dest) == label or type(it.dest) == location {
|
||||
it;
|
||||
} else {
|
||||
text(it, fill: faculty_color);
|
||||
text(underline(it), fill: faculty_color);
|
||||
}
|
||||
}
|
||||
set highlight(fill: faculty_color.lighten(90%));
|
||||
@@ -247,9 +247,9 @@
|
||||
set page(margin: 2cm);
|
||||
pagebreak(weak: true);
|
||||
if has_all_none((
|
||||
document_type, title, author, supervisor, consultant, study_programme,
|
||||
title, author, supervisor, consultant, study_programme, study_specialization, year_of_study
|
||||
)) {
|
||||
place(center + horizon, align(left, faculty_logotype(faculty_id, language)));
|
||||
place(center + horizon, align(left, text(faculty_logotype(faculty, language), size: 1.5em)));
|
||||
} else {
|
||||
header(faculty, language);
|
||||
align({
|
||||
@@ -343,6 +343,7 @@
|
||||
"author.name",
|
||||
));
|
||||
let author_pronouns = get_arg(args, "author.pronouns");
|
||||
set page(footer: none)
|
||||
heading(get_lang_item(language, "disclaimer"), numbering: none, outlined: false);
|
||||
par(
|
||||
text(disclaimer(language, disclaimer_type, author_pronouns))
|
||||
@@ -366,6 +367,7 @@
|
||||
if is_none(content) {
|
||||
return;
|
||||
}
|
||||
set page(footer: none)
|
||||
heading(get_lang_item(language, "acknowledgement"), numbering: none, outlined: false);
|
||||
par(content.at(language));
|
||||
v(2em);
|
||||
@@ -386,6 +388,7 @@
|
||||
if not require and is_none(get_arg(args, "abstract.content")) {
|
||||
return;
|
||||
}
|
||||
set page(footer: none)
|
||||
heading(
|
||||
text(req_arg(args, "title").at(language), font: base_font), numbering: none, outlined: false
|
||||
);
|
||||
@@ -463,19 +466,29 @@
|
||||
|
||||
// ABBREVIATION LIST
|
||||
|
||||
#let abbrlist(language) = {
|
||||
#let abbrlist(language, hidden: false) = {
|
||||
import "../abbreviations.typ": abbrlist
|
||||
if hidden {
|
||||
context {
|
||||
let abbrs = abbrlist()
|
||||
for abbr in abbrs.pairs() {
|
||||
[#metadata("empty")#label("abbr_" + abbr.at(0))]
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
context {
|
||||
let abbrs = abbrlist();
|
||||
let max_abbr_width = if abbrs.len() > 0 {
|
||||
calc.max(abbrs.keys().map((v) => measure(v).width)).at(0)
|
||||
} else { return };
|
||||
let abbr_pairs = abbrs.pairs().sorted(key: it => it.at(0))
|
||||
pagebreak(weak: true);
|
||||
heading(get_lang_item(language, "abbrs"), numbering: none);
|
||||
align(center, grid(
|
||||
columns: 2,
|
||||
gutter: 1em,
|
||||
..abbrs.pairs().map((a) => {
|
||||
..abbr_pairs.map((a) => {
|
||||
(
|
||||
align(left, {
|
||||
[
|
||||
@@ -483,7 +496,7 @@
|
||||
#label("abbr_" + a.at(0))
|
||||
]
|
||||
}),
|
||||
text(a.at(1))
|
||||
align(left, text(a.at(1)))
|
||||
)
|
||||
}).flatten()
|
||||
));
|
||||
@@ -507,7 +520,7 @@
|
||||
// BIBLIOGRAPHY
|
||||
|
||||
#let bibliogr(args) = {
|
||||
let (language, citations_file) = req_arg(args, ("document.language", "citations"));
|
||||
let (language, citations) = req_arg(args, ("document.language", "citations"));
|
||||
let styles = (
|
||||
"cs": "../citations/tul-csn690-numeric-square_brackets.csl",
|
||||
"en": "../citations/iso690-numeric-square_brackets.csl",
|
||||
@@ -516,7 +529,7 @@
|
||||
context {
|
||||
if query(ref.where(element: none)).len() > 0 {
|
||||
bibliography(
|
||||
citations_file,
|
||||
citations,
|
||||
style: style,
|
||||
title: get_lang_item(language, "bibliography"),
|
||||
);
|
||||
|
||||
@@ -1,38 +1,43 @@
|
||||
#import "../lang.typ": get_lang_item
|
||||
#import "common.typ": (
|
||||
mainpage,
|
||||
default_styling,
|
||||
assignment,
|
||||
disclaimer,
|
||||
abstract,
|
||||
toc,
|
||||
abbrlist,
|
||||
imagelist,
|
||||
tablelist,
|
||||
bibliogr,
|
||||
abbrlist, abstract, assignment, bibliogr, default_styling, disclaimer, imagelist, mainpage,
|
||||
tablelist, toc,
|
||||
)
|
||||
#import "../attachments.typ": attachment_list
|
||||
#import "../utils.typ": is_none, assert_not_none, assert_dict_has, assert_in_arr
|
||||
#import "../arguments.typ": req_arg
|
||||
#import "../utils.typ": assert_dict_has, assert_in_arr, assert_not_none, is_none
|
||||
#import "../arguments.typ": get_arg, map_arg, req_arg
|
||||
#import "../theme.typ": faculty_color
|
||||
|
||||
#let other_title_page(args) = {
|
||||
let (language, title) = req_arg(args, ("document.language", "title"));
|
||||
assert_dict_has((language,), title, "title");
|
||||
mainpage(args);
|
||||
if req_arg(args, "document.content_only") {
|
||||
return
|
||||
}
|
||||
let language = req_arg(args, "document.language")
|
||||
let title = get_arg(args, "title")
|
||||
map_arg(args, "title", v => { assert_dict_has((language,), v, "title") })
|
||||
mainpage(args)
|
||||
}
|
||||
|
||||
#let other_base(args, content) = {
|
||||
let (language, title) = req_arg(args, ("document.language", "title"));
|
||||
let language = req_arg(args, "document.language")
|
||||
|
||||
default_styling(true, faculty_color(req_arg(args, "document.faculty")), {
|
||||
toc(language);
|
||||
tablelist(language);
|
||||
imagelist(language);
|
||||
abbrlist(language);
|
||||
pagebreak(to: "even", weak: true);
|
||||
content;
|
||||
bibliogr(args);
|
||||
attachment_list(language);
|
||||
}, language);
|
||||
default_styling(
|
||||
true,
|
||||
faculty_color(req_arg(args, "document.faculty")),
|
||||
{
|
||||
if not req_arg(args, "document.content_only") {
|
||||
toc(language)
|
||||
tablelist(language)
|
||||
imagelist(language)
|
||||
abbrlist(language)
|
||||
pagebreak(to: "even", weak: true)
|
||||
} else {
|
||||
abbrlist(language, hidden: true)
|
||||
}
|
||||
content
|
||||
bibliogr(args)
|
||||
attachment_list(language)
|
||||
},
|
||||
language,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
// - assignment (str): Filepath of the assignment document/page.
|
||||
// - citations (str): The location of the citation file.
|
||||
// - presentation (dictionary): Arguments for the presentation
|
||||
// - content_only (bool): Whether to output content only (this works for documents of type `other`)
|
||||
// - content (content): The content of the document
|
||||
//
|
||||
//-> none
|
||||
@@ -51,7 +52,7 @@
|
||||
title_pages: none,
|
||||
title: none, keywords: none, abstract: none, acknowledgement: none, author: none,
|
||||
author_pronouns: none, supervisor: none, consultant: none, programme: none,
|
||||
specialization: none, year_of_study: none,
|
||||
specialization: none, year_of_study: none, content_only: false,
|
||||
|
||||
// nested
|
||||
assignment: none, presentation: none,
|
||||
@@ -72,7 +73,7 @@
|
||||
)
|
||||
|
||||
let args = arguments(
|
||||
document_info(style, faculty, lang, document),
|
||||
document_info(style, faculty, lang, document, content_only),
|
||||
title_pages,
|
||||
title,
|
||||
author_info(author, author_pronouns, programme, specialization, year_of_study),
|
||||
@@ -125,7 +126,7 @@
|
||||
req_arg,
|
||||
)
|
||||
let args = arguments(
|
||||
document_info(style, faculty, lang, document),
|
||||
document_info(style, faculty, lang, document, false),
|
||||
none,
|
||||
title,
|
||||
author_info(author, author_pronouns, programme, specialization, year_of_study),
|
||||
|
||||
397
template/type_signature.typ
Normal file
397
template/type_signature.typ
Normal file
@@ -0,0 +1,397 @@
|
||||
#let doc(inner, argument_name, explanations) = {
|
||||
inner.doc = (argname: argument_name, expl: explanations)
|
||||
inner
|
||||
}
|
||||
|
||||
#let type_primitive(id, name, cs_name, en_name) = {
|
||||
(type: "primitive", type_id: id, type_name: name, primitive_expl: (cs: cs_name, en: en_name))
|
||||
}
|
||||
|
||||
#let int = type_primitive("integer", "an 'integer'", "celé číslo", "a whole number");
|
||||
#let float = type_primitive("float", "a 'float'", "desetinné číslo", "a decimal number");
|
||||
#let bool = type_primitive("boolean", "a 'boolean'", "pravdivostní hodnota", "a truthiness value");
|
||||
#let string = type_primitive("string", "a 'string'", "textový řetězec", "a text string");
|
||||
#let cont = type_primitive(
|
||||
"content",
|
||||
"a 'content'",
|
||||
"obsah generovaný Typst syntaxí",
|
||||
"content generated with Typst syntax",
|
||||
);
|
||||
#let null = type_primitive("none", "a 'none'", "prázdná hodnota", "empty value");
|
||||
|
||||
#let literal(value) = {
|
||||
(type: "literal", value: value)
|
||||
}
|
||||
|
||||
#let variants(..variants) = {
|
||||
(type: "variants", variants: variants.pos())
|
||||
}
|
||||
|
||||
#let slice(items) = {
|
||||
(type: "slice", items: items)
|
||||
}
|
||||
|
||||
#let tuple(..items) = {
|
||||
(type: "tuple", items: items.pos())
|
||||
}
|
||||
|
||||
#let keyval(key, val) = {
|
||||
(type: "keyval", key: key, val: val)
|
||||
}
|
||||
|
||||
#let dict(keyval) = {
|
||||
(type: "dictionary", key: keyval.key, val: keyval.val)
|
||||
}
|
||||
|
||||
#let struct(..keyvals) = {
|
||||
let copy_doc(from, to) = {
|
||||
if "doc" in from {
|
||||
let to = to
|
||||
to.doc = from.doc
|
||||
to
|
||||
} else {
|
||||
to
|
||||
}
|
||||
}
|
||||
|
||||
let keyvals = keyvals.pos()
|
||||
let res = ().to-dict()
|
||||
for keyval in keyvals {
|
||||
if keyval.key.type != "literal" {
|
||||
panic("invalid type signature, struct keys must be literals")
|
||||
}
|
||||
res.insert(keyval.key.value, copy_doc(keyval, keyval.val))
|
||||
}
|
||||
(type: "struct", pairs: res)
|
||||
}
|
||||
|
||||
#let dbg_literal(literal, is_content: false) = {
|
||||
let res = if type(literal) == str {
|
||||
"\"" + literal + "\""
|
||||
} else {
|
||||
"'" + str(literal) + "'"
|
||||
}
|
||||
if is_content {
|
||||
raw(res)
|
||||
} else {
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
#let dbg_type(value) = {
|
||||
str(type(value))
|
||||
}
|
||||
|
||||
#let signature_check(value, signature, name_prefix) = {
|
||||
let error_target_name(target, name_prefix) = {
|
||||
name_prefix + if "doc" in target { " ('" + target.doc.argname + "')" } else { "" }
|
||||
}
|
||||
|
||||
let error_value_name(value) = {
|
||||
str(type(value))
|
||||
}
|
||||
|
||||
let error_expected_type(target) = {
|
||||
if target.type == "variants" {
|
||||
let variants = target.variants
|
||||
let last = variants.pop()
|
||||
let res = (variants.map(v => { error_expected_type(v) })).join(", ")
|
||||
if type(last) != type(none) {
|
||||
if type(res) != type(none) {
|
||||
res + " or " + error_expected_type(last)
|
||||
} else {
|
||||
error_expected_type(last)
|
||||
}
|
||||
} else {
|
||||
res
|
||||
}
|
||||
} else if target.type == "slice" or target.type == "tuple" {
|
||||
"an array"
|
||||
} else if target.type == "dictionary" or target.type == "struct" {
|
||||
"a dictionary/hashmap"
|
||||
} else if target.type == "primitive" {
|
||||
target.type_name
|
||||
} else if target.type == "literal" {
|
||||
dbg_literal(target.value)
|
||||
} else {
|
||||
panic()
|
||||
}
|
||||
}
|
||||
|
||||
let error(target, name_prefix, value, is_value: false, target_doc: none) = {
|
||||
(
|
||||
if type(target_doc) != type(none) {
|
||||
error_target_name(target_doc)
|
||||
} else {
|
||||
error_target_name(target, name_prefix)
|
||||
}
|
||||
+ (
|
||||
" of type '"
|
||||
+ dbg_type(value)
|
||||
+ "' is unexpected, expected "
|
||||
+ error_expected_type(target)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
let in_variants(value, variants, matcher) = {
|
||||
for variant in variants {
|
||||
if matcher(value, variant).at(0) == true {
|
||||
return true
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
let opt_suffix(prefix, suffix: " ") = {
|
||||
if prefix.len() == 0 {
|
||||
""
|
||||
} else {
|
||||
prefix + suffix
|
||||
}
|
||||
}
|
||||
|
||||
let matches_type(value, target, name_prefix: "") = {
|
||||
if target.type == "variants" {
|
||||
return if in_variants(value, target.variants, matches_type.with(name_prefix: name_prefix)) {
|
||||
(true,)
|
||||
} else {
|
||||
(false, error(target, name_prefix, value, is_value: true))
|
||||
}
|
||||
} else if target.type == "literal" {
|
||||
return if value != target.value {
|
||||
(false, error(target, name_prefix, value, is_value: true))
|
||||
} else {
|
||||
(true,)
|
||||
}
|
||||
}
|
||||
if type(value) == dictionary {
|
||||
if target.type == "struct" {
|
||||
for key in target.pairs.keys() {
|
||||
if key not in value {
|
||||
return (
|
||||
false,
|
||||
(
|
||||
error_target_name(target, name_prefix)
|
||||
+ " is missing an entry for key "
|
||||
+ dbg_literal(key)
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
for (key, val) in value.pairs() {
|
||||
if key not in target.pairs {
|
||||
return (
|
||||
false,
|
||||
opt_suffix(name_prefix) + "contains an unexpected key " + dbg_literal(key),
|
||||
)
|
||||
}
|
||||
let res = matches_type(
|
||||
val,
|
||||
target.pairs.at(key),
|
||||
name_prefix: opt_suffix(name_prefix) + str(key),
|
||||
)
|
||||
if not res.at(0) {
|
||||
return res
|
||||
} else {
|
||||
res
|
||||
}
|
||||
}
|
||||
} else if target.type == "dictionary" {
|
||||
for (key, val) in value.pairs() {
|
||||
let cur = matches_type(key, target.key, name_prefix: opt_suffix(name_prefix) + "key")
|
||||
if not cur.at(0) {
|
||||
return cur
|
||||
}
|
||||
let cur = matches_type(val, target.val, name_prefix: opt_suffix(name_prefix) + "value")
|
||||
if not cur.at(0) {
|
||||
return cur
|
||||
}
|
||||
}
|
||||
(true,)
|
||||
} else {
|
||||
(false, error(target, name_prefix, value))
|
||||
}
|
||||
} else if type(value) == array {
|
||||
if target.type == "slice" {
|
||||
for (idx, val) in value.enumerate() {
|
||||
let cur = matches_type(
|
||||
val,
|
||||
target.items,
|
||||
name_prefix: opt_suffix(name_prefix) + "item at index " + str(idx),
|
||||
)
|
||||
if not cur.at(0) {
|
||||
return cur
|
||||
}
|
||||
}
|
||||
(true,)
|
||||
} else if target.type == "tuple" {
|
||||
for (idx, target) in target.items.enumerate() {
|
||||
if idx >= value.len() {
|
||||
return (
|
||||
false,
|
||||
opt_suffix(name_prefix) + "is missing an item: " + error_expected_type(target),
|
||||
)
|
||||
}
|
||||
let cur = matches_type(
|
||||
value.at(idx),
|
||||
target,
|
||||
name_prefix: opt_suffix(name_prefix) + "item at index " + str(idx),
|
||||
)
|
||||
if not cur.at(0) {
|
||||
return cur
|
||||
}
|
||||
}
|
||||
(true,)
|
||||
} else {
|
||||
(false, error(target, name_prefix, value))
|
||||
}
|
||||
} else {
|
||||
if target.type != "primitive" or str(type(value)) != target.type_id {
|
||||
(false, error(target, name_prefix, value))
|
||||
} else {
|
||||
(true,)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
matches_type(value, signature, name_prefix: name_prefix)
|
||||
}
|
||||
|
||||
#let signature_docs(target, is_nested: false, lang: "en") = {
|
||||
let lang_expr = (
|
||||
with_keys: (cs: "S klíči", en: "With keys"),
|
||||
with_values: (cs: "S hodnotami", en: "With values"),
|
||||
empty: (cs: [prádzné (_none_)], en: [empty (_none_)]),
|
||||
struct: (
|
||||
cs: [slovník s přesnými atributy (_dictionary_)],
|
||||
en: [a dictionary with exact atributes (_dictionary_)],
|
||||
),
|
||||
dict: (cs: [slovník (_dictionary_)], en: [_dictionary_]),
|
||||
slice: (cs: [pole různé délky (_array_): ], en: [variable-length array (_array_): ]),
|
||||
tuple: (cs: [pole s přesnými prvky (_array_): ], en: [array with exact items (_array_): ]),
|
||||
)
|
||||
|
||||
let typeinfo(target, flatten: false, disable_doc: false) = {
|
||||
let try_doc(target, mapper: v => { v }) = {
|
||||
if "doc" in target and not disable_doc {
|
||||
mapper(target.doc.expl.at(lang))
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
if target.type == "struct" {
|
||||
if not flatten {
|
||||
lang_expr.struct.at(lang)
|
||||
try_doc(target, mapper: v => {
|
||||
[ -- ]
|
||||
v
|
||||
})
|
||||
":"
|
||||
}
|
||||
list(..target
|
||||
.pairs
|
||||
.pairs()
|
||||
.map(((key, val)) => {
|
||||
raw(key)
|
||||
try_doc(val, mapper: v => {
|
||||
[ -- ]
|
||||
text(v)
|
||||
})
|
||||
": "
|
||||
typeinfo(val, disable_doc: true)
|
||||
}))
|
||||
} else if target.type == "dictionary" {
|
||||
lang_expr.struct.at(lang)
|
||||
try_doc(target, mapper: v => {
|
||||
[ -- ]
|
||||
v
|
||||
})
|
||||
":"
|
||||
list(
|
||||
{
|
||||
lang_expr.with_keys.at(lang) + ": "
|
||||
typeinfo(target.key)
|
||||
},
|
||||
{
|
||||
lang_expr.with_values.at(lang) + ": "
|
||||
typeinfo(target.val)
|
||||
},
|
||||
)
|
||||
} else if target.type == "slice" {
|
||||
try_doc(target, mapper: v => {
|
||||
v
|
||||
": "
|
||||
})
|
||||
lang_expr.slice.at(lang)
|
||||
typeinfo(target.items, disable_doc: true)
|
||||
} else if target.type == "tuple" {
|
||||
try_doc(target, mapper: v => {
|
||||
v
|
||||
": "
|
||||
})
|
||||
lang_expr.tuple.at(lang)
|
||||
list(..target.items.map(v => {
|
||||
list.item({
|
||||
typeinfo(v)
|
||||
})
|
||||
}))
|
||||
} else if target.type == "primitive" {
|
||||
if target.type_id == "none" {
|
||||
lang_expr.empty.at(lang)
|
||||
try_doc(target, mapper: v => {
|
||||
[ -- ]
|
||||
text(v)
|
||||
})
|
||||
} else {
|
||||
text(target.primitive_expl.at(lang) + " (")
|
||||
text(target.type_id, style: "italic")
|
||||
text(")")
|
||||
try_doc(target, mapper: v => {
|
||||
[ -- ]
|
||||
text(v)
|
||||
})
|
||||
}
|
||||
} else if target.type == "variants" {
|
||||
try_doc(target, mapper: v => {
|
||||
text(v)
|
||||
":"
|
||||
})
|
||||
list(..target.variants.map(v => {
|
||||
list.item({
|
||||
typeinfo(v)
|
||||
})
|
||||
}))
|
||||
} else if target.type == "literal" {
|
||||
dbg_literal(target.value, is_content: true)
|
||||
try_doc(target, mapper: v => {
|
||||
[ -- ]
|
||||
text(v)
|
||||
})
|
||||
} else {
|
||||
panic()
|
||||
}
|
||||
}
|
||||
|
||||
let args = ()
|
||||
if target.type == "struct" {
|
||||
for val in target.pairs.values() {
|
||||
args.push(signature_docs(val, is_nested: true, lang: lang))
|
||||
}
|
||||
} else {
|
||||
if "doc" in target and type(target.doc.argname) != type(none) {
|
||||
args.push({
|
||||
raw(target.doc.argname)
|
||||
[ -- ]
|
||||
typeinfo(target)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if not is_nested {
|
||||
list(spacing: 2em, ..args.flatten())
|
||||
} else {
|
||||
args.flatten()
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
- tato šablona slouží jako ukázka použití Typst TUL šablony k tvorbě prezentace
|
||||
- můžete zde používat všechny funkcionality Typstu, stejně jako u ostatních dokumentů
|
||||
- slajdy fungují podobně jako v Latexu - každý nadpis je nový slajd
|
||||
- slajdy fungují podobně jako v Latexu - každý nadpis 1. úrovně tvoří nový slajd
|
||||
- v případě použití _first_heading_is_fullpage_ neplatí - viz dále
|
||||
- možno používat i nadpisy druhé úrovně
|
||||
|
||||
@@ -33,8 +33,9 @@
|
||||
|
||||
- _append_thanks_: Jestli na závěr přidat slajd s poděkováním
|
||||
- _wide_: Použití formátu 16:9 místo 4:3 na všechny slajdy
|
||||
- _first_heading_is_fullpage_: V případě použití vloží každý nadpis 1. úrovně na samostatný slajd, takže logicky rozčlení prezentaci
|
||||
- _first_heading_is_fullpage_: vloží každý nadpis 1. úrovně na samostatný slajd, takže logicky rozčlení prezentaci
|
||||
- zároveň tvoří nový slajd pro každý nadpis 2. úrovně
|
||||
- pokud je vypnuta, nadpisy 2. úrovně *netvoří* nový slajd
|
||||
|
||||
== Struktura
|
||||
|
||||
|
||||
49
theses/presentation_en.typ
Normal file
49
theses/presentation_en.typ
Normal file
@@ -0,0 +1,49 @@
|
||||
#import "../template/template.typ": *
|
||||
|
||||
#show: tultemplate2.with(
|
||||
style: "classic",
|
||||
faculty: "fm",
|
||||
lang: "en",
|
||||
document: "presentation",
|
||||
author: [Ondřej Mekina],
|
||||
title: (
|
||||
en: [Example presentation using the tultemplate2 template],
|
||||
),
|
||||
presentation: (
|
||||
append_thanks: true,
|
||||
wide: false,
|
||||
first_heading_is_fullpage: true,
|
||||
),
|
||||
citations: "citations.bib",
|
||||
)
|
||||
|
||||
= Intro
|
||||
|
||||
== How to use this presentation
|
||||
|
||||
- this template serves as a demo usage of the Typst TUL template for creating presentations
|
||||
- you can use all the functionalities of Typst, the same you would in all the other documents
|
||||
- slides are created in a similiar fashion to LaTeX - each level 1 heading detones a new slide
|
||||
- this behaves differently when using the _first_heading_is_fullpage_ option - more on that later
|
||||
- you can also use level 2 headings
|
||||
|
||||
= Template options
|
||||
|
||||
== Template function arguments
|
||||
|
||||
- _append_thanks_: Whether to end the presentation with a Thank you slide
|
||||
- _wide_: Using the 16:9 aspect ratio for all slides instead of 4:3
|
||||
- _first_heading_is_fullpage_: creates a standalone page for each level 1 heading, this breaks down the presentation nicely
|
||||
- also creates a new slide for each level 2 heading
|
||||
- if the option is not set, level 2 headings *do not* create a new slide
|
||||
|
||||
== Structure
|
||||
|
||||
- The presentations begins with a title page - configured in the generator
|
||||
- there is no automatically generated table of contents - the user may create it easily using dashes or an ordered list
|
||||
- after the content of the presentation, there is a slide with all citation sources - this one is automatically generated
|
||||
- optionally a Thank you slide
|
||||
|
||||
== Usage of citations
|
||||
|
||||
- here are two example citations: Citation 1 @typst and citation 2 @bibtex
|
||||
Reference in New Issue
Block a user