Compare commits
11 Commits
e2e0f45588
...
master
Author | SHA1 | Date | |
---|---|---|---|
80b0eb9448 | |||
14c347b2f1 | |||
85e286c2c5 | |||
10e7d50501 | |||
9983b98da0
|
|||
f85d557916
|
|||
cc7a3908f6 | |||
670dd9596e | |||
48af642e4f | |||
99c876c48c | |||
264299a7a8 |
25
build.sh
25
build.sh
@@ -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
|
||||||
|
|
||||||
|
84
data.js
84
data.js
@@ -18,6 +18,10 @@ let steps = {
|
|||||||
layout: language_layout,
|
layout: language_layout,
|
||||||
result: {
|
result: {
|
||||||
lang: "cs"
|
lang: "cs"
|
||||||
|
},
|
||||||
|
finalize: (result) => {
|
||||||
|
result.is_cs = result.lang === "cs";
|
||||||
|
result.is_en = result.lang === "en";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
thesis_title: {
|
thesis_title: {
|
||||||
@@ -51,6 +55,7 @@ let steps = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
programme: {
|
programme: {
|
||||||
|
condition: () => programmes[steps.faculty.result.name] !== undefined,
|
||||||
title: "Který program studujete?",
|
title: "Který program studujete?",
|
||||||
layout: programme_layout,
|
layout: programme_layout,
|
||||||
result: {
|
result: {
|
||||||
@@ -101,6 +106,24 @@ let steps = {
|
|||||||
finalize: (result) => {
|
finalize: (result) => {
|
||||||
result.include_pdf = result.format === "external";
|
result.include_pdf = result.format === "external";
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
other_details: {
|
||||||
|
title: "Ostatní detaily",
|
||||||
|
layout: other_details_layout,
|
||||||
|
result: {
|
||||||
|
has_keywords: 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";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,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(
|
||||||
@@ -204,21 +236,38 @@ 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}"),
|
||||||
|
specialization: ({language.lang}: "SEM DOPLŇTE SPECIALIZACI"),
|
||||||
|
<other_details.has_keywords: keywords: (
|
||||||
|
cs: ("DOPLŇTE", "SEM", "KLÍČOVÁ", "SLOVA"),
|
||||||
|
en: ("INSERT", "KEYWORDS", "HERE")
|
||||||
|
),
|
||||||
|
><other_details.has_acknowledgement: acknowledgement: (
|
||||||
|
<language.is_cs:cs: "
|
||||||
|
Rád bych poděkoval všem, kteří přispěli ke vzniku tohoto dílka.
|
||||||
|
"><language.is_en:en: "
|
||||||
|
I would like to acknowledge everyone who contributed to the creation of this fine piece of work.
|
||||||
|
">
|
||||||
|
),
|
||||||
|
> abstract: (
|
||||||
|
cs: "
|
||||||
|
Sem vyplňte abstrakt své práce v češtině.
|
||||||
|
",
|
||||||
|
en: "
|
||||||
|
Insert the abstract of your theses in English here.
|
||||||
|
"
|
||||||
|
),
|
||||||
author: "{author_info.name}",
|
author: "{author_info.name}",
|
||||||
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: "{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) {
|
||||||
@@ -234,9 +283,12 @@ function generate_template() {
|
|||||||
console.log("- " + key);
|
console.log("- " + key);
|
||||||
|
|
||||||
const search_condition = "<" + step_key + "." + key + ":";
|
const search_condition = "<" + step_key + "." + key + ":";
|
||||||
|
|
||||||
|
while(true) {
|
||||||
const condition_pos = out.search(search_condition);
|
const condition_pos = out.search(search_condition);
|
||||||
|
|
||||||
if(condition_pos >= 0) {
|
if(condition_pos < 0) break;
|
||||||
|
|
||||||
const condition_end_pos = out.slice(condition_pos).search(">");
|
const condition_end_pos = out.slice(condition_pos).search(">");
|
||||||
|
|
||||||
if(condition_end_pos >= 0) {
|
if(condition_end_pos >= 0) {
|
||||||
@@ -249,9 +301,12 @@ function generate_template() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const search_replacement = "{" + step_key + "." + key + "}";
|
const search_replacement = "{" + step_key + "." + key + "}";
|
||||||
|
|
||||||
|
while(true) {
|
||||||
const replacement_pos = out.search(search_replacement);
|
const replacement_pos = out.search(search_replacement);
|
||||||
|
|
||||||
if(replacement_pos >= 0) {
|
if(replacement_pos < 0) break;
|
||||||
|
|
||||||
const head = out.slice(0, replacement_pos);
|
const head = out.slice(0, replacement_pos);
|
||||||
const meat = result[key];
|
const meat = result[key];
|
||||||
const tail = out.slice(replacement_pos + search_replacement.length);
|
const tail = out.slice(replacement_pos + search_replacement.length);
|
||||||
@@ -270,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" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
47
ui.js
47
ui.js
@@ -178,6 +178,43 @@ async function assignment_layout(content, result) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function other_details_layout(content, result) {
|
||||||
|
content.appendChild(new BinaryInputBuilder(result, "has_keywords")
|
||||||
|
.label("Vložit klíčová slova")
|
||||||
|
.finish());
|
||||||
|
content.appendChild(new BinaryInputBuilder(result, "has_acknowledgement")
|
||||||
|
.label("Vložit poděkování")
|
||||||
|
.finish());
|
||||||
|
content.appendChild(new ElementBuilder("div.vertical-spacer").finish());
|
||||||
|
content.appendChild(new ElementBuilder("div.hint")
|
||||||
|
.text("Generátor pouze vygeneruje ukázky, jak by tato pole měla vypadat. Samotná klíčová slova či poděkování si poté upravíte dle svých potřeb.")
|
||||||
|
.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;
|
||||||
@@ -219,14 +256,20 @@ async function run() {
|
|||||||
let steps_len = Object.keys(steps).length;
|
let steps_len = Object.keys(steps).length;
|
||||||
|
|
||||||
while(id < steps_len) {
|
while(id < steps_len) {
|
||||||
|
let step = get_step(id);
|
||||||
|
|
||||||
|
if(step.condition && !step.condition()) {
|
||||||
|
if(animation > 0) id++;
|
||||||
|
if(animation < 0) id--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
back_button.style.display = (id != 0) ? "" : "none";
|
back_button.style.display = (id != 0) ? "" : "none";
|
||||||
next_button.innerText = (id < steps_len - 1) ? "Další →" : "Dokončit";
|
next_button.innerText = (id < steps_len - 1) ? "Další →" : "Dokončit";
|
||||||
next_button.disabled = false;
|
next_button.disabled = false;
|
||||||
|
|
||||||
container.innerHTML = "";
|
container.innerHTML = "";
|
||||||
|
|
||||||
let step = get_step(id);
|
|
||||||
|
|
||||||
let title = new ElementBuilder("h1")
|
let title = new ElementBuilder("h1")
|
||||||
.html(step.title)
|
.html(step.title)
|
||||||
.finish();
|
.finish();
|
||||||
|
6
utils.js
6
utils.js
@@ -235,11 +235,13 @@ class BinaryInputBuilder {
|
|||||||
let input = new ElementBuilder("input#" + this.key)
|
let input = new ElementBuilder("input#" + this.key)
|
||||||
.type("checkbox")
|
.type("checkbox")
|
||||||
.checked(this.result[this.key])
|
.checked(this.result[this.key])
|
||||||
.if(this.update_handler !== null, b => b.on_click(e => {
|
.on_click(e => {
|
||||||
console.log(e.target.checked);
|
console.log(e.target.checked);
|
||||||
this.result[this.key] = e.target.checked;
|
this.result[this.key] = e.target.checked;
|
||||||
|
if(this.update_handler !== null) {
|
||||||
this.update_handler(e.target.checked);
|
this.update_handler(e.target.checked);
|
||||||
}))
|
}
|
||||||
|
})
|
||||||
.finish();
|
.finish();
|
||||||
|
|
||||||
let bundle = new ElementBuilder("div.horizontal-list")
|
let bundle = new ElementBuilder("div.horizontal-list")
|
||||||
|
Reference in New Issue
Block a user