mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-03 20:12:59 +00:00
Add files via upload
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
.PHONY: dev install
|
||||||
|
|
||||||
|
dev:
|
||||||
|
@echo "Starting development server..."
|
||||||
|
go run main.go
|
||||||
|
|
||||||
|
install:
|
||||||
|
@echo "Installing dependencies..."
|
||||||
|
go mod tidy
|
||||||
|
go get -u gopkg.in/gomail.v2
|
||||||
|
@echo "Build complete. Run with: go run main.go"
|
||||||
@@ -45,11 +45,11 @@ RUN mkdir -p data && chown -R appuser:appgroup /app
|
|||||||
USER appuser
|
USER appuser
|
||||||
|
|
||||||
# Expose port
|
# Expose port
|
||||||
EXPOSE 8080
|
EXPOSE 80
|
||||||
|
|
||||||
# Health check
|
# Health check
|
||||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||||
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/ || exit 1
|
CMD wget --no-verbose --tries=1 --spider http://localhost:80/ || exit 1
|
||||||
|
|
||||||
# Run the application
|
# Run the application
|
||||||
CMD ["./contact-scrape"]
|
CMD ["./contact-scrape"]
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
# Variables
|
# Variables
|
||||||
BINARY_NAME=contact-scrape
|
BINARY_NAME=contact-scrape
|
||||||
BUILD_DIR=build
|
BUILD_DIR=build
|
||||||
PORT=8080
|
PORT=80
|
||||||
|
|
||||||
help: ## Show this help message
|
help: ## Show this help message
|
||||||
@echo "Available commands:"
|
@echo "Available commands:"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ WorkingDirectory=/opt/contact-scrape
|
|||||||
ExecStart=/opt/contact-scrape/contact-scrape
|
ExecStart=/opt/contact-scrape/contact-scrape
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=5
|
RestartSec=5
|
||||||
Environment=PORT=8080
|
Environment=PORT=80
|
||||||
|
|
||||||
# Security settings
|
# Security settings
|
||||||
NoNewPrivileges=true
|
NoNewPrivileges=true
|
||||||
|
|||||||
@@ -33,6 +33,171 @@ type GeoCoords struct {
|
|||||||
Lng string `json:"lng"`
|
Lng string `json:"lng"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Contact struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Position string `json:"position"`
|
||||||
|
Phone string `json:"phone"`
|
||||||
|
ServicePhone string `json:"service_phone"`
|
||||||
|
Table int `json:"table"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func getEmbeddedHTML() string {
|
||||||
|
return `<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Kontakty</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
|
background-color: #f0f2f5;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 20px auto;
|
||||||
|
background-color: #ffffff;
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
background-color: #004990;
|
||||||
|
color: white;
|
||||||
|
padding: 20px 25px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header h1 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section {
|
||||||
|
margin-bottom: 25px;
|
||||||
|
border-bottom: 1px solid #eaeaea;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
margin-bottom: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 18px;
|
||||||
|
color: #004990;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-row {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-item {
|
||||||
|
width: 48%;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #555;
|
||||||
|
font-size: 14px;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.value {
|
||||||
|
color: #333;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight {
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
border-left: 3px solid #0072b0;
|
||||||
|
padding: 10px 15px;
|
||||||
|
margin: 15px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-link {
|
||||||
|
display: inline-block;
|
||||||
|
margin-top: 10px;
|
||||||
|
color: #0072b0;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
text-align: center;
|
||||||
|
padding: 15px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #777;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<h1>Kontakty</h1>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<div class="section">
|
||||||
|
<div class="section-title">Seznam kontaktů</div>
|
||||||
|
<div class="info-row">
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="label">Jméno</span>
|
||||||
|
<span class="value">Jan Novák</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="label">Pozice</span>
|
||||||
|
<span class="value">Ředitel</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="info-row">
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="label">Telefon</span>
|
||||||
|
<span class="value">+420 123 456 789</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="label">Služební telefon</span>
|
||||||
|
<span class="value">+420 987 654 321</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="highlight">
|
||||||
|
<span class="label">Stůl</span>
|
||||||
|
<span class="value">1</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
© 2025 Poppe + Potthoff - Automaticky generovaný email
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||||
|
|
||||||
@@ -42,8 +207,16 @@ func main() {
|
|||||||
w.Write([]byte(`{"status":"ok"}`))
|
w.Write([]byte(`{"status":"ok"}`))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
http.HandleFunc("/contacts", enableCORS(handleContacts))
|
||||||
|
http.HandleFunc("/reload", enableCORS(handleReload))
|
||||||
|
|
||||||
http.HandleFunc("/", enableCORS(func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", enableCORS(func(w http.ResponseWriter, r *http.Request) {
|
||||||
http.ServeFile(w, r, "index.html")
|
if r.URL.Path == "/kontakty" {
|
||||||
|
w.Header().Set("Content-Type", "text/html")
|
||||||
|
w.Write([]byte(getEmbeddedHTML()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.ServeFile(w, r, r.URL.Path[1:])
|
||||||
}))
|
}))
|
||||||
|
|
||||||
http.HandleFunc("/evidence-aut", enableCORS(func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/evidence-aut", enableCORS(func(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -126,19 +299,16 @@ func handleSubmit(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Formátování dat do českého formátu
|
|
||||||
czechMonths := []string{
|
czechMonths := []string{
|
||||||
"ledna", "února", "března", "dubna", "května", "června",
|
"ledna", "února", "března", "dubna", "května", "června",
|
||||||
"července", "srpna", "září", "října", "listopadu", "prosince",
|
"července", "srpna", "září", "října", "listopadu", "prosince",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zpracování začátku cesty
|
|
||||||
parsedDateStart, err := time.Parse("2006-01-02", entry.DateStart)
|
parsedDateStart, err := time.Parse("2006-01-02", entry.DateStart)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Chyba při parsování data začátku: %v", err)
|
log.Printf("Chyba při parsování data začátku: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zpracování konce cesty
|
|
||||||
parsedDateEnd, err := time.Parse("2006-01-02", entry.DateEnd)
|
parsedDateEnd, err := time.Parse("2006-01-02", entry.DateEnd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Chyba při parsování data konce: %v", err)
|
log.Printf("Chyba při parsování data konce: %v", err)
|
||||||
@@ -313,7 +483,6 @@ func sendEmail(entry TripEntry, parsedDateStart, parsedDateEnd time.Time, czechM
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
`)
|
`)
|
||||||
|
|
||||||
// Formátování dat a časů pro zobrazení
|
|
||||||
formattedDateStart := ""
|
formattedDateStart := ""
|
||||||
if parsedDateStart.IsZero() == false {
|
if parsedDateStart.IsZero() == false {
|
||||||
monthNameStart := czechMonths[parsedDateStart.Month()-1]
|
monthNameStart := czechMonths[parsedDateStart.Month()-1]
|
||||||
@@ -330,7 +499,6 @@ func sendEmail(entry TripEntry, parsedDateStart, parsedDateEnd time.Time, czechM
|
|||||||
formattedDateEnd = entry.DateEnd
|
formattedDateEnd = entry.DateEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
// Výpočet celkové doby jízdy
|
|
||||||
startDateTime, startErr := time.Parse("2006-01-02T15:04", fmt.Sprintf("%sT%s", entry.DateStart, entry.TimeStart))
|
startDateTime, startErr := time.Parse("2006-01-02T15:04", fmt.Sprintf("%sT%s", entry.DateStart, entry.TimeStart))
|
||||||
endDateTime, endErr := time.Parse("2006-01-02T15:04", fmt.Sprintf("%sT%s", entry.DateEnd, entry.TimeEnd))
|
endDateTime, endErr := time.Parse("2006-01-02T15:04", fmt.Sprintf("%sT%s", entry.DateEnd, entry.TimeEnd))
|
||||||
|
|
||||||
@@ -356,7 +524,6 @@ func sendEmail(entry TripEntry, parsedDateStart, parsedDateEnd time.Time, czechM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vypsání informací o řidiči a vozidle
|
|
||||||
htmlContent.WriteString(`<div class="section">
|
htmlContent.WriteString(`<div class="section">
|
||||||
<div class="section-title">Informace o řidiči a vozidle</div>
|
<div class="section-title">Informace o řidiči a vozidle</div>
|
||||||
<div class="info-row">
|
<div class="info-row">
|
||||||
@@ -371,7 +538,6 @@ func sendEmail(entry TripEntry, parsedDateStart, parsedDateEnd time.Time, czechM
|
|||||||
</div>
|
</div>
|
||||||
</div>`)
|
</div>`)
|
||||||
|
|
||||||
// Vypsání informací o trase
|
|
||||||
htmlContent.WriteString(`<div class="section">
|
htmlContent.WriteString(`<div class="section">
|
||||||
<div class="section-title">Informace o trase</div>
|
<div class="section-title">Informace o trase</div>
|
||||||
<div class="info-row">
|
<div class="info-row">
|
||||||
@@ -386,7 +552,6 @@ func sendEmail(entry TripEntry, parsedDateStart, parsedDateEnd time.Time, czechM
|
|||||||
</div>
|
</div>
|
||||||
</div>`)
|
</div>`)
|
||||||
|
|
||||||
// Vypsání informací o času
|
|
||||||
htmlContent.WriteString(`<div class="section">
|
htmlContent.WriteString(`<div class="section">
|
||||||
<div class="section-title">Časové údaje</div>
|
<div class="section-title">Časové údaje</div>
|
||||||
<div class="info-row">
|
<div class="info-row">
|
||||||
@@ -405,7 +570,6 @@ func sendEmail(entry TripEntry, parsedDateStart, parsedDateEnd time.Time, czechM
|
|||||||
</div>
|
</div>
|
||||||
</div>`)
|
</div>`)
|
||||||
|
|
||||||
// Vypsání informací o kilometrech
|
|
||||||
htmlContent.WriteString(`<div class="section">
|
htmlContent.WriteString(`<div class="section">
|
||||||
<div class="section-title">Stav tachometru</div>
|
<div class="section-title">Stav tachometru</div>
|
||||||
<div class="info-row">
|
<div class="info-row">
|
||||||
@@ -456,3 +620,11 @@ func sendEmail(entry TripEntry, parsedDateStart, parsedDateEnd time.Time, czechM
|
|||||||
|
|
||||||
return d.DialAndSend(m)
|
return d.DialAndSend(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleContacts(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// Implement contact listing logic
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleReload(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// Implement contact reload logic
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user