Actually generating valid templates now
This commit is contained in:
18
data.js
18
data.js
@@ -236,7 +236,7 @@ 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}"),
|
||||||
branch: ({language.lang}: "SEM DOPLŇTE SPECIALIZACI"),
|
specialization: ({language.lang}: "SEM DOPLŇTE SPECIALIZACI"),
|
||||||
<other_details.has_keywords: keywords: (
|
<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")
|
||||||
@@ -265,12 +265,9 @@ const typst_header = `#import "template/template.typ": *
|
|||||||
> 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) {
|
||||||
@@ -328,7 +325,16 @@ 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");
|
||||||
|
Reference in New Issue
Block a user