fix styling and add address env vars
This commit is contained in:
16
main.go
16
main.go
@ -20,6 +20,9 @@ type Config struct {
|
||||
KVK string
|
||||
Email string
|
||||
Phone string
|
||||
Street string
|
||||
PostalCode string
|
||||
Village string
|
||||
Port string
|
||||
TelegramBotToken string
|
||||
TelegramChatID string
|
||||
@ -29,6 +32,7 @@ type Config struct {
|
||||
type PageData struct {
|
||||
Config
|
||||
Title string
|
||||
CurrentPage string
|
||||
CurrentYear int
|
||||
ErrorMessage string
|
||||
SuccessMessage string
|
||||
@ -74,6 +78,9 @@ func NewServer() *Server {
|
||||
KVK: getEnv("KVK", "12345678"), // Replace with actual KVK number
|
||||
Email: getEnv("EMAIL", "info@hogelandlinux.nl"),
|
||||
Phone: getEnv("PHONE", "+31 6 12345678"),
|
||||
Street: getEnv("STREET", "Voorstraat 123"),
|
||||
PostalCode: getEnv("POSTAL_CODE", "9967 AA"),
|
||||
Village: getEnv("VILLAGE", "Eenrum"),
|
||||
Port: ":" + getEnv("PORT", "8080"),
|
||||
TelegramBotToken: getEnv("TELEGRAM_BOT_TOKEN", ""), // Set this in environment
|
||||
TelegramChatID: getEnv("TELEGRAM_CHAT_ID", ""), // Set this in environment
|
||||
@ -91,11 +98,12 @@ func NewServer() *Server {
|
||||
}
|
||||
}
|
||||
|
||||
// createPageData creates PageData with the given title
|
||||
func (s *Server) createPageData(title string) PageData {
|
||||
// createPageData creates PageData with the given title and current page
|
||||
func (s *Server) createPageData(title, currentPage string) PageData {
|
||||
return PageData{
|
||||
Config: s.config,
|
||||
Title: title,
|
||||
CurrentPage: currentPage,
|
||||
CurrentYear: time.Now().Year(),
|
||||
}
|
||||
}
|
||||
@ -110,13 +118,13 @@ func (s *Server) renderTemplate(w http.ResponseWriter, templateName string, data
|
||||
|
||||
// homeHandler handles the home page
|
||||
func (s *Server) homeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := s.createPageData("Linux Migratie Service - Uw Computer Nieuw Leven Geven")
|
||||
data := s.createPageData("Linux Migratie Service - Uw Computer Nieuw Leven Geven", "home")
|
||||
s.renderTemplate(w, "index.html", data)
|
||||
}
|
||||
|
||||
// contactHandler handles the contact page
|
||||
func (s *Server) contactHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := s.createPageData("Contact - " + s.config.CompanyName)
|
||||
data := s.createPageData("Contact - "+s.config.CompanyName, "contact")
|
||||
|
||||
if r.Method == "POST" {
|
||||
s.handleContactForm(w, r, &data)
|
||||
|
Reference in New Issue
Block a user