Skip to content

Commit 3c0b4a4

Browse files
committed
update regex
1 parent bd3a392 commit 3c0b4a4

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

core/templates/core/base/navbar.jinja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<li><a href="{{ url('matmat:search_clear') }}">{% trans %}Matmatronch{% endtrans %}</a></li>
2727
<li><a href="{{ url('core:file_list') }}">{% trans %}Files{% endtrans %}</a></li>
2828
<li><a href="{{ url('pedagogy:guide') }}">{% trans %}Pedagogy{% endtrans %}</a></li>
29+
<li><a href="{{ url('timetable:generator') }}">{% trans %}Timetable Generator{% endtrans %}</a></li>
2930
</ul>
3031
</details>
3132
<details name="navbar" class="menu">

timetable/static/bundled/timetable/generator-index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import html2canvas from "html2canvas";
22

33
// see https://regex101.com/r/QHSaPM/2
44
const TIMETABLE_ROW_RE: RegExp =
5-
/^(?<ueCode>[A-Z\d]{4}(?:\+[A-Z\d]{4})?)\s+(?<courseType>[A-Z]{2}\d)\s+((?<weekGroup>[AB])\s+)?(?<weekday>(lundi)|(mardi)|(mercredi)|(jeudi)|(vendredi)|(samedi)|(dimanche))\s+(?<startHour>\d{2}:\d{2})\s+(?<endHour>\d{2}:\d{2})\s+[\dA-B]\s+(?:[\wé]*\s+)?(?<room>\w+(?:, \w+)?)$/;
5+
/^(?<ueCode>[^\t]+)\t+(?<courseType>[A-Z]{2}\d)\t+((?<weekGroup>[AB])\t+)?(?<weekday>(lundi)|(mardi)|(mercredi)|(jeudi)|(vendredi)|(samedi)|(dimanche))\t+(?<startHour>\d{2}:\d{2})\t+(?<endHour>\d{2}:\d{2})\t+[\dA-B]\t+(?:[^\t]*\t+)?(?<room>[^\t]+)$/;
66

77
const DEFAULT_TIMETABLE: string = `DS52\t\tCM1\t\tlundi\t08:00\t10:00\t1\tPrésentiel\tA113
88
DS53\t\tCM1\t\tlundi\t10:15\t12:15\t1\tPrésentiel\tA101
@@ -135,11 +135,18 @@ document.addEventListener("alpine:init", () => {
135135
},
136136

137137
getStyle(slot: TimetableSlot) {
138+
const hasWeekGroup = slot.weekGroup !== undefined;
139+
const width = hasWeekGroup ? SLOT_WIDTH / 2 : SLOT_WIDTH;
140+
const leftOffset = hasWeekGroup
141+
? slot.weekGroup === "A"
142+
? 0
143+
: SLOT_WIDTH / 2
144+
: 0;
138145
return {
139146
height: `${(slot.endSlot - slot.startSlot) * SLOT_HEIGHT}px`,
140-
width: `${SLOT_WIDTH}px`,
147+
width: `${width}px`,
141148
top: `${(slot.startSlot - this.startSlot) * SLOT_HEIGHT}px`,
142-
left: `${this.displayedWeekdays.indexOf(slot.weekday) * SLOT_WIDTH}px`,
149+
left: `${this.displayedWeekdays.indexOf(slot.weekday) * SLOT_WIDTH + leftOffset}px`,
143150
backgroundColor: this.colors[slot.ueCode],
144151
};
145152
},

timetable/templates/timetable/generator.jinja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<div class="slot" :style="getStyle(course)">
4141
<span x-text="`${course.ueCode} (${course.courseType})`"></span>
4242
<span x-text="`${course.startHour} - ${course.endHour}`"></span>
43+
<span x-text="(course.weekGroup ? `\nGroupe ${course.weekGroup}` : '')"></span>
4344
<span x-text="course.room"></span>
4445
</div>
4546
</template>

0 commit comments

Comments
 (0)