'Nächster Topictreff' und 'rundgang' eingebunden

This commit is contained in:
xoy 2023-01-28 14:23:31 +01:00
parent 0d6638db4c
commit 78cf5a1d36
19 changed files with 186 additions and 3 deletions

80
func.go
View File

@ -32,6 +32,7 @@ func handler() {
httpHandleFunc("style/main.css", "./web/styles/main.css", "text/css") httpHandleFunc("style/main.css", "./web/styles/main.css", "text/css")
httpHandleFunc("style/kontakt.css", "./web/styles/kontakt.css", "text/css") httpHandleFunc("style/kontakt.css", "./web/styles/kontakt.css", "text/css")
httpHandleFunc("style/home.css", "./web/styles/home.css", "text/css") httpHandleFunc("style/home.css", "./web/styles/home.css", "text/css")
httpHandleFunc("style/events.css", "./web/styles/events.css", "text/css")
//Images //Images
httpHandleFunc("image/logo_ctdo.svg", "./web/images/logo_ctdo.svg", "image/svg+xml") httpHandleFunc("image/logo_ctdo.svg", "./web/images/logo_ctdo.svg", "image/svg+xml")
@ -104,6 +105,14 @@ func getRoomState() status {
return *roomState return *roomState
} }
func htmlNewBanner(text string, link string) string {
output := ""
output += htmlElement("div", htmlLinkElement(text, link, true, ""), "class=\"newBanner\"")
return output
}
func htmlReplacer(input string, activePage string) string { func htmlReplacer(input string, activePage string) string {
output := strings.ReplaceAll(input, "!NAV", htmlNav(getPages(), activePage)) output := strings.ReplaceAll(input, "!NAV", htmlNav(getPages(), activePage))
@ -115,5 +124,76 @@ func htmlReplacer(input string, activePage string) string {
output = strings.ReplaceAll(output, "!FOOTERNAV", htmlNav(getFooterPages(), activePage)) output = strings.ReplaceAll(output, "!FOOTERNAV", htmlNav(getFooterPages(), activePage))
if getNextTopic().days == 0 {
output = strings.ReplaceAll(output, "!TOPICTREFF", htmlElement("h3", "Nächster Topictreff findet Heute statt!", ""))
} else if getNextTopic().days == 1 {
output = strings.ReplaceAll(output, "!TOPICTREFF", htmlElement("h3", "Nächster Topictreff findet Morgen statt!", "class=\"topic\"")+htmlElement("p", "Am "+getNextTopic().date, "class=\"topic\""))
} else if getNextTopic().days < 10 {
output = strings.ReplaceAll(output, "!TOPICTREFF", htmlElement("h3", "Nächster Topictreff findet in "+strconv.FormatInt(int64(getNextTopic().days), 10)+" Tagen statt!", "class=\"topic\"")+htmlElement("p", "Am "+getNextTopic().date, "class=\"topic\""))
} else {
output = strings.ReplaceAll(output, "!TOPICTREFF", htmlElement("h3", "Nächster Topictreff findet in "+string(getNextTopic().days)+" Tagen statt!", "class=\"topic\"")+htmlElement("p", "Am "+getNextTopic().date, "class=\"topic\""))
}
output = strings.ReplaceAll(output, "!NEWBANNER", htmlNewBanner("Rundgang", "https://www.chaostreff-dortmund.de/rundgang/"))
return output
}
func ifFloatRange(variable float64, min float64, max float64, includeMin bool, includeMax bool) bool {
a, b := false, false
if includeMin {
a = variable >= min
} else {
a = variable > min
}
if includeMax {
b = variable <= max
} else {
b = variable < max
}
return a && b
}
func stringSplit(input string, sep string) []string {
output := *new([]string)
for _, element := range strings.Split(input, sep) {
if element != "" {
output = append(output, element)
}
}
return output
}
// jeden ersten donnerstag und dritten dienstag
func getNextTopic() topic {
date := time.Now()
var output topic
for i := 0; i < 31; i++ {
newDate := stringSplit(date.AddDate(0, 0, 1*i).Format(time.UnixDate), " ")
if newDate[0] == "Thu" || newDate[0] == "Tue" {
dayA, errA := strconv.Atoi(newDate[2])
if errA != nil {
panic(errA)
}
dayB, errB := strconv.Atoi(newDate[2])
if errB != nil {
panic(errB)
}
if ifFloatRange(float64(dayA)/7, 0, 1, false, true) || (ifFloatRange(float64(dayB)/7, 2, 3, false, true) && newDate[0] == "Tue") {
output.date = date.AddDate(0, 0, 1*i).Format("02.01.2006")
output.days = i
break
}
}
}
return output return output
} }

View File

@ -16,3 +16,8 @@ type event struct {
media []string media []string
date string date string
} }
type topic struct {
date string
days int
}

