diff --git a/folderopener/main.go b/folderopener/main.go
new file mode 100644
index 0000000..abfb20a
--- /dev/null
+++ b/folderopener/main.go
@@ -0,0 +1,68 @@
+package main
+
+import (
+ "fmt"
+ "log"
+ "net/http"
+ "os/exec"
+ "strings"
+)
+
+func main() {
+ // Set up HTTP server
+ http.HandleFunc("/open", openFolderHandler)
+
+ // Start server on port 8080
+ fmt.Println("Folder opener server running on http://localhost:8080")
+ log.Fatal(http.ListenAndServe(":8080", nil))
+}
+
+func openFolderHandler(w http.ResponseWriter, r *http.Request) {
+ // Set CORS headers to allow requests from any origin
+ w.Header().Set("Access-Control-Allow-Origin", "*")
+ w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS")
+ w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
+
+ // Handle preflight OPTIONS request
+ if r.Method == "OPTIONS" {
+ w.WriteHeader(http.StatusOK)
+ return
+ }
+
+ // Only allow GET requests
+ if r.Method != "GET" {
+ http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
+ return
+ }
+
+ // Get the folder path from the query parameter
+ folderPath := r.URL.Query().Get("path")
+ if folderPath == "" {
+ http.Error(w, "Missing path parameter", http.StatusBadRequest)
+ return
+ }
+
+ // Log the request
+ fmt.Printf("Opening folder: %s\n", folderPath)
+
+ // Open the folder in Windows Explorer
+ // The /select flag opens Explorer with the specified folder selected
+ cmd := exec.Command("explorer.exe", folderPath)
+ err := cmd.Start()
+
+ if err != nil {
+ // If there was an error, try to clean the path and retry
+ cleanPath := strings.ReplaceAll(folderPath, "/", "\\")
+ cmd = exec.Command("explorer.exe", cleanPath)
+ err = cmd.Start()
+
+ if err != nil {
+ http.Error(w, fmt.Sprintf("Error opening folder: %v", err), http.StatusInternalServerError)
+ return
+ }
+ }
+
+ // Return success response
+ w.WriteHeader(http.StatusOK)
+ fmt.Fprintf(w, "Opening folder: %s", folderPath)
+}
diff --git a/folderopener/start_server.bat b/folderopener/start_server.bat
new file mode 100644
index 0000000..32ac4a2
--- /dev/null
+++ b/folderopener/start_server.bat
@@ -0,0 +1,4 @@
+@echo off
+echo Starting Folder Opener Server...
+cd %~dp0
+go run main.go
diff --git a/index.html b/index.html
index 6453f9f..f1b1824 100644
--- a/index.html
+++ b/index.html
@@ -1,123 +1,205 @@
-
-
-
-
-
- Aplikační Rozcestník
-
-
-
-
-
-
-
-
-
-
Poppe + Potthoff - Firemní Aplikace
-
Rychlý přístup ke všem důležitým systémům
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Záznam jízdy služebního vozu
-
Systém pro evidenci služebních jízd.
-
- Otevřít aplikaci
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Canboard úkolníček
-
Správa úkolů a projektů v přehledném kanban stylu
-
- Otevřít aplikaci
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+ Aplikační Rozcestník
+
+
+
+
+
+
+
+
+
+
Poppe + Potthoff - Firemní Aplikace
+
Rychlý přístup ke všem důležitým systémům
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Záznam jízdy služebního vozu
+
Systém pro evidenci služebních jízd.
+
+ Otevřít aplikaci
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ WINDOWS SDÍLENÉ SLOŽKY
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Telefonní seznam
+
Aktuální telefonní seznam společnosti
+
+
+
+
+
+
+
+
+
+
+
+
+
Řízená dokumentace
+
Přístup k firemní řízené dokumentaci
+
+
+
+
+
+
+
+
+
+
+
+
+
Management úkolů
+
Systém pro správu a sledování firemních úkolů
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main.go b/main.go
index 89102d1..4337618 100644
--- a/main.go
+++ b/main.go
@@ -8,6 +8,7 @@ import (
"log"
"net/http"
"os"
+ "os/exec"
"strings"
"time"
@@ -50,12 +51,15 @@ func main() {
http.ServeFile(w, r, "evidence-aut.html")
}))
+ // Add folder opener endpoint
+ http.HandleFunc("/open", enableCORS(openFolderHandler))
+
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
- log.Printf("Server běží na portu %s", port)
+ log.Printf("Server běží na portu %s (včetně otevírání složek Windows)", port)
err := http.ListenAndServe(":"+port, nil)
if err != nil {
log.Fatalf("Chyba při spuštění serveru: %v", err)
@@ -156,6 +160,55 @@ func handleSubmit(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`{"message":"Záznam byl úspěšně uložen a email odeslán"}`))
}
+// Handler pro otevírání Windows složek přímo z prohlížeče
+func openFolderHandler(w http.ResponseWriter, r *http.Request) {
+ // Get the folder path from the query parameter
+ folderPath := r.URL.Query().Get("path")
+ if folderPath == "" {
+ http.Error(w, "Missing path parameter", http.StatusBadRequest)
+ return
+ }
+
+ // Log the request
+ log.Printf("Otevírání složky: %s", folderPath)
+
+ // Properly handle backslashes in Windows paths
+ // First, replace any forward slashes with backslashes
+ folderPath = strings.ReplaceAll(folderPath, "/", "\\")
+
+ // Fix any double backslashes that might have been created by JavaScript escaping
+ for strings.Contains(folderPath, "\\\\") {
+ folderPath = strings.ReplaceAll(folderPath, "\\\\", "\\")
+ }
+
+ // Log the cleaned path
+ log.Printf("Upravená cesta: %s", folderPath)
+
+ // Open the folder in Windows Explorer
+ cmd := exec.Command("explorer.exe", folderPath)
+ err := cmd.Start()
+
+ if err != nil {
+ // If there was an error, try opening the parent directory
+ log.Printf("Chyba při otevírání složky: %v, zkouším jinou metodu", err)
+
+ // Try using /root,path format which sometimes works better
+ cmd = exec.Command("explorer.exe", "/root," + folderPath)
+ err = cmd.Start()
+
+ if err != nil {
+ log.Printf("Chyba při otevírání složky: %v", err)
+ http.Error(w, fmt.Sprintf("Error opening folder: %v", err), http.StatusInternalServerError)
+ return
+ }
+ }
+
+ // Return success response
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ json.NewEncoder(w).Encode(map[string]string{"status": "success", "message": fmt.Sprintf("Opening folder: %s", folderPath)})
+}
+
func sendEmail(entry TripEntry, parsedDateStart, parsedDateEnd time.Time, czechMonths []string) error {
smtpHost := "mail.pp-kunovice.cz"
smtpPort := 465