11 Commits

8 changed files with 170 additions and 21 deletions

View File

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

View File

@@ -21,3 +21,5 @@ That will compile the example document and view it.
> [!IMPORTANT]
> 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 :)
#heading(
level: 3,
level: 2,
range(1, 6).map((v) => range(1, v).map((_) => "pod").join("") + "nadpisy").join(", ") + ", ..."
)<chained_subheading>
@@ -323,6 +323,7 @@ Zvýrazněné hodnoty jsou základní -- pokud vynecháte parametr, pak bude pou
- `document` (typ dokumentu)
- *`"other"`* - nespecifikovaný (neformální) typ dokumentu
- `bp` - Bakalářská práce
- `dp` - Diplomová práce
#line()
- `title` (nadpis dokumentu)
- Ve formátu `(<zkratka_jazyka>: "<nadpis>")`, například `(cs: "Můj nadpis")`
@@ -422,8 +423,14 @@ Zde je ukázka definice příloh (je také použita na konci tohoto ukázkového
```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.]),
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

@@ -5,6 +5,7 @@
// thesis types
#import "bp.typ": bp
#import "dp.typ": dp
#import "other.typ": other
#let template_classic(
@@ -21,6 +22,7 @@
// argument pre-checking
let document_types = (
"bp": bp,
"dp": dp,
"other": other,
)
assert_in_dict(document_type, document_types, "document type");

View File

@@ -4,6 +4,7 @@
#let base_font = "Inter";
#let mono_font = "Noto Sans Mono";
#let mono_font_compensation = 1.3em;
#let serif_font = "Merriweather";
#let tul_logomark_size = 6.5em;
@@ -71,10 +72,17 @@
};
// 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 => {
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%));
content

68
template/classic/dp.typ Normal file
View File

@@ -0,0 +1,68 @@
#import "../lang.typ": get_lang_item
#import "common.typ": (
mainpage,
default_styling,
assignment,
disclaimer,
abstract,
acknowledgement,
toc,
abbrlist,
imagelist,
tablelist,
bibliogr
)
#import "../attachments.typ": attachment_list
#import "../utils.typ": is_none, assert_dict_has, assert_not_none, assert_type_signature, map_none
#let dp(
// general settings
faculty_id, faculty_color, language, assignment_document, citation_file,
// document info
title, author, author_pronouns, supervisor, consultant, study_programme, study_branch,
year_of_study, abstract_content, acknowledgement_content, keywords,
content
) = {
let force_langs = ("cs", "en");
assert_not_none(title, "title");
assert_dict_has(force_langs, title, "title");
assert_not_none(study_programme, "study programme");
assert_dict_has((language,), study_programme, "study programme");
map_none(study_branch, (v) => assert_dict_has((language,), v, "study branch"));
assert_not_none(abstract_content, "abstract");
assert_dict_has(force_langs, abstract_content, "abstract");
if not is_none(keywords) {
assert_dict_has(force_langs, keywords, "keywords");
}
assert_not_none(acknowledgement_content, "acknowledgement content");
if language == "cs" {
assert_not_none(author_pronouns, "author gender");
}
assert_type_signature(supervisor, "string | none", "supervisor");
assert_type_signature(consultant, "string | none", "consultant");
mainpage(
faculty_id, language, "dp", title, author, supervisor, consultant, study_programme,
study_branch, year_of_study,
);
assignment(language, assignment_document);
default_styling(false, faculty_color, {
disclaimer(language, faculty_id, "dp", author, author_pronouns);
abstract("cs", title, abstract_content, keywords);
abstract("en", title, abstract_content, keywords);
acknowledgement(language, author, acknowledgement_content);
toc(language);
tablelist(language);
imagelist(language);
abbrlist(language);
pagebreak(weak: true);
content;
bibliogr(language, citation_file);
attachment_list(language);
});
}

View File

@@ -9,6 +9,7 @@
"year_of_study": "Ročník",
"bp": "Bakalářská práce",
"dp": "Diplomová práce",
"city": "Liberec",
@@ -31,6 +32,21 @@
"svůj": "svoji",
"jejímu": "jejímu",
"zveřejněn": "zveřejněna"
},
"dp": {
"práce:ta": "diplomová práce",
"práce:tu": "diplomovou práci",
"práce:té": "diplomové práce",
"moji": "moji",
"naše": "naše",
"naši": "naši",
"naší": "naší",
"mé": "mé",
"můj": "moje",
"svůj": "svoji",
"jejímu": "jejímu",
"zveřejněn": "zveřejněna"
}
},
@@ -60,6 +76,7 @@
"year_of_study": "Year of study",
"bp": "Bachelor thesis",
"dp": "Diploma thesis",
"city": "Liberec",
@@ -71,6 +88,10 @@
"disclaimer_replace": {
"bp": {
"thesis": "bachelor thesis"
},
"dp": {
"thesis": "diploma thesis"
}
},

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) $<