5
tester.go Normal file
View File

@ -0,0 +1,5 @@
package main
func testFuncOutput(functionOutput any, rightOutput any) bool {
return functionOutput == rightOutput
}

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="/style/main.css"> <link rel="stylesheet" href="/style/main.css">
</head> </head>
<body> <body>
!NEWBANNER
<header> <header>
<img src="/image/logo_ctdo.svg" alt="ctdo logo"> <img src="/image/logo_ctdo.svg" alt="ctdo logo">
!NAV !NAV

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="/style/main.css"> <link rel="stylesheet" href="/style/main.css">
</head> </head>
<body> <body>
!NEWBANNER
<header> <header>
<img src="/image/logo_ctdo.svg" alt="ctdo logo"> <img src="/image/logo_ctdo.svg" alt="ctdo logo">
!NAV !NAV

View File

@ -6,10 +6,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ctdo - events</title> <title>ctdo - events</title>
<link rel="stylesheet" href="/style/main.css"> <link rel="stylesheet" href="/style/main.css">
<link rel="stylesheet" href="/style/events.css">
</head> </head>
<body> <body>
!NEWBANNER
<header> <header>
<img src="/image/logo_ctdo.svg" alt="ctdo logo"> <img src="/image/logo_ctdo.svg" alt="ctdo logo" style="width:100%;">
!NAV !NAV
</header> </header>
<main> <main>

View File

@ -9,12 +9,21 @@
<link rel="stylesheet" href="/style/home.css"> <link rel="stylesheet" href="/style/home.css">
</head> </head>
<body> <body>
!NEWBANNER
<header> <header>
<img src="/image/logo_ctdo.svg" alt="ctdo logo"> <img src="/image/logo_ctdo.svg" alt="ctdo logo">
!NAV !NAV
</header> </header>
<main> <main>
<img src="/image/header.jpg" alt="Raum 2 mit gemütlichen Sofas"> <div class="rundgang">
<a href="https://www.chaostreff-dortmund.de/rundgang/" target="_blank" class="imgLink">
<div>
<img src="/image/header.jpg" alt="Raum 2 mit gemütlichen Sofas">
<h2>Rundgang</h2>
</div>
</a>
</div>
!RAUMSTATUS !RAUMSTATUS
<h2>Hi</h2> <h2>Hi</h2>
@ -30,7 +39,8 @@
</p> </p>
<h2>Die nächsten Events</h2> <h2>Die nächsten Events</h2>
<p>Es sind gerade keine besonderen Veranstaltungen geplant.</p> !TOPICTREFF
!NEXTEVENTS
</main> </main>
<footer> <footer>
!FOOTERNAV !FOOTERNAV

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="/style/main.css"> <link rel="stylesheet" href="/style/main.css">
</head> </head>
<body> <body>
!NEWBANNER
<header> <header>
<img src="/image/logo_ctdo.svg" alt="ctdo logo"> <img src="/image/logo_ctdo.svg" alt="ctdo logo">
!NAV !NAV

View File

