Code quality improvements and Dutch language fixes

- Refactored Go code for better maintainability:
  * Eliminated DRY violations with Server struct
  * Added proper configuration management
  * Separated concerns with dedicated handlers
  * Improved error handling

- Fixed Dutch grammar and language issues:
  * Translated all English tech terms to Dutch
  * Fixed mixed English/Dutch descriptions
  * Improved naturalness of Dutch phrases
  * Updated distro tags and feature descriptions
This commit is contained in:
2025-07-04 23:26:25 +02:00
parent 214c350fb8
commit 587870e5f6
2 changed files with 101 additions and 56 deletions

119
main.go
View File

@ -6,6 +6,16 @@ import (
"net/http"
)
// Configuration holds all website configuration
type Config struct {
CompanyName string
KVK string
Email string
Phone string
Port string
}
// PageData holds data for template rendering
type PageData struct {
CompanyName string
Title string
@ -14,46 +24,81 @@ type PageData struct {
Phone string
}
func main() {
// Parse templates
tmpl := template.Must(template.ParseGlob("templates/*.html"))
// Server holds the application state
type Server struct {
config Config
templates *template.Template
}
// NewServer creates a new server instance
func NewServer() *Server {
// Configuration - replace these with your actual values
config := Config{
CompanyName: "Hogeland Linux",
KVK: "12345678", // Replace with actual KVK number
Email: "info@hogelandlinux.nl",
Phone: "+31 6 12345678",
Port: ":8080",
}
// Parse templates with error handling
templates, err := template.ParseGlob("templates/*.html")
if err != nil {
log.Fatalf("Failed to parse templates: %v", err)
}
return &Server{
config: config,
templates: templates,
}
}
// createPageData creates PageData with the given title
func (s *Server) createPageData(title string) PageData {
return PageData{
CompanyName: s.config.CompanyName,
Title: title,
KVK: s.config.KVK,
Email: s.config.Email,
Phone: s.config.Phone,
}
}
// renderTemplate renders a template with error handling
func (s *Server) renderTemplate(w http.ResponseWriter, templateName string, data PageData) {
if err := s.templates.ExecuteTemplate(w, templateName, data); err != nil {
log.Printf("Template execution error: %v", err)
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
}
}
// 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")
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)
s.renderTemplate(w, "contact.html", data)
}
// setupRoutes configures all HTTP routes
func (s *Server) setupRoutes() {
// Static files
fs := http.FileServer(http.Dir("static/"))
http.Handle("/static/", http.StripPrefix("/static/", fs))
// Home page
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
data := PageData{
CompanyName: "Hogeland Linux",
Title: "Linux Migratie Service - Uw Computer Nieuw Leven Geven",
KVK: "12345678", // Replace with actual KVK number
Email: "info@hogelandlinux.nl",
Phone: "+31 6 12345678",
}
if err := tmpl.ExecuteTemplate(w, "index.html", data); err != nil {
log.Printf("Template execution error: %v", err)
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
}
})
// Contact page
http.HandleFunc("/contact", func(w http.ResponseWriter, r *http.Request) {
data := PageData{
CompanyName: "Hogeland Linux",
Title: "Contact - Hogeland Linux",
KVK: "12345678", // Replace with actual KVK number
Email: "info@hogelandlinux.nl",
Phone: "+31 6 12345678",
}
if err := tmpl.ExecuteTemplate(w, "contact.html", data); err != nil {
log.Printf("Template execution error: %v", err)
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
}
})
log.Println("Server starting on :8080")
log.Fatal(http.ListenAndServe(":8080", nil))
// Page routes
http.HandleFunc("/", s.homeHandler)
http.HandleFunc("/contact", s.contactHandler)
}
func main() {
server := NewServer()
server.setupRoutes()
log.Printf("Server starting on %s", server.config.Port)
log.Fatal(http.ListenAndServe(server.config.Port, nil))
}

View File

