summary refs log tree commit diff stats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/buildall6
-rw-r--r--java/prelude.typ38
-rw-r--r--java/template.typ17
3 files changed, 54 insertions, 7 deletions
diff --git a/java/buildall b/java/buildall
index 7cdd0c0..4468d35 100644
--- a/java/buildall
+++ b/java/buildall
@@ -1,4 +1,4 @@
 #!/bin/sh
-
-awk '$3 == "#" { printf("#include(\"text/%s.typ\")\n", $2) }' alist.txt > all.typ
-typst compile --root $PWD all.typ a/all.pdf
+cat prelude.typ > all.typ
+awk '$2 == "#" { printf("#include(\"text/%s.typ\")\n", $1) }' alist.txt >> all.typ
+typst compile --root $PWD all.typ docs/all.pdf
diff --git a/java/prelude.typ b/java/prelude.typ
new file mode 100644
index 0000000..027bfef
--- /dev/null
+++ b/java/prelude.typ
@@ -0,0 +1,38 @@
+#import "@preview/tablex:0.0.7": tablex, cellx
+#import "/template.typ": *
+
+#apply(page-numbering: "(i)" , [
+  #align(center, [== Contents])
+  #let heading-format(content) = cellx(align: center + horizon, content)
+  #let col-aligns = (right, auto, center + horizon, center + horizon, auto)
+  #let preprocess-alist(l, lpno) = {
+    let i = 0
+    let e = l.len() - 1
+    let nl = ()
+    while i < e {
+      let it = l.at(i)
+      i = i + 1
+      let nit = l.at(i)
+      it.at(2) = [ #it.at(2) - #{nit.at(2) - 1} ]
+      it.push([])
+      nl.push(it)
+    }
+    l.at(e).at(2) = [ #{l.at(e).at(2)} - #lpno ]
+    l.at(e).push([])
+    nl.push(l.at(e))
+    nl
+  }
+  #list-of-assignments((l, lpno) =>
+    tablex(
+      columns: (3em, 1fr, 4em, 8em, 10em),
+      stroke: 1pt + gray,
+      map-cols: (i, cells) => (cells.first(), ..cells.slice(1).map(cell => (..cell, align: col-aligns.at(i)))),
+      heading-format[*Sl.* \ *No.*], heading-format[*Description*], heading-format[*Page No.*], heading-format[*Date*], heading-format[*Teacher’s* \ *Signature*],
+      ..preprocess-alist(l, lpno).flatten(),
+    ))
+])
+
+#colbreak()
+
+#counter(page).update(0)
+
diff --git a/java/template.typ b/java/template.typ
index 47a97a1..57e2e48 100644
--- a/java/template.typ
+++ b/java/template.typ
@@ -31,13 +31,13 @@
 }
 
 /* Draws page border around the provided content, taking an optional function to be called at the footer. */
-#let apply-page-borders(body, ..font-options, footer-special-func: none) = {
+#let apply-page-borders(body, ..font-options, footer-special-func: none, page-numbering: none) = {
   let page-margin = (left: 0.75in, right: 0.25in, top: 0.25in, bottom: 0.25in)
   let margin = (left: 0.65in, right: 0.15in, top: 1.5em, bottom: 1.5em)
   let page-border-thickness = 1.25pt
   set page(
     margin: (..page-margin, bottom: margin.bottom + 2em),
-    numbering: "1",
+    numbering: if page-numbering != none { page-numbering } else { "1" },
     background: align(top + start, pad(..margin, rect(width: 100%, height: 100%, stroke: page-border-thickness + gray, radius: 5pt))),
     footer: locate(loc => {
       align(center, move(dy: -margin.bottom + 1em, text(..font-options, size: 9pt, counter(page).display(loc.page-numbering()))))
@@ -50,7 +50,7 @@
   body
 }
 
-#let apply(body) = {
+#let apply(body, page-numbering: none) = {
   let body-font-settings = (font: "Nunito Sans 10pt", size: 12pt, stretch: 75%)
 //  let body-font-settings = (font: "Hanken Grotesk", size: 12pt, stretch: 75%)
   set text(..body-font-settings)
@@ -74,7 +74,7 @@
   show raw.where(block: true): it => align(left, it)
   set list(marker: ([$square.filled.tiny$], [--]))
   set par(leading: 0.5em)
-  apply-page-borders(body, ..body-font-settings, footer-special-func: signature-footer)
+  apply-page-borders(body, ..body-font-settings, footer-special-func: signature-footer, page-numbering: page-numbering)
 }
 
 #let scos(name) = {
@@ -86,9 +86,18 @@
   include ofname
 }
 
+#let alist = state("assignment-list", ())
+
+#let list-of-assignments(cb) = locate(loc => {
+  let l = alist.final(loc)
+  let lpno = counter(page).final(loc).first()
+  cb(l, lpno)
+})
+
 #let assignment(number, description) = align(center, [
 = #text(weight: 600, [Assignment #number])
 == #text(weight: 500, [Program statement:]) #text(weight: 400, description)
+#locate(loc => alist.update(lst => (..lst, (number, description, counter(page).at(loc).first(), []))))
 ])
 
 #let skind(kind) = [