mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2026-01-18 12:32:26 +01:00
feat:#49 added multiple room linkout and mapping for map
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
ics "github.com/arran4/golang-ical"
|
||||
"htwkalender/ical/model"
|
||||
"htwkalender/ical/service/functions"
|
||||
"log/slog"
|
||||
"net/url"
|
||||
"strings"
|
||||
_ "time/tzdata"
|
||||
@@ -31,10 +32,6 @@ func generateUserAgentSpecificDescription(vEvent *ics.VEvent, event model.Event,
|
||||
description, altrep := generateDescription(event, userAgent)
|
||||
|
||||
if isThunderbird(userAgent) && altrep != "" {
|
||||
// Thunderbird-specific handling: Add DESCRIPTION with ALTREP attribute.
|
||||
// create property altrep
|
||||
//altrepParam := WithAltRep(altrep)
|
||||
|
||||
uri := &url.URL{
|
||||
Scheme: "data",
|
||||
Opaque: altrep,
|
||||
@@ -103,20 +100,30 @@ func generateThunderbirdHTMLDescription(event model.Event) string {
|
||||
htmlDescription.WriteString("Typ: " + event.EventType + event.Compulsory + "<br>")
|
||||
}
|
||||
|
||||
// Add the HTML link to the room map.
|
||||
htmlDescription.WriteString(`Link: <a href="https://map.htwk-leipzig.de/room/` + event.Rooms + `">HTWK-Karte</a>`)
|
||||
roomList := functions.SeperateRoomString(event.Rooms)
|
||||
htmlDescription.WriteString("Orte: <br>")
|
||||
|
||||
for _, room := range roomList {
|
||||
mapRoomName := functions.MapRoom(room, true)
|
||||
_, bufferErr := htmlDescription.WriteString("<a href=\"https://map.htwk-leipzig.de/room/" + mapRoomName + "\">" + room + "</a><br>")
|
||||
|
||||
if bufferErr != nil {
|
||||
slog.Error("Error while writing to buffer", "error", bufferErr)
|
||||
return ""
|
||||
}
|
||||
}
|
||||
return htmlDescription.String()
|
||||
}
|
||||
|
||||
// Generates a room description with links for Google Calendar.
|
||||
func generateGoogleCalendarDescription(rooms string) string {
|
||||
var description strings.Builder
|
||||
roomList := strings.Split(rooms, " ")
|
||||
roomList := functions.SeperateRoomString(rooms)
|
||||
description.WriteString("Orte: \n ")
|
||||
|
||||
for _, room := range roomList {
|
||||
description.WriteString("<a href=\"https://map.htwk-leipzig.de/room/" + room + "\">HTWK-Karte</a>\n")
|
||||
mapRoomName := functions.MapRoom(room, true)
|
||||
description.WriteString("<a href=\"https://map.htwk-leipzig.de/room/" + mapRoomName + "\"> " + mapRoomName + " </a>\n")
|
||||
}
|
||||
|
||||
return description.String()
|
||||
@@ -131,10 +138,3 @@ func isThunderbird(userAgent string) bool {
|
||||
func isGoogleCalendar(userAgent string) bool {
|
||||
return strings.Contains(userAgent, "Google-Calendar-Importer")
|
||||
}
|
||||
|
||||
func WithAltRep(altRepUrl string) ics.PropertyParameter {
|
||||
return &ics.KeyValues{
|
||||
Key: string(ics.ParameterAltrep),
|
||||
Value: []string{altRepUrl},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user