@ -179,8 +179,8 @@
</div>
<p class="distro-description">Ziet er vertrouwd uit voor Windows gebruikers. Stabiel en betrouwbaar.</p>
<div class="distro-features">
<span class="feature">✓ Vertrouwd interface</span>
<span class="feature">✓ Multimedia support</span>
<span class="feature">✓ Vertrouwde interface</span>
<span class="feature">✓ Multimedia ondersteuning</span>
<span class="feature">✓ Zeer stabiel</span>
</div>
<p class="distro-ideal">Ideaal voor: <strong>Windows migratie, ouderen, conservatieve gebruikers</strong></p>
@ -192,13 +192,13 @@
<h3>Pop!_OS</h3>
<span class="distro-tag">Gaming</span>
</div>
<p class="distro-description">Gemaakt door System76. Excellent voor gaming en creatief werk.</p>
<p class="distro-description">Gemaakt door System76. Uitstekend voor gaming en creatief werk.</p>
<div class="distro-features">
<span class="feature">✓ Gaming optimized</span>
<span class="feature">✓ NVIDIA support</span>
<span class="feature">✓ Modern design</span>
<span class="feature">✓ Gaming-geoptimaliseerd</span>
<span class="feature">✓ NVIDIA ondersteuning</span>
<span class="feature">✓ Modern ontwerp</span>
</div>
<p class="distro-ideal">Ideaal voor: <strong>Gamers, developers, jongeren</strong></p>
<p class="distro-ideal">Ideaal voor: <strong>Gamers, ontwikkelaars, jongeren</strong></p>
</div>
<div class="distro-card">
@ -207,10 +207,10 @@
<h3>Elementary OS</h3>
<span class="distro-tag">Mooi</span>
</div>
<p class="distro-description">Prachtig design geïnspireerd door macOS. Eenvoudig en elegant.</p>
<p class="distro-description">Prachtig ontwerp geïnspireerd door macOS. Eenvoudig en elegant.</p>
<div class="distro-features">
<span class="feature">✓ Elegant design</span>
<span class="feature">✓ Privacy-focused</span>
<span class="feature">✓ Elegant ontwerp</span>
<span class="feature">✓ Privacy-gericht</span>
<span class="feature">✓ Mac-achtig</span>
</div>
<p class="distro-ideal">Ideaal voor: <strong>Mac gebruikers, designers, stijlbewuste mensen</strong></p>
@ -222,28 +222,28 @@
<h3>Fedora</h3>
<span class="distro-tag">Geavanceerd</span>
</div>
<p class="distro-description">Nieuwste technologieën en features. Voor technische gebruikers.</p>
<p class="distro-description">Nieuwste technologieën en functies. Voor technische gebruikers.</p>
<div class="distro-features">
<span class="feature">Cutting-edge</span>
<span class="feature">Geavanceerde technologie</span>
<span class="feature">✓ Red Hat basis</span>
<span class="feature">Developer tools</span>
<span class="feature">Ontwikkelaarstools</span>
</div>
<p class="distro-ideal">Ideaal voor: <strong>Developers, IT professionals, tech enthusiasts</strong></p>
<p class="distro-ideal">Ideaal voor: <strong>Ontwikkelaars, IT professionals, tech-enthousiasten</strong></p>
</div>
<div class="distro-card">
<div class="distro-header">
<div class="distro-logo">🔥</div>
<h3>Garuda Linux</h3>
<span class="distro-tag">Performance</span>
<span class="distro-tag">Prestaties</span>
</div>
<p class="distro-description">Arch-based met extreme prestaties. Prachtig design en gaming-geoptimaliseerd.</p>
<p class="distro-description">Arch-gebaseerd met extreme prestaties. Prachtig ontwerp en gaming-geoptimaliseerd.</p>
<div class="distro-features">
<span class="feature">✓ Arch basis</span>
<span class="feature">✓ Gaming ready</span>
<span class="feature">Beautiful UI</span>
<span class="feature">✓ Gaming-klaar</span>
<span class="feature">Mooie interface</span>
</div>
<p class="distro-ideal">Ideaal voor: <strong>Power users, gamers, performance enthusiasts</strong></p>
<p class="distro-ideal">Ideaal voor: <strong>Powergebruikers, gamers, prestatie-enthousiasten</strong></p>
</div>
</div>