mirror of
https://github.com/sstent/garminsync-go.git
synced 2026-02-14 11:21:43 +00:00
checkpoint 3
This commit is contained in:
6
fix_imports.sh
Executable file
6
fix_imports.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Find all Go files and replace import paths
|
||||||
|
find . -name '*.go' -exec sed -i \
|
||||||
|
-e 's|github.com/yourusername/garminsync|github.com/sstent/garminsync-go|g' \
|
||||||
|
-e 's|github.com/sstent/garminsync-go/internal/parser/activity|github.com/sstent/garminsync-go/internal/parser/activity/activity|g' \
|
||||||
|
{} +
|
||||||
29
go.mod
29
go.mod
@@ -1,30 +1,9 @@
|
|||||||
// go.mod - Keep dependencies minimal
|
module github.com/sstent/garminsync-go
|
||||||
module garminsync
|
|
||||||
|
|
||||||
go 1.21
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gorilla/mux v1.8.0 // For HTTP routing
|
github.com/joho/godotenv v1.5.1
|
||||||
github.com/mattn/go-sqlite3 v1.14.17
|
github.com/mattn/go-sqlite3 v1.14.22
|
||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
golang.org/x/net v0.12.0 // For HTTP client
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/BurntSushi/toml v1.2.1 // indirect
|
|
||||||
github.com/client9/misspell v0.3.4 // indirect
|
|
||||||
github.com/google/go-cmp v0.5.8 // indirect
|
|
||||||
github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8 // indirect
|
|
||||||
github.com/joho/godotenv v1.5.1 // indirect
|
|
||||||
github.com/kisielk/errcheck v1.6.1 // indirect
|
|
||||||
github.com/mdempsky/unconvert v0.0.0-20230125054757-2661c2c99a9b // indirect
|
|
||||||
github.com/tormoder/fit v0.15.0 // indirect
|
|
||||||
golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a // indirect
|
|
||||||
golang.org/x/mod v0.8.0 // indirect
|
|
||||||
golang.org/x/sync v0.1.0 // indirect
|
|
||||||
golang.org/x/sys v0.10.0 // indirect
|
|
||||||
golang.org/x/text v0.11.0 // indirect
|
|
||||||
golang.org/x/tools v0.6.0 // indirect
|
|
||||||
honnef.co/go/tools v0.4.2 // indirect
|
|
||||||
mvdan.cc/gofumpt v0.4.0 // indirect
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/yourusername/garminsync/internal/parser/activity"
|
"github.com/sstent/garminsync-go/internal/parser/activity/activity"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GPX represents the root element of a GPX file
|
// GPX represents the root element of a GPX file
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/yourusername/garminsync/internal/database"
|
"github.com/sstent/garminsync-go/internal/database"
|
||||||
"github.com/yourusername/garminsync/internal/garmin"
|
"github.com/sstent/garminsync-go/internal/garmin"
|
||||||
"github.com/yourusername/garminsync/internal/parser"
|
"github.com/sstent/garminsync-go/internal/parser"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SyncService struct {
|
type SyncService struct {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/yourusername/garminsync/internal/database"
|
"github.com/sstent/garminsync-go/internal/database"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WebHandler struct {
|
type WebHandler struct {
|
||||||
|
|||||||
@@ -1 +1,47 @@
|
|||||||
|
package web
|
||||||
|
|
||||||
|
import (
|
||||||
|
"html/template"
|
||||||
|
"io"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/sstent/garminsync-go/internal/database"
|
||||||
|
)
|
||||||
|
|
||||||
|
type WebHandler struct {
|
||||||
|
templates *template.Template
|
||||||
|
db *database.SQLiteDB
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewWebHandler(db *database.SQLiteDB) *WebHandler {
|
||||||
|
return &WebHandler{
|
||||||
|
db: db,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *WebHandler) LoadTemplates(templatesDir string) error {
|
||||||
|
tmpl := template.New("base")
|
||||||
|
tmpl = tmpl.Funcs(template.FuncMap{})
|
||||||
|
|
||||||
|
// Load layouts
|
||||||
|
layouts, err := filepath.Glob(filepath.Join(templatesDir, "layouts/*.html"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load pages
|
||||||
|
pages, err := filepath.Glob(filepath.Join(templatesDir, "pages/*.html"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combine all templates
|
||||||
|
files := append(layouts, pages...)
|
||||||
|
|
||||||
|
h.templates, err = tmpl.ParseFiles(files...)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *WebHandler) renderTemplate(w io.Writer, name string, data interface{}) error {
|
||||||
|
return h.templates.ExecuteTemplate(w, name, data)
|
||||||
|
}
|
||||||
|
|||||||
8
main.go
8
main.go
@@ -15,10 +15,10 @@ import (
|
|||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
|
|
||||||
"github.com/yourusername/garminsync/internal/database"
|
"github.com/sstent/garminsync-go/internal/database"
|
||||||
"github.com/yourusername/garminsync/internal/garmin"
|
"github.com/sstent/garminsync-go/internal/garmin"
|
||||||
"github.com/yourusername/garminsync/internal/sync"
|
"github.com/sstent/garminsync-go/internal/sync"
|
||||||
"github.com/yourusername/garminsync/internal/web"
|
"github.com/sstent/garminsync-go/internal/web"
|
||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
|
|||||||
Reference in New Issue
Block a user