9 Commits

11 changed files with 121 additions and 47 deletions

View File

@@ -1,45 +1,81 @@
.PHONY: view_example .PHONY: view_example
view_example: example.pdf view_example: documentation.pdf
xdg-open $< xdg-open $<
.PHONY: watch_example .PHONY: watch_documentation
watch_example: watch_documentation:
typst watch --font-path template/fonts example.typ & xdg-open example.pdf typst watch --font-path template/fonts documentation.typ & xdg-open documentation.pdf
.PHONY: example .PHONY: documentation
example: example.pdf documentation: documentation.pdf
PACKDIR := pack/tultemplate2
BUNDLEDIR := pack/bundle
TO_PACK := $(shell find template -type f) template/LICENSE TO_PACK := $(shell find template -type f) template/LICENSE
PACK_TARGETS := $(TO_PACK:%=pack/tultemplate2/%) pack/tultemplate2/example.typ \ BUNDLE_TARGETS := $(TO_PACK:%=$(BUNDLEDIR)/%) $(BUNDLEDIR)/citations.bib $(BUNDLEDIR)/Makefile
pack/tultemplate2/citations.bib PACK_TARGETS := $(TO_PACK:%=$(PACKDIR)/%) $(PACKDIR)/documentation.typ \
$(PACKDIR)/documentation.pdf $(PACKDIR)/citations.bib
.PHONY: pack .PHONY: pack
pack: pack/tultemplate2.zip pack: pack/tultemplate2.zip
.PHONY: bundle
bundle: $(BUNDLE_TARGETS)
.PHONY: clean .PHONY: clean
clean: clean:
rm -rf pack rm -rf pack
rm -f example.pdf rm -f documentation.pdf
pack/tultemplate2.zip: $(PACK_TARGETS) pack/tultemplate2.zip: $(PACK_TARGETS)
@mkdir -p $(@D) @mkdir -p $(@D)
rm -f $@ rm -f $@
cd pack && zip -r tultemplate2.zip tultemplate2 cd pack && zip -r tultemplate2.zip tultemplate2
pack/tultemplate2/%: % $(PACKDIR)/%: %
ln -f $< $@
pack/tultemplate2/template/LICENSE: LICENSE
@mkdir -p $(@D) @mkdir -p $(@D)
ln -f $< $@ ln -f $< $@
pack/tultemplate2/template/%: template/% $(BUNDLEDIR)/citations.bib:
@mkdir -p $(@D)
touch $@
$(BUNDLEDIR)/Makefile: templategen.mk
@mkdir -p $(@D)
ln -f $< $@
$(PACKDIR)/template/LICENSE: LICENSE
@mkdir -p $(@D)
ln -f $< $@
$(BUNDLEDIR)/template/LICENSE: LICENSE
@mkdir -p $(@D)
ln -f $< $@
$(PACKDIR)/template/tul_citace.csl $(BUNDLEDIR)/template/tul_citace.csl: template/tul_citace.csl
@mkdir -p $(@D)
cat $< | sed 's/^\s*\(.*\)$$/\1/' | tr -d '\n' > $@
$(PACKDIR)/template/lang.json: template/lang.json
@mkdir -p $(@D)
cat $< | jq -c > $@
$(BUNDLEDIR)/template/lang.json: template/lang.json
@mkdir -p $(@D)
cat $< | jq -c > $@
$(PACKDIR)/template/%: template/%
@mkdir -p $(@D)
ln -f $< $@
$(BUNDLEDIR)/template/%: template/%
@mkdir -p $(@D) @mkdir -p $(@D)
ln -f $< $@ ln -f $< $@
TEMPLATE_SRCS := $(shell find template -type f) TEMPLATE_SRCS := $(shell find template -type f)
%.pdf: %.typ $(TEMPLATE_SRCS) documentation.pdf: documentation.typ $(TEMPLATE_SRCS)
typst compile --font-path template/fonts $< typst compile --font-path template/fonts $<
include tests/make.mk include tests/make.mk

View File

@@ -21,3 +21,5 @@ That will compile the example document and view it.
> [!IMPORTANT] > [!IMPORTANT]
> This repo uses git lfs to pull fonts. Please set it up (or download a packed build from releases). > This repo uses git lfs to pull fonts. Please set it up (or download a packed build from releases).
> When running in CLI - you'll want to include the embedded fonts:
> `typst compile --font-path template/fonts example.typ`

View File

