Skip to content

Commit bebd5b5

Browse files
committed
neat-timetable:0.1.0
1 parent f3cac7e commit bebd5b5

File tree

15 files changed

+1481
-0
lines changed

15 files changed

+1481
-0
lines changed

packages/preview/two-week-timetable/0.1.0/LICENSES/AGPL-3.0-only.txt

Lines changed: 235 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
MIT No Attribution
2+
3+
Copyright 2025 Andrew Voynov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
6+
software and associated documentation files (the "Software"), to deal in the Software
7+
without restriction, including without limitation the rights to use, copy, modify,
8+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9+
permit persons to whom the Software is furnished to do so.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
# neat-timetable (Typst template)
2+
3+
[neat-timetable] is a template for creating timetable for university
4+
classes (class schedule) that use a 2-week system: numerator and denominator
5+
week. Essentially, the first week is a numerator week, therefore the second
6+
week is a denominator week, and then the cycle continues.
7+
8+
[neat-timetable]: https://codeberg.org/Andrew15-5/neat-timetable
9+
10+
## Usage
11+
12+
First, choose the "neat-timetable" template in https://typst.app or via CLI:
13+
14+
```sh
15+
typst init @preview/neat-timetable:0.1.0
16+
```
17+
18+
To use the default settings, you will need the [Liberation] typeface.
19+
Particularly the [`LiberationSans-Bold.ttf`] file.
20+
21+
[Liberation]: https://github.com/liberationfonts/liberation-fonts
22+
[`LiberationSans-Bold.ttf`]: https://codeberg.org/Andrew15-5/neat-timetable/raw/branch/main/fonts/Liberation/LiberationSans-Bold.ttf
23+
24+
You can also start using the template by directly importing it:
25+
26+
```typ
27+
#import "@preview/neat-timetable:0.1.0": template, timetable
28+
#show: template.with(group: "D1-21")
29+
#pdf.embed("timetable.typ") // Make PDF reproducible and easy to edit.
30+
#timetable(data: (
31+
"Monday": (
32+
("PE 153",),
33+
(
34+
"Theoretical Computer Science lecture 201",
35+
"Engineering Graphics lecture 118",
36+
),
37+
("Cultural Studies lecture 3-208",),
38+
),
39+
"Tuesday": (
40+
("Foreign Language ex. 146",),
41+
("Mathematical Analysis ex. 307",),
42+
(
43+
"High-Level Programming lab. II 158",
44+
"High-Level Programming lab. I 158",
45+
),
46+
),
47+
"Thursday": (
48+
("Cultural Studies ex. 203", none),
49+
("Mathematical Analysis lecture 1-302",),
50+
),
51+
"Friday": (
52+
("Analytical Geometry lecture 302",),
53+
("Analytical Geometry ex. 111",),
54+
),
55+
))
56+
```
57+
58+
<img
59+
height="500px"
60+
src="./tests/example-simple/ref/1.png"
61+
alt="Timetable simple example"
62+
/>
63+
64+
Besides class name and location, you can, for example, include type of class
65+
(lecture, exercise, laboratory work, etc.), subgroup (if it exists, when there
66+
are many students), and professor name.
67+
68+
### Automating data creation
69+
70+
If you have a structured representation of timetable that can be transformed to
71+
Typst `dict`ionary to be used by `timetable` (e.g., [`ШУЦ1-31Б.json`]), you can
72+
automate everything, so that your Typst file only includes:
73+
74+
```typ
75+
#import "/template.typ": get-timetable-info, template, timetable
76+
#show: template
77+
#pdf.embed("timetable.typ")
78+
#timetable(..get-timetable-info(json("ШУЦ1-31Б.json")))
79+
```
80+
81+
<img
82+
height="900px"
83+
src="./tests/automated-example-ru/ref/1.png"
84+
alt="Timetable simple example"
85+
/>
86+
87+
See [`automated-example-ru`] test.
88+
89+
[`automated-example-ru`]: ./tests/automated-example-ru
90+
[`ШУЦ1-31Б.json`]: ./tests/automated-example-ru/ШУЦ1-31Б.json
91+
92+
If you would like to copy the Typst dictionary from the `get-timetable-info`,
93+
use [`repr`]:
94+
95+
```typ
96+
#import "@preview/neat-timetable:0.1.0": get-timetable-info
97+
#repr(get-timetable-info(json("ШУЦ1-31Б.json")).at("data")) // Data only
98+
#repr(get-timetable-info(json("ШУЦ1-31Б.json")).at("group")) // Group only
99+
#repr(get-timetable-info(json("ШУЦ1-31Б.json")) // `arguments` value
100+
```
101+
102+
Then simply select text from the generated PDF, paste it in Typst source file
103+
and use like shown in [Usage](#usage) or [Examples](#examples). Note that
104+
`repr` doesn't have stable/defined output, so in future it might not produce
105+
valid Typst dictionary syntax. Furthermore, you will get a nice representation
106+
only if `format-entry` outputs `str` and not `content` (default implementation
107+
outputs `str`).
108+
109+
[`repr`]: https://typst.app/docs/reference/foundations/repr/
110+
111+
## Examples
112+
113+
```typ
114+
#import "@preview/neat-timetable:0.1.0": template, timetable
115+
#show: template.with(group: "AB1-12")
116+
#timetable(data: (
117+
"Monday": (
118+
("Physical Education 6-145",),
119+
(
120+
"Theoretical Computer Science lecture 2-201",
121+
"Engineering Graphics lecture 5-118",
122+
),
123+
("Cultural Studies lecture 3-208",),
124+
("High-Level Programming lab. II 4-158",),
125+
),
126+
"Tuesday": (
127+
("Foreign Language ex. 1-146",),
128+
("Mathematical Analysis ex. 7-407",),
129+
(
130+
"High-Level Programming lab. II 4-158",
131+
"High-Level Programming lab. I 4-158",
132+
),
133+
(
134+
"High-Level Programming lab. II 4-158",
135+
"High-Level Programming lab. I 4-158",
136+
),
137+
),
138+
"Wednesday": (
139+
(none,),
140+
("Analytical Geometry ex. 6-511",),
141+
(
142+
"Theoretical Computer Science lab. I 5-322",
143+
"Theoretical Computer Science lab. II 5-322",
144+
),
145+
),
146+
"Thursday": (
147+
("Cultural Studies ex. 2-203", none),
148+
("Engineering Graphics ex. I 3-406 II 3-411",),
149+
("Mathematical Analysis lecture 1-302",),
150+
),
151+
"Friday": (
152+
("High-Level Programming lab. I 4-258",),
153+
("Analytical Geometry lecture 2-302",),
154+
("Engineering Graphics lab. I 6-310 II 6-312",),
155+
),
156+
"Saturday": (
157+
("High-Level Programming lecture 5-232",),
158+
("High-Level Programming ex. 3-162", none),
159+
),
160+
))
161+
```
162+
163+
<img
164+
height="900px"
165+
src="./tests/example-en/ref/1.png"
166+
alt="Timetable simple example"
167+
/>
168+
169+
---
170+
171+
```typ
172+
#import "@preview/neat-timetable:0.1.0": template, timetable
173+
#show: template.with(group: "AБ1-12")
174+
#timetable(data: (
175+
"Понедельник": (
176+
("Физическая культура 2-123",),
177+
(
178+
"Теоретическая информатика лекц. 5-108",
179+
"Инженерная графика лекц. 1-306",
180+
),
181+
("Культурология лекц. 5-208",),
182+
("Высокоуровневое программирование лаб. II 5-158",),
183+
),
184+
"Вторник": (
185+
("Иностранный язык упр. 1-146",),
186+
("Математический анализ упр. 7-407",),
187+
(
188+
"Высокоуровневое программирование лаб. II 5-158",
189+
"Высокоуровневое программирование лаб. I 5-158",
190+
),
191+
(
192+
"Высокоуровневое программирование лаб. II 5-158",
193+
"Высокоуровневое программирование лаб. I 5-158",
194+
),
195+
),
196+
"Среда": (
197+
(none,),
198+
("Аналитическая геометрия упр. 7-411",),
199+
(
200+
"Теоретическая информатика лаб. I 5-222",
201+
"Теоретическая информатика лаб. II 5-222",
202+
),
203+
),
204+
"Четверг": (
205+
("Культурология упр. 1-203", none),
206+
("Инженерная графика упр. I 1-306 II 1-311",),
207+
("Математический анализ лекц. 5-202",),
208+
),
209+
"Пятница": (
210+
("Высокоуровневое программирование лаб. I 5-158",),
211+
("Аналитическая геометрия лекц. 5-202",),
212+
("Инженерная графика лаб. I 3-210 II 3-212",),
213+
),
214+
"Суббота": (
215+
("Высокоуровневое программирование лекц. 5-232",),
216+
("Высокоуровневое программирование упр. 5-162", none),
217+
),
218+
))
219+
```
220+
221+
<img
222+
height="900px"
223+
src="./tests/example-ru/ref/1.png"
224+
alt="Timetable simple example"
225+
/>
226+
227+
## API
228+
229+
### `template`
230+
231+
```typ
232+
/// Template function used together with `timetable`.
233+
///
234+
/// - group (str, content): timetable of this group/class
235+
/// - time-data (array): array of timings for each class to show
236+
/// - text-fill (color): `text.fill`
237+
/// - table-fill (color): `table.fill`
238+
/// - table-zebra-fill (color): alternating `table.fill` for readability
239+
/// - table-zebra-odd (bool): whether to use zebra fill for odd weekdays
240+
/// - table-stroke (stroke): `table.stroke`
241+
/// - title (auto, none, str, content): document title
242+
/// - extra-styling (bool): whether to apply extra styling that can't be
243+
/// undone, because of show rule wrapper
244+
/// - sans-font (str): which sans-serif font to use as a part of `extra-styling`
245+
/// - doc (content): document to apply the template to
246+
#let template(
247+
group: "group name",
248+
time-data: time-data,
249+
text-fill: white,
250+
table-fill: rgb("333"),
251+
table-zebra-fill: black,
252+
table-zebra-odd: false,
253+
table-stroke: 2pt + rgb("b2b2b2"),
254+
title: auto,
255+
extra-styling: true,
256+
sans-font: "Liberation Sans",
257+
doc,
258+
)
259+
```
260+
261+
---
262+
263+
### `timetable`
264+
265+
```typ
266+
/// A table wrapper for creating class schedule.
267+
///
268+
/// - group (auto, str, content): timetable of this group/class.
269+
/// `auto` uses data from used template, otherwise default is used.
270+
/// - zebra-fill (auto, color): alternating `table.fill` for readability.
271+
/// `auto` uses data from used template, otherwise default is used.
272+
/// - zebra-odd (auto, bool): whether to use zebra fill for odd weekdays.
273+
/// `auto` uses data from used template, otherwise default is used.
274+
/// - time-data (auto, array): array of timings for each class to show.
275+
/// `auto` uses data from used template, otherwise default is used.
276+
/// - data (dictionary): dictionary of weekday as keys and array of classes as
277+
/// values. Each class can be an array of 1 value (class on numerator and
278+
/// denominator week) or 2 values (first class on numerator week, second
279+
/// class on denominator week). Each value can one of: `none`, `str`,
280+
/// `content`.
281+
#let timetable(
282+
group: auto,
283+
zebra-fill: auto,
284+
time-data: auto,
285+
zebra-odd: auto,
286+
data: (:),
287+
)
288+
```
289+
290+
---
291+
292+
### `format-entry`
293+
294+
```typ
295+
/// Format entry (class info) in the timetable.
296+
///
297+
/// - class (dictionary): source class data that contains everything necessary
298+
/// for formatting an entry
299+
/// -> content
300+
#let format-entry(class)
301+
```
302+
303+
---
304+
305+
### `get-timetable-info`
306+
307+
```typ
308+
/// Transform source dictionary to `arguments` that can be passed to
309+
/// `timetable`. To modify, simply create your own function from scratch, or
310+
/// copy this one to your project and edit accordingly.
311+
///
312+
/// - source (dictionary): source dictionary. Can be obtained through data
313+
/// loading functions.
314+
/// - format-entry (function): used to format single entry from data. This
315+
/// splits the schedule generation logic from class info generation logic.
316+
/// -> arguments
317+
#let get-timetable-info(source, format-entry: format-entry)
318+
```
319+
320+
## License
321+
322+
This Typst package is licensed under AGPL-3.0-only license with exception for
323+
`format-entry` and `get-timetable-info` functions in the [`template.typ`] file
324+
that are licensed under MIT-0 license. You can view:
325+
- the AGPL-3.0-only license in the [`AGPL-3.0-only.txt`] file in the
326+
[`LICENSES`] directory in the root of the project or at
327+
<https://www.gnu.org/licenses/agpl-3.0.txt>
328+
- the MIT-0 licenses in the [`MIT-0.txt`] file in the [`LICENSES`] directory in
329+
the root of the project or at <https://romanrm.net/mit-zero>
330+
331+
[`template.typ`]: ./template.typ
332+
[`LICENSES`]: ./LICENSES
333+
[`AGPL-3.0-only.txt`]: ./LICENSES/AGPL-3.0-only.txt
334+
[`MIT-0.txt`]: ./LICENSES/MIT-0.txt

0 commit comments

Comments
 (0)