Merge branch '49-add-htwkarte-linkout-at-ics-event-info' into 'development'

fix:#49 new line fix google calendar description

See merge request htwk-software/htwkalender!84
This commit is contained in:
Elmar Kresse
2024-10-19 16:28:51 +00:00
2 changed files with 9 additions and 7 deletions

View File

@@ -111,10 +111,12 @@ func generateRoomLinksForGoogleCalendar(rooms string) string {
var description strings.Builder var description strings.Builder
roomList := functions.SeperateRoomString(rooms) roomList := functions.SeperateRoomString(rooms)
description.WriteString("Orte: \n") if !functions.OnlyWhitespace(rooms) {
for _, room := range roomList { description.WriteString("Orte: ")
roomLink := functions.MapRoom(room, true) for _, room := range roomList {
description.WriteString("<a href=\"https://map.htwk-leipzig.de/room/" + roomLink + "\"> " + room + " </a>\n") roomLink := functions.MapRoom(room, true)
description.WriteString("<a href=\"https://map.htwk-leipzig.de/room/" + roomLink + "\"> " + room + " </a> ")
}
} }
return description.String() return description.String()

View File

@@ -191,14 +191,14 @@ func Test_generateRoomLinksForGoogleCalendar(t *testing.T) {
args: args{ args: args{
rooms: "A123, ZU423, C789", rooms: "A123, ZU423, C789",
}, },
want: "Orte: \n<a href=\"https://map.htwk-leipzig.de/room/A123\"> A123 </a>\n<a href=\"https://map.htwk-leipzig.de/room/ZU423\"> ZU423 </a>\n<a href=\"https://map.htwk-leipzig.de/room/C789\"> C789 </a>\n", want: "Orte: <a href=\"https://map.htwk-leipzig.de/room/A123\"> A123 </a> <a href=\"https://map.htwk-leipzig.de/room/ZU423\"> ZU423 </a> <a href=\"https://map.htwk-leipzig.de/room/C789\"> C789 </a> ",
}, },
{ {
name: "Test 2", name: "Test 2",
args: args{ args: args{
rooms: "A123", rooms: "A123",
}, },
want: "Orte: \n<a href=\"https://map.htwk-leipzig.de/room/A123\"> A123 </a>\n", want: "Orte: <a href=\"https://map.htwk-leipzig.de/room/A123\"> A123 </a> ",
}, },
} }
for _, tt := range tests { for _, tt := range tests {
@@ -306,7 +306,7 @@ func Test_generateDescription(t *testing.T) {
}, },
userAgent: "Google-Calendar-Importer", userAgent: "Google-Calendar-Importer",
}, },
description: "Profs: Dr. Smith\nGruppen: Math 101\nTyp: Lecture (mandatory)\nOrte: \n<a href=\"https://map.htwk-leipzig.de/room/ZU423\"> ZU423 </a>\n<a href=\"https://map.htwk-leipzig.de/room/FE231\"> FE231 </a>\n", description: "Profs: Dr. Smith\nGruppen: Math 101\nTyp: Lecture (mandatory)\nOrte: <a href=\"https://map.htwk-leipzig.de/room/ZU423\"> ZU423 </a> <a href=\"https://map.htwk-leipzig.de/room/FE231\"> FE231 </a> ",
altrep: "", altrep: "",
}, },
} }