Compare commits

...

6 Commits

3 changed files with 86 additions and 21 deletions

View File

@@ -14,18 +14,29 @@ curl "https://stag.tul.cz/StagPortletsJSR168/ProhlizeniPrint?stateClass=cz.zcu.s
}] }]
}] | from_entries' >> programmes.js }] | from_entries' >> programmes.js
if [ ! -d template_upstream ]; then TEMPLATE=template_upstream
git clone git@gordon.zumepro.cz:tul/tultemplate2 template_upstream
if [ ! -d $TEMPLATE ]; then
git clone git@gordon.zumepro.cz:tul/tultemplate2 $TEMPLATE
else else
cd template_upstream cd $TEMPLATE
git pull git fetch --tags
cd .. cd ..
fi fi
cd $TEMPLATE
git checkout $(git describe --tags "$(git rev-list --tags --max-count=1)")
cd ..
TEMPLATE_PACKDIR=$TEMPLATE/pack/bundle
rm -r $TEMPLATE_PACKDIR
cd $TEMPLATE
make bundle
cd ..
cp -r \ cp -r \
template_upstream/template \ $TEMPLATE_PACKDIR/. \
template_upstream/citations.bib \
template_upstream/Makefile \
assignment.pdf \ assignment.pdf \
archive archive

56
data.js
View File