@ -9,6 +9,7 @@
<link rel="stylesheet" href="/style/kontakt.css"> <link rel="stylesheet" href="/style/kontakt.css">
</head> </head>
<body> <body>
!NEWBANNER
<header> <header>
<img src="/image/logo_ctdo.svg" alt="ctdo logo"> <img src="/image/logo_ctdo.svg" alt="ctdo logo">
!NAV !NAV

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="/style/main.css"> <link rel="stylesheet" href="/style/main.css">
</head> </head>
<body> <body>
!NEWBANNER
<header> <header>
<img src="/image/logo_ctdo.svg" alt="ctdo logo"> <img src="/image/logo_ctdo.svg" alt="ctdo logo">
!NAV !NAV

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="/style/main.css"> <link rel="stylesheet" href="/style/main.css">
</head> </head>
<body> <body>
!NEWBANNER
<header> <header>
<img src="/image/logo_ctdo.svg" alt="ctdo logo"> <img src="/image/logo_ctdo.svg" alt="ctdo logo">
!NAV !NAV

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="/style/main.css"> <link rel="stylesheet" href="/style/main.css">
</head> </head>
<body> <body>
!NEWBANNER
<header> <header>
<img src="/image/logo_ctdo.svg" alt="ctdo logo"> <img src="/image/logo_ctdo.svg" alt="ctdo logo">
!NAV !NAV

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="/style/main.css"> <link rel="stylesheet" href="/style/main.css">
</head> </head>
<body> <body>
!NEWBANNER
<header> <header>
<img src="/image/logo_ctdo.svg" alt="ctdo logo"> <img src="/image/logo_ctdo.svg" alt="ctdo logo">
!NAV !NAV

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="/style/main.css"> <link rel="stylesheet" href="/style/main.css">
</head> </head>
<body> <body>
!NEWBANNER
<header> <header>
<img src="/image/logo_ctdo.svg" alt="ctdo logo"> <img src="/image/logo_ctdo.svg" alt="ctdo logo">
!NAV !NAV

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="/style/main.css"> <link rel="stylesheet" href="/style/main.css">
</head> </head>
<body> <body>
!NEWBANNER
<header> <header>
<img src="/image/logo_ctdo.svg" alt="ctdo logo"> <img src="/image/logo_ctdo.svg" alt="ctdo logo">
!NAV !NAV

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="/style/main.css"> <link rel="stylesheet" href="/style/main.css">
</head> </head>
<body> <body>
!NEWBANNER
<header> <header>
<img src="/image/logo_ctdo.svg" alt="ctdo logo"> <img src="/image/logo_ctdo.svg" alt="ctdo logo">
!NAV !NAV

0
web/styles/events.css Normal file
View File

View File

@ -1,4 +1,8 @@
main img { main img {
max-width: 950px; max-width: 950px;
width: 100%; width: 100%;
}
main div.rundgang {
height: 140px;
} }

View File

@ -27,6 +27,39 @@ a:visited {
color: #bb66ff !important; color: #bb66ff !important;
} }
a.imgLink div {
position: relative;
text-align: center;
color: white;
}
a.imgLink:hover {
text-decoration: none;
}
a.imgLink div {
position: relative;
text-align: center;
color: white !important;
font-size: 0;
transform: scale(1);
transition: transform .5s;
text-shadow: 2px 2px black;
}
a.imgLink div:hover {
font-size: 200%;
transform: scale(.9);
transition: font-size .5s, transform .5s;
}
a.imgLink div h2 {
position: absolute;
top: 35%;
left: 50%;
transform: translate(-50%, -50%);
}
header { header {
background-color: var(--logo-background-color); background-color: var(--logo-background-color);
} }
@ -107,6 +140,39 @@ iframe.osm {
display: block; display: block;
} }
div.newBanner {
display: block;
position: fixed;
top: 30px;
left: -40px;
background-color: #DD0000;
text-align: center;
transform: rotateZ(-45deg);
transition: transform .5s;
}
div.newBanner:hover {
transform: rotateZ(-45deg) scale(1.4);
transition: transform .5s;
}
div.newBanner a {
color: white !important;
padding: 100px 50px 100px 50px;
}
div.newBanner a:hover {
text-decoration: none;
}
h3.topic {
margin-bottom: 0;
}
p.topic {
margin-top: 0;
}
@media only screen and (max-width: 885px) { @media only screen and (max-width: 885px) {
nav ul li { nav ul li {
display: block; display: block;