@@ -91,7 +91,7 @@ opravdu hodně vám to usnadní práci.
// tohle je podnadpis :) // tohle je podnadpis :)
#heading( #heading(
level: 3, level: 2,
range(1, 6).map((v) => range(1, v).map((_) => "pod").join("") + "nadpisy").join(", ") + ", ..." range(1, 6).map((v) => range(1, v).map((_) => "pod").join("") + "nadpisy").join(", ") + ", ..."
)<chained_subheading> )<chained_subheading>
@@ -331,7 +331,7 @@ Zvýrazněné hodnoty jsou základní -- pokud vynecháte parametr, pak bude pou
- `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` (jazykový rod autora - není potřeba pro angličtinu, která základní hodnotu) - `author_pronouns` (jazykový rod autora - není potřeba pro angličtinu, která základní hodnotu)
- Pro vybraný jazyk _cs_: - Pro vybraný jazyk _cs_:
- `"masculine"` - Mužský rod - `"masculine"` - Mužský rod
- `"feminine"` - Ženský rod - `"feminine"` - Ženský rod
@@ -422,8 +422,14 @@ Zde je ukázka definice příloh (je také použita na konci tohoto ukázkového
```typst ```typst
#attachments( #attachments(
attach_link("Zdrojový kód této šablony", "https://git.zumepro.cz/tul/tultemplate2"), attach_link(
attach_content("Testovací obsah vygenerovaný Typstem", [Sem lze psát _stylovaný_ obsah.]), "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

@@ -20,8 +20,8 @@
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, title, author, author_pronouns, supervisor, consultant, study_programme, study_branch,
abstract_content, acknowledgement_content, keywords, year_of_study, abstract_content, acknowledgement_content, keywords,
content content
) = { ) = {
@@ -41,7 +41,7 @@
} }
assert_not_none(acknowledgement_content, "acknowledgement content"); 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");
} }
assert_type_signature(supervisor, "string | none", "supervisor"); assert_type_signature(supervisor, "string | none", "supervisor");
@@ -49,11 +49,11 @@
mainpage( mainpage(
faculty_id, language, "bp", title, author, supervisor, consultant, study_programme, faculty_id, language, "bp", title, author, supervisor, consultant, study_programme,
study_branch, 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); acknowledgement(language, author, acknowledgement_content);

View File

@@ -12,8 +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, title, author, author_pronouns, supervisor, consultant, study_programme, study_branch,
acknowledgement, keywords, year_of_study, abstract, acknowledgement, keywords,
// content // content
content, content,
@@ -37,11 +37,12 @@
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, acknowledgement,
keywords, keywords,

View File

@@ -1,9 +1,10 @@
#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, assert_dict_has #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";
#let mono_font_compensation = 1.3em;
#let serif_font = "Merriweather"; #let serif_font = "Merriweather";
#let tul_logomark_size = 6.5em; #let tul_logomark_size = 6.5em;
@@ -71,10 +72,17 @@
}; };
// other // other
show raw: set text(font: mono_font); show raw: set text(font: mono_font, size: mono_font_compensation);
show raw.where(block: true): it => { show raw.where(block: true): it => {
block(it, fill: rgb("#eee"), inset: 1em) block(it, fill: rgb("#eee"), inset: 1em)
}; };
show link: it => {
if type(it.dest) == label or type(it.dest) == location {
it;
} else {
text(it, fill: faculty_color);
}
}
set highlight(fill: faculty_color.lighten(90%)); set highlight(fill: faculty_color.lighten(90%));
content content
@@ -119,7 +127,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,
) = { ) = {
let info_name_value_padding = 5em; let info_name_value_padding = 5em;
let info_name_min_width = 10em; let info_name_min_width = 10em;
@@ -141,11 +149,12 @@
// other info // other info
// [field_name, field_value, bold] // [field_name, field_value, bold]
let info_fields = ( let info_fields = (
("study_programme", study_programme, false),
("study_branch", study_branch, false),
("author", author, true), ("author", author, true),
("supervisor", person_info(supervisor, "supervisor"), false), ("supervisor", person_info(supervisor, "supervisor"), false),
("consultant", person_info(consultant, "consultant"), false), ("consultant", person_info(consultant, "consultant"), false),
("study_programme", study_programme, false),
("study_branch", study_branch, false),
("year_of_study", map_none(year_of_study, (v) => str(v) + "."), 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) => {
@@ -180,7 +189,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);
@@ -195,7 +204,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);
@@ -227,11 +236,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(

View File

@@ -18,15 +18,18 @@
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, title, author, _, supervisor, consultant, study_programme, study_branch, year_of_study,
_, keywords, 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);
tablelist(language); tablelist(language);

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",
@@ -56,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",

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,7 +28,7 @@
// - 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. // - consultant (str): The name of the document's consultant.
// - programme (dictionary): Study programme. // - programme (dictionary): Study programme.
@@ -46,7 +46,8 @@
// document info // document info
title: none, keywords: none, abstract: none, acknowledgement: none, author: none, title: none, keywords: none, abstract: none, acknowledgement: none, author: none,
author_gender: 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",
@@ -70,7 +71,7 @@
acknowledgement, "dictionary[string : string] | none", "acknowledgement content" 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( assert_type_signature(
supervisor, "string | dictionary[string : string] | none", "supervisor argument" supervisor, "string | dictionary[string : string] | none", "supervisor argument"
); );
@@ -81,6 +82,7 @@
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");
@@ -99,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, acknowledgement, keywords, content programme, branch, year_of_study, abstract, acknowledgement, keywords, content
); );
import "prototyping.typ": assert_release_ready import "prototyping.typ": assert_release_ready

13
templategen.mk Normal file
View File

@@ -0,0 +1,13 @@
THESIS_FILE := thesis
TYPST_FONTPATH := --font-path template/fonts
.PHONY: watch
watch: $(THESIS_FILE).pdf
xdg-open $< & typst watch $(TYPST_FONTPATH) $(THESIS_FILE).typ
.PHONY: view
view: $(THESIS_FILE).pdf
xdg-open $<
%.pdf: %.typ
typst compile $(TYPST_FONTPATH) $<