code-style: centralize CSS styling into stylesheet file

This commit is contained in:
Johannes 2023-07-09 13:01:01 +02:00
parent 4d7d98feed
commit 0046bc39db
6 changed files with 30 additions and 23 deletions

View file

@ -55,9 +55,9 @@ func (b *BaseHandler) printTimetable(timetable map[models.Date]map[int]models.Of
for minute := 0; minute < 60; minute += b.config.Date.MinuteGranularity {
tableBody += "<tr>"
if minute == 0 {
tableBody += fmt.Sprintf("<td>%d Uhr</td>\n", hour)
tableBody += fmt.Sprintf("<td class=\"timetableRightBorder\">%d Uhr</td>\n", hour)
} else {
tableBody += "<td></td>\n"
tableBody += "<td class=\"timetableRightBorder\"></td>\n"
}
for day := 0; day < 5; day += 1 {
for slot := 0; slot < slots[day]; slot += 1 {
@ -96,7 +96,7 @@ func (b *BaseHandler) printTimetable(timetable map[models.Date]map[int]models.Of
}
} else {
if slot+1 == slots[day] {
tableBody += "<td style=\"border-right: 1px dotted\"></td>\n"
tableBody += "<td class=\"timetableRightBorder\"></td>\n"
} else {
tableBody += "<td></td>\n"
}

17
static/officeHours.css Normal file
View file

@ -0,0 +1,17 @@
/* mark required fields */
input.required ~ label::after, select.required ~ label::after {
content: ' *';
color: red;
}
/* improve indent of help texts below form fields */
.form-control ~ .form-text {
padding-left: 12px;
padding-right: 12px;
}
.timetableRightBorder {
border-right: 1px dotted;
}
td.officeHour {
border: 1px solid;
}

View file

@ -14,17 +14,6 @@
{{end}}
</div>
<style>
input.required ~ label::after, select.required ~ label::after {
content: ' *';
color: red;
}
.form-control ~ .form-text {
padding-left: 12px;
padding-right: 12px;
}
</style>
<div class="row">
<div class="col-lg-8 mb-4">
<form method="POST" action="addOfficeHour">

View file

@ -6,7 +6,8 @@
<meta name="description" content="Eine Übersicht der Sprechstunden, die in den offenen Arbeitsräumen der Fachschaft Mathematik, TU Darmstadt, angeboten werden">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="/static/officeHours.css" />
<title>{{block "title" .}}Start{{end}} Sprechstunden</title>
</head>

View file

@ -1,11 +1,11 @@
<table>
<tr>
<th>&nbsp;</th>
<th colspan="{{.ColspanMon}}" style="padding-left: 10px; padding-right: 10px; border-right: 1px dotted">Montag</th>
<th colspan="{{.ColspanTue}}" style="padding-left: 10px; padding-right: 10px; border-right: 1px dotted">Dienstag</th>
<th colspan="{{.ColspanWed}}" style="padding-left: 10px; padding-right: 10px; border-right: 1px dotted">Mittwoch</th>
<th colspan="{{.ColspanThu}}" style="padding-left: 10px; padding-right: 10px; border-right: 1px dotted">Donnerstag</th>
<th colspan="{{.ColspanFri}}" style="padding-left: 10px; padding-right: 10px; border-right: 1px dotted">Freitag</th>
<th class="px-2 text-center timetableRightBorder">&nbsp;</th>
<th class="px-2 text-center timetableRightBorder" colspan="{{.ColspanMon}}">Montag</th>
<th class="px-2 text-center timetableRightBorder" colspan="{{.ColspanTue}}">Dienstag</th>
<th class="px-2 text-center timetableRightBorder" colspan="{{.ColspanWed}}">Mittwoch</th>
<th class="px-2 text-center timetableRightBorder" colspan="{{.ColspanThu}}">Donnerstag</th>
<th class="px-2 text-center timetableRightBorder" colspan="{{.ColspanFri}}">Freitag</th>
</tr>
{{.TableBody}}
</table>
</table>

View file

@ -1,4 +1,4 @@
<td rowspan="{{divide .OfficeHour.Duration .MinuteGranularity}}" style="border: 1px solid">
<td class="officeHour" rowspan="{{divide .OfficeHour.Duration .MinuteGranularity}}">
{{if .DeleteIcons}}<div style="text-align: right;"><a href="/deleteOfficeHour?id={{.OfficeHour.Id}}"></a></div>{{end}}
{{printf "%02d" .OfficeHour.Date.Hour}}:{{printf "%02d" .OfficeHour.Date.Minute}} - {{printf "%02d" .OfficeHour.EndDate.Hour}}:{{printf "%02d" .OfficeHour.EndDate.Minute}}<br>
{{if eq .OfficeHour.Date.Week 1}}in ungeraden Vorlesungswochen<br>{{end}}{{if eq .OfficeHour.Date.Week 2}}in geraden Vorlesungswochen<br>{{end}}