@@ -107,13 +107,23 @@ let steps = {
result.include_pdf = result.format === "external"; result.include_pdf = result.format === "external";
} }
}, },
finishing_touches: { other_details: {
title: "Závěrečné detaily", title: "Ostatní detaily",
layout: finishing_touches_layout, layout: other_details_layout,
result: { result: {
has_keywords: true, has_keywords: true,
has_acknowledgement: true has_acknowledgement: true
} }
},
toolchain: {
title: "Jak budete používat Typst?",
layout: toolchain_layout,
result: {
toolchain: "online"
},
finalize: (result) => {
result.include_makefile = result.toolchain === "local";
}
} }
} }
@@ -210,6 +220,15 @@ const assignment_formats = {
} }
} }
const toolchains = {
"online": {
name: "Pomocí webového editoru Typstu"
},
"local": {
name: "Pomocí příkazové řádky"
}
}
const typst_header = `#import "template/template.typ": * const typst_header = `#import "template/template.typ": *
#show: tultemplate2.with( #show: tultemplate2.with(
@@ -217,17 +236,18 @@ const typst_header = `#import "template/template.typ": *
document: "{thesis_type.type}", document: "{thesis_type.type}",
lang: "{language.lang}", lang: "{language.lang}",
title: (cs: "{thesis_title.cs}", en: "{thesis_title.en}"), title: (cs: "{thesis_title.cs}", en: "{thesis_title.en}"),
<finishing_touches.has_keywords: keywords: ( specialization: ({language.lang}: "SEM DOPLŇTE SPECIALIZACI"),
<other_details.has_keywords: keywords: (
cs: ("DOPLŇTE", "SEM", "KLÍČOVÁ", "SLOVA"), cs: ("DOPLŇTE", "SEM", "KLÍČOVÁ", "SLOVA"),
en: ("INSERT", "KEYWORDS", "HERE") en: ("INSERT", "KEYWORDS", "HERE")
) ),
><finishing_touches.has_acknowledgement: acknowledgement: ( ><other_details.has_acknowledgement: acknowledgement: (
<language.is_cs:cs: " <language.is_cs:cs: "
Rád bych poděkoval všem, kteří přispěli ke vzniku tohoto dílka. Rád bych poděkoval všem, kteří přispěli ke vzniku tohoto dílka.
"><language.is_en:en: " "><language.is_en:en: "
I would like to acknowledge everyone who contributed to the creation of this fine piece of work. I would like to acknowledge everyone who contributed to the creation of this fine piece of work.
"> ">
) ),
> abstract: ( > abstract: (
cs: " cs: "
Sem vyplňte abstrakt své práce v češtině. Sem vyplňte abstrakt své práce v češtině.
@@ -240,17 +260,14 @@ const typst_header = `#import "template/template.typ": *
author_pronouns: "{author_info.pronouns}", author_pronouns: "{author_info.pronouns}",
<collaborators.has_supervisor: supervisor: "{collaborators.supervisor_name}", <collaborators.has_supervisor: supervisor: "{collaborators.supervisor_name}",
><collaborators.has_consultant: consultant: "{collaborators.consultant_name}", ><collaborators.has_consultant: consultant: "{collaborators.consultant_name}",
><programme.has_programme: programme: ({language.lang}: "{programme.programme}"}), ><programme.has_programme: programme: ({language.lang}: "{programme.programme}"),
><assignment.include_pdf: assignment: "assignment.pdf", ><assignment.include_pdf: assignment: "assignment.pdf",
> citations: "citations.bib" > citations: "citations.bib"
) )
= Nadpis
skibidi
`; `;
function generate_template() { function generate_template_header() {
let out = typst_header; let out = typst_header;
for(const step_key in steps) { for(const step_key in steps) {
@@ -308,12 +325,25 @@ async function generate_zip() {
let assets_zip = await fetch("template.zip"); let assets_zip = await fetch("template.zip");
let out_zip = await new JSZip().loadAsync(await assets_zip.blob()); let out_zip = await new JSZip().loadAsync(await assets_zip.blob());
out_zip.file("thesis.typ", generate_template()); let template = await out_zip.file(steps.thesis_type.result.type + ".typ").async("string");
template = generate_template_header() + template;
out_zip.forEach((path, _) => {
if(path.match(/^[a-z_]*\.typ$/)) {
out_zip.remove(path)
}
});
out_zip.file("thesis.typ", template);
if(!steps.assignment.result.include_pdf) { if(!steps.assignment.result.include_pdf) {
out_zip.remove("assignment.pdf"); out_zip.remove("assignment.pdf");
} }
if(!steps.toolchain.result.include_makefile) {
out_zip.remove("Makefile");
}
return await out_zip.generateAsync({ type: "blob" }); return await out_zip.generateAsync({ type: "blob" });
} }

26
ui.js
View File

@@ -178,7 +178,7 @@ async function assignment_layout(content, result) {
} }
} }
async function finishing_touches_layout(content, result) { async function other_details_layout(content, result) {
content.appendChild(new BinaryInputBuilder(result, "has_keywords") content.appendChild(new BinaryInputBuilder(result, "has_keywords")
.label("Vložit klíčová slova") .label("Vložit klíčová slova")
.finish()); .finish());
@@ -191,6 +191,30 @@ async function finishing_touches_layout(content, result) {
.finish()); .finish());
} }
async function toolchain_layout(content, result) {
if(!Object.keys(toolchains).includes(result.toolchain)) {
document.querySelector("#next-button").disabled = true;
}
let buttons = new ButtonListBuilder(Object.keys(toolchains))
.should_be_pressed((key) => result.toolchain == key)
.modify((b, key) => b.class("wide").text(toolchains[key].name))
.on_click((key) => {
result.toolchain = key;
document.querySelector("#next-button").disabled = false;
})
.finish();
for(const button of buttons) {
content.appendChild(button);
}
content.appendChild(new ElementBuilder("div.vertical-spacer").finish());
content.appendChild(new ElementBuilder("div.hint")
.text("Toto rozhodnutí pouze ovlivní, zda výsledná šablona bude obsahovat soubor Makefile pro jednodušší použití s příkazovou řádkou. Webový editor Typstu tento soubor nepotřebuje.")
.finish());
}
async function run() { async function run() {
startbutton.style.cursor = "auto"; startbutton.style.cursor = "auto";
startbutton.disabled = true; startbutton.disabled = true;