From a57844a19b4c01eb62c4435c2871e3e325046dc3 Mon Sep 17 00:00:00 2001 From: Jo Vandeginste Date: Mon, 6 Jan 2025 21:49:23 +0100 Subject: [PATCH] Improve the page options for scripts and stylesheets Signed-off-by: Jo Vandeginste --- views/admin/edit_user.templ | 2 +- views/admin/edit_user_templ.go | 2 +- views/admin/root.templ | 2 +- views/admin/root_templ.go | 2 +- views/equipment/add.templ | 2 +- views/equipment/add_templ.go | 2 +- views/equipment/edit.templ | 2 +- views/equipment/edit_templ.go | 2 +- views/equipment/list.templ | 2 +- views/equipment/list_templ.go | 2 +- views/equipment/show.templ | 2 +- views/equipment/show_templ.go | 2 +- views/partials/page.go | 54 ++++++++++++++++++++ views/partials/page.templ | 8 +-- views/partials/page_templ.go | 13 ++--- views/partials/page_test.go | 40 +++++++++++++++ views/route_segments/add.templ | 2 +- views/route_segments/add_templ.go | 2 +- views/route_segments/edit.templ | 2 +- views/route_segments/edit_templ.go | 2 +- views/route_segments/list.templ | 2 +- views/route_segments/list_templ.go | 2 +- views/route_segments/show.templ | 9 +--- views/route_segments/show_templ.go | 39 ++++++-------- views/user/heatmap.templ | 14 +---- views/user/heatmap_templ.go | 16 +----- views/user/login.templ | 2 +- views/user/login_templ.go | 2 +- views/user/profile.templ | 2 +- views/user/profile_templ.go | 2 +- views/user/show.templ | 2 +- views/user/show_templ.go | 2 +- views/user/statistics.templ | 9 +--- views/user/statistics_templ.go | 37 ++++++-------- views/workouts/add.templ | 2 +- views/workouts/add_templ.go | 2 +- views/workouts/create_route_segment.templ | 18 ++----- views/workouts/create_route_segment_templ.go | 40 ++++++--------- views/workouts/edit.templ | 2 +- views/workouts/edit_templ.go | 2 +- views/workouts/list.templ | 2 +- views/workouts/list_templ.go | 2 +- views/workouts/show.templ | 18 ++----- views/workouts/show_templ.go | 30 ++++------- 44 files changed, 202 insertions(+), 203 deletions(-) create mode 100644 views/partials/page.go create mode 100644 views/partials/page_test.go diff --git a/views/admin/edit_user.templ b/views/admin/edit_user.templ index 704a025f..c66b85cc 100644 --- a/views/admin/edit_user.templ +++ b/views/admin/edit_user.templ @@ -9,7 +9,7 @@ import ( ) templ EditUser(u *database.User) { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) {

@helpers.IconFor(`admin`) { i18n.T(ctx, "Manage user '%s'", u.Name) } diff --git a/views/admin/edit_user_templ.go b/views/admin/edit_user_templ.go index c76a1d37..b99e21d7 100644 --- a/views/admin/edit_user_templ.go +++ b/views/admin/edit_user_templ.go @@ -218,7 +218,7 @@ func EditUser(u *database.User) templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/admin/root.templ b/views/admin/root.templ index fe3d5b94..93fd7bea 100644 --- a/views/admin/root.templ +++ b/views/admin/root.templ @@ -8,7 +8,7 @@ import ( ) templ Root(users []*database.User) { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) {

@helpers.IconFor(`admin`) { i18n.T(ctx, "Manage") } diff --git a/views/admin/root_templ.go b/views/admin/root_templ.go index 46c2636f..1a2f42ff 100644 --- a/views/admin/root_templ.go +++ b/views/admin/root_templ.go @@ -343,7 +343,7 @@ func Root(users []*database.User) templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/equipment/add.templ b/views/equipment/add.templ index 9feffedc..12dac3cc 100644 --- a/views/equipment/add.templ +++ b/views/equipment/add.templ @@ -7,7 +7,7 @@ import ( ) templ Add() { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) {

@helpers.IconFor("equipment-add") { i18n.T(ctx, "Add equipment") } diff --git a/views/equipment/add_templ.go b/views/equipment/add_templ.go index c32429a8..6922ffc2 100644 --- a/views/equipment/add_templ.go +++ b/views/equipment/add_templ.go @@ -131,7 +131,7 @@ func Add() templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/equipment/edit.templ b/views/equipment/edit.templ index cf6edb7a..4e4dd6c0 100644 --- a/views/equipment/edit.templ +++ b/views/equipment/edit.templ @@ -8,7 +8,7 @@ import ( ) templ Edit(e *database.Equipment) { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) {

{ i18n.T(ctx, "Equipment") }: { e.Name }

diff --git a/views/equipment/edit_templ.go b/views/equipment/edit_templ.go index 1816268a..a3c86caf 100644 --- a/views/equipment/edit_templ.go +++ b/views/equipment/edit_templ.go @@ -262,7 +262,7 @@ func Edit(e *database.Equipment) templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/equipment/list.templ b/views/equipment/list.templ index 84d1a591..28c0ec72 100644 --- a/views/equipment/list.templ +++ b/views/equipment/list.templ @@ -9,7 +9,7 @@ import ( ) templ List(equipment []*database.Equipment) { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) {

@helpers.IconFor("equipment") diff --git a/views/equipment/list_templ.go b/views/equipment/list_templ.go index 5d5417fc..dce85182 100644 --- a/views/equipment/list_templ.go +++ b/views/equipment/list_templ.go @@ -215,7 +215,7 @@ func List(equipment []*database.Equipment) templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/equipment/show.templ b/views/equipment/show.templ index 95496e34..7063580d 100644 --- a/views/equipment/show.templ +++ b/views/equipment/show.templ @@ -8,7 +8,7 @@ import ( ) templ Show(e *database.Equipment) { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) { {{ currentUser := helpers.CurrentUser(ctx) }} {{ pu := currentUser.PreferredUnits() }}
diff --git a/views/equipment/show_templ.go b/views/equipment/show_templ.go index d99c5989..c3cc4110 100644 --- a/views/equipment/show_templ.go +++ b/views/equipment/show_templ.go @@ -477,7 +477,7 @@ func Show(e *database.Equipment) templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/partials/page.go b/views/partials/page.go new file mode 100644 index 00000000..4d758d51 --- /dev/null +++ b/views/partials/page.go @@ -0,0 +1,54 @@ +package partials + +type PageOptions struct { + Scripts, Styles []string +} + +func NewPageOptions() *PageOptions { + return &PageOptions{Scripts: nil, Styles: nil} +} + +func (o *PageOptions) WithScripts(scripts ...string) *PageOptions { + return &PageOptions{ + Scripts: append(o.Scripts, scripts...), + Styles: o.Styles, + } +} + +func (o *PageOptions) WithStyles(styles ...string) *PageOptions { + return &PageOptions{ + Scripts: o.Scripts, + Styles: append(o.Styles, styles...), + } +} + +func (o *PageOptions) WithCharts() *PageOptions { + return o. + WithScripts("/dist/apexcharts.min.js"). + WithStyles("/dist/apexcharts.css") +} + +func (o *PageOptions) WithMaps() *PageOptions { + return o. + WithScripts("/dist/leaflet.js"). + WithStyles("/dist/leaflet.css") +} + +func (o *PageOptions) WithHeatMaps() *PageOptions { + return o.WithMaps(). + WithScripts( + "/dist/simpleheat.js", + "/dist/leaflet-heat.js", + "/dist/leaflet.markercluster.js", + ). + WithStyles( + "/dist/MarkerCluster.css", + "/dist/MarkerCluster.Default.css", + ) +} + +func (o *PageOptions) WithSharing() *PageOptions { + return o. + WithScripts("/dist/shareon.iife.js"). + WithStyles("/dist/shareon.min.css") +} diff --git a/views/partials/page.templ b/views/partials/page.templ index ec548cab..3213bc2a 100644 --- a/views/partials/page.templ +++ b/views/partials/page.templ @@ -2,16 +2,10 @@ package partials import "github.com/jovandeginste/workout-tracker/views/helpers" -type PageOptions struct { - Scripts []string - Styles []string -} - -templ Page(options PageOptions) { +templ Page(options *PageOptions) { - for _, script := range options.Scripts { } diff --git a/views/partials/page_templ.go b/views/partials/page_templ.go index c05312a6..c7fd27eb 100644 --- a/views/partials/page_templ.go +++ b/views/partials/page_templ.go @@ -10,12 +10,7 @@ import templruntime "github.com/a-h/templ/runtime" import "github.com/jovandeginste/workout-tracker/views/helpers" -type PageOptions struct { - Scripts []string - Styles []string -} - -func Page(options PageOptions) templ.Component { +func Page(options *PageOptions) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -36,7 +31,7 @@ func Page(options PageOptions) templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -48,7 +43,7 @@ func Page(options PageOptions) templ.Component { var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(helpers.RouteFor(ctx, "assets") + script) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/partials/page.templ`, Line: 16, Col: 58} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/partials/page.templ`, Line: 10, Col: 58} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -67,7 +62,7 @@ func Page(options PageOptions) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(helpers.RouteFor(ctx, "assets") + stylesheet) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/partials/page.templ`, Line: 19, Col: 61} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/partials/page.templ`, Line: 13, Col: 61} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { diff --git a/views/partials/page_test.go b/views/partials/page_test.go new file mode 100644 index 00000000..f83f77e1 --- /dev/null +++ b/views/partials/page_test.go @@ -0,0 +1,40 @@ +package partials + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestNewPageOptions(t *testing.T) { + po := NewPageOptions() + + assert.Empty(t, po.Scripts) + assert.Empty(t, po.Styles) +} + +func TestPageOptions_WithScripts(t *testing.T) { + po := NewPageOptions().WithScripts("/a.js", "/b.js") + + assert.Contains(t, po.Scripts, "/a.js") + assert.Contains(t, po.Scripts, "/b.js") +} + +func TestPageOptions_WithStyles(t *testing.T) { + po := NewPageOptions().WithStyles("/a.css", "/b.css") + + assert.Contains(t, po.Styles, "/a.css") + assert.Contains(t, po.Styles, "/b.css") +} + +func TestPageOptions_WithScriptsAndStyles(t *testing.T) { + po := NewPageOptions(). + WithScripts("/a.js", "/b.js"). + WithStyles("/a.css", "/b.css") + + assert.Contains(t, po.Scripts, "/a.js") + assert.Contains(t, po.Scripts, "/b.js") + + assert.Contains(t, po.Styles, "/a.css") + assert.Contains(t, po.Styles, "/b.css") +} diff --git a/views/route_segments/add.templ b/views/route_segments/add.templ index 6c2f9bb9..d1af3081 100644 --- a/views/route_segments/add.templ +++ b/views/route_segments/add.templ @@ -7,7 +7,7 @@ import ( ) templ Add() { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) {

@helpers.IconFor("route-segment-add") { i18n.T(ctx, "Add route segment") } diff --git a/views/route_segments/add_templ.go b/views/route_segments/add_templ.go index ba6ea251..3aa41c52 100644 --- a/views/route_segments/add_templ.go +++ b/views/route_segments/add_templ.go @@ -131,7 +131,7 @@ func Add() templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/route_segments/edit.templ b/views/route_segments/edit.templ index 12828f7b..b5282951 100644 --- a/views/route_segments/edit.templ +++ b/views/route_segments/edit.templ @@ -8,7 +8,7 @@ import ( ) templ Edit(s *database.RouteSegment) { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) {

@helpers.IconFor("route-segment") diff --git a/views/route_segments/edit_templ.go b/views/route_segments/edit_templ.go index 5a4fe8a5..98e3f5cf 100644 --- a/views/route_segments/edit_templ.go +++ b/views/route_segments/edit_templ.go @@ -238,7 +238,7 @@ func Edit(s *database.RouteSegment) templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/route_segments/list.templ b/views/route_segments/list.templ index bd740219..9b87bf19 100644 --- a/views/route_segments/list.templ +++ b/views/route_segments/list.templ @@ -8,7 +8,7 @@ import ( ) templ List(segments []*database.RouteSegment) { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) {

@helpers.IconFor("route-segment") diff --git a/views/route_segments/list_templ.go b/views/route_segments/list_templ.go index 5d5afcca..a98694bf 100644 --- a/views/route_segments/list_templ.go +++ b/views/route_segments/list_templ.go @@ -188,7 +188,7 @@ func List(segments []*database.RouteSegment) templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/route_segments/show.templ b/views/route_segments/show.templ index 204691f7..97fba666 100644 --- a/views/route_segments/show.templ +++ b/views/route_segments/show.templ @@ -8,14 +8,7 @@ import ( ) templ Show(s *database.RouteSegment) { - @partials.Page(partials.PageOptions{ - Scripts: []string{ - "/dist/leaflet.js", - }, - Styles: []string{ - "/dist/leaflet.css", - }, - }) { + @partials.Page(partials.NewPageOptions().WithMaps()) { {{ preferredUnits := helpers.CurrentUser(ctx).PreferredUnits() }}
diff --git a/views/route_segments/show_templ.go b/views/route_segments/show_templ.go index 836baba1..63394122 100644 --- a/views/route_segments/show_templ.go +++ b/views/route_segments/show_templ.go @@ -65,7 +65,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "refresh in progress")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 25, Col: 42} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 18, Col: 42} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -91,7 +91,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(s.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 32, Col: 12} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 25, Col: 12} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -120,7 +120,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "User")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 50, Col: 34} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 43, Col: 34} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -133,7 +133,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Workout")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 51, Col: 37} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 44, Col: 37} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -146,7 +146,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Distance")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 52, Col: 38} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 45, Col: 38} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -159,7 +159,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Duration")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 53, Col: 38} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 46, Col: 38} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -172,7 +172,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Tempo")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 54, Col: 35} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 47, Col: 35} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -199,7 +199,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(m.Workout.User.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 62, Col: 33} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 55, Col: 33} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -221,7 +221,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(m.Workout.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 67, Col: 28} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 60, Col: 28} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { @@ -234,7 +234,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(helpers.HumanDistance(ctx, m.Distance)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 71, Col: 51} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 64, Col: 51} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { @@ -247,7 +247,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var15 string templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(preferredUnits.Distance()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 71, Col: 81} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 64, Col: 81} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) if templ_7745c5c3_Err != nil { @@ -260,7 +260,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var16 string templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(helpers.HumanDuration(m.Duration)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 74, Col: 46} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 67, Col: 46} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { @@ -273,7 +273,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var17 string templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(helpers.HumanTempo(ctx, m.AverageSpeed())) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 77, Col: 54} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 70, Col: 54} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) if templ_7745c5c3_Err != nil { @@ -286,7 +286,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var18 string templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(preferredUnits.Tempo()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 77, Col: 81} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 70, Col: 81} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) if templ_7745c5c3_Err != nil { @@ -313,7 +313,7 @@ func Show(s *database.RouteSegment) templ.Component { var templ_7745c5c3_Var19 string templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Notes")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 91, Col: 29} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/route_segments/show.templ`, Line: 84, Col: 29} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) if templ_7745c5c3_Err != nil { @@ -338,14 +338,7 @@ func Show(s *database.RouteSegment) templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{ - Scripts: []string{ - "/dist/leaflet.js", - }, - Styles: []string{ - "/dist/leaflet.css", - }, - }).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions().WithMaps()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/user/heatmap.templ b/views/user/heatmap.templ index 5d1ff929..763efd72 100644 --- a/views/user/heatmap.templ +++ b/views/user/heatmap.templ @@ -8,19 +8,7 @@ import ( ) templ Heatmap(workouts []*database.Workout) { - @partials.Page(partials.PageOptions{ - Scripts: []string{ - "/dist/leaflet.js", - "/dist/simpleheat.js", - "/dist/leaflet-heat.js", - "/dist/leaflet.markercluster.js", - }, - Styles: []string{ - "/dist/leaflet.css", - "/dist/MarkerCluster.css", - "/dist/MarkerCluster.Default.css", - }, - }) { + @partials.Page(partials.NewPageOptions().WithHeatMaps()) {

@helpers.IconFor(`heatmap`) { i18n.T(ctx, "Heatmap") } diff --git a/views/user/heatmap_templ.go b/views/user/heatmap_templ.go index 5b968400..86a4b97c 100644 --- a/views/user/heatmap_templ.go +++ b/views/user/heatmap_templ.go @@ -59,7 +59,7 @@ func Heatmap(workouts []*database.Workout) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Heatmap")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/heatmap.templ`, Line: 26, Col: 27} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/heatmap.templ`, Line: 14, Col: 27} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -91,19 +91,7 @@ func Heatmap(workouts []*database.Workout) templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{ - Scripts: []string{ - "/dist/leaflet.js", - "/dist/simpleheat.js", - "/dist/leaflet-heat.js", - "/dist/leaflet.markercluster.js", - }, - Styles: []string{ - "/dist/leaflet.css", - "/dist/MarkerCluster.css", - "/dist/MarkerCluster.Default.css", - }, - }).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions().WithHeatMaps()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/user/login.templ b/views/user/login.templ index fd3affd3..f1667456 100644 --- a/views/user/login.templ +++ b/views/user/login.templ @@ -7,7 +7,7 @@ import ( ) templ Login() { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) {
diff --git a/views/user/login_templ.go b/views/user/login_templ.go index 99f38ff2..c225c86e 100644 --- a/views/user/login_templ.go +++ b/views/user/login_templ.go @@ -223,7 +223,7 @@ func Login() templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/user/profile.templ b/views/user/profile.templ index d4876e15..a31eedcb 100644 --- a/views/user/profile.templ +++ b/views/user/profile.templ @@ -8,7 +8,7 @@ import ( ) templ Profile(u *database.User) { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) {

@helpers.IconFor("user-profile") { i18n.T(ctx, "Your profile") } diff --git a/views/user/profile_templ.go b/views/user/profile_templ.go index d474f014..31a64e2f 100644 --- a/views/user/profile_templ.go +++ b/views/user/profile_templ.go @@ -555,7 +555,7 @@ func Profile(u *database.User) templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/user/show.templ b/views/user/show.templ index aacadb0e..088a5e7d 100644 --- a/views/user/show.templ +++ b/views/user/show.templ @@ -9,7 +9,7 @@ import ( ) templ Show(user *database.User, users []*database.User, wos []*database.Workout, recentWorkouts []*database.Workout) { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) {

@helpers.IconFor("dashboard") { i18n.T(ctx, "Dashboard for %s", user.Name) } diff --git a/views/user/show_templ.go b/views/user/show_templ.go index 62a34d47..49be16a3 100644 --- a/views/user/show_templ.go +++ b/views/user/show_templ.go @@ -193,7 +193,7 @@ func Show(user *database.User, users []*database.User, wos []*database.Workout, } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/user/statistics.templ b/views/user/statistics.templ index 8ee871ce..066e274f 100644 --- a/views/user/statistics.templ +++ b/views/user/statistics.templ @@ -8,14 +8,7 @@ import ( ) templ Statistics(u *database.User, since, per string) { - @partials.Page(partials.PageOptions{ - Scripts: []string{ - "/dist/apexcharts.min.js", - }, - Styles: []string{ - "/dist/apexcharts.css", - }, - }) { + @partials.Page(partials.NewPageOptions().WithCharts()) {

@helpers.IconFor("statistics") { i18n.T(ctx, "Your progress per %s for the past %s", i18n.T(ctx, per), i18n.T(ctx, since)) } diff --git a/views/user/statistics_templ.go b/views/user/statistics_templ.go index 42da7198..cdc1521a 100644 --- a/views/user/statistics_templ.go +++ b/views/user/statistics_templ.go @@ -59,7 +59,7 @@ func Statistics(u *database.User, since, per string) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Your progress per %s for the past %s", i18n.T(ctx, per), i18n.T(ctx, since))) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 21, Col: 94} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 14, Col: 94} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -72,7 +72,7 @@ func Statistics(u *database.User, since, per string) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Since")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 25, Col: 45} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 18, Col: 45} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -90,7 +90,7 @@ func Statistics(u *database.User, since, per string) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(o) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 28, Col: 23} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 21, Col: 23} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -113,7 +113,7 @@ func Statistics(u *database.User, since, per string) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, o)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 28, Col: 67} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 21, Col: 67} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -131,7 +131,7 @@ func Statistics(u *database.User, since, per string) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Per")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 31, Col: 41} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 24, Col: 41} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -149,7 +149,7 @@ func Statistics(u *database.User, since, per string) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(o) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 34, Col: 23} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 27, Col: 23} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -172,7 +172,7 @@ func Statistics(u *database.User, since, per string) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, o)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 34, Col: 65} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 27, Col: 65} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -190,7 +190,7 @@ func Statistics(u *database.User, since, per string) templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "refresh")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 37, Col: 65} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 30, Col: 65} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -207,7 +207,7 @@ func Statistics(u *database.User, since, per string) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Workouts")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 44, Col: 32} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 37, Col: 32} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -224,7 +224,7 @@ func Statistics(u *database.User, since, per string) templ.Component { var templ_7745c5c3_Var12 string templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Duration")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 53, Col: 32} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 46, Col: 32} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { @@ -241,7 +241,7 @@ func Statistics(u *database.User, since, per string) templ.Component { var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Distance")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 62, Col: 32} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 55, Col: 32} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { @@ -258,7 +258,7 @@ func Statistics(u *database.User, since, per string) templ.Component { var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Average speed")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 71, Col: 37} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 64, Col: 37} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { @@ -275,7 +275,7 @@ func Statistics(u *database.User, since, per string) templ.Component { var templ_7745c5c3_Var15 string templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Average speed (no pause)")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 80, Col: 48} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 73, Col: 48} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) if templ_7745c5c3_Err != nil { @@ -292,7 +292,7 @@ func Statistics(u *database.User, since, per string) templ.Component { var templ_7745c5c3_Var16 string templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Max speed")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 89, Col: 33} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/user/statistics.templ`, Line: 82, Col: 33} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { @@ -330,14 +330,7 @@ func Statistics(u *database.User, since, per string) templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{ - Scripts: []string{ - "/dist/apexcharts.min.js", - }, - Styles: []string{ - "/dist/apexcharts.css", - }, - }).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions().WithCharts()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/workouts/add.templ b/views/workouts/add.templ index 2373f865..f08e1892 100644 --- a/views/workouts/add.templ +++ b/views/workouts/add.templ @@ -7,7 +7,7 @@ import ( ) templ Add() { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) {

@helpers.IconFor("workout-add") { i18n.T(ctx, "Add a workout") } diff --git a/views/workouts/add_templ.go b/views/workouts/add_templ.go index 92ea5a7f..4a8c6163 100644 --- a/views/workouts/add_templ.go +++ b/views/workouts/add_templ.go @@ -290,7 +290,7 @@ func Add() templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/workouts/create_route_segment.templ b/views/workouts/create_route_segment.templ index 834ff67f..24692654 100644 --- a/views/workouts/create_route_segment.templ +++ b/views/workouts/create_route_segment.templ @@ -8,19 +8,11 @@ import ( ) templ CreateRouteSegment(w *database.Workout) { - @partials.Page(partials.PageOptions{ - Scripts: []string{ - "/dist/leaflet.js", - "/route_segments.js", - "/dist/apexcharts.min.js", - "/dist/shareon.iife.js", - }, - Styles: []string{ - "/dist/leaflet.css", - "/dist/apexcharts.css", - "/dist/shareon.min.css", - }, - }) { + @partials.Page( + partials.NewPageOptions(). + WithSharing().WithCharts().WithMaps(). + WithScripts("/route_segments.js"), + ) {

@helpers.IconFor(w.Type.String()) diff --git a/views/workouts/create_route_segment_templ.go b/views/workouts/create_route_segment_templ.go index 8b03c30c..920932f9 100644 --- a/views/workouts/create_route_segment_templ.go +++ b/views/workouts/create_route_segment_templ.go @@ -59,7 +59,7 @@ func CreateRouteSegment(w *database.Workout) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(w.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 27, Col: 12} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 19, Col: 12} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -105,7 +105,7 @@ func CreateRouteSegment(w *database.Workout) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(helpers.RouteFor(ctx, "assets") + "/map.js") if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 64, Col: 63} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 56, Col: 63} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -127,7 +127,7 @@ func CreateRouteSegment(w *database.Workout) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Name")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 83, Col: 51} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 75, Col: 51} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -140,7 +140,7 @@ func CreateRouteSegment(w *database.Workout) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(w.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 89, Col: 24} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 81, Col: 24} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -153,7 +153,7 @@ func CreateRouteSegment(w *database.Workout) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Start")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 94, Col: 53} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 86, Col: 53} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -166,7 +166,7 @@ func CreateRouteSegment(w *database.Workout) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(helpers.A2S(len(w.Details().Points))) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 102, Col: 52} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 94, Col: 52} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -179,7 +179,7 @@ func CreateRouteSegment(w *database.Workout) templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "End")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 110, Col: 49} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 102, Col: 49} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -192,7 +192,7 @@ func CreateRouteSegment(w *database.Workout) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(helpers.A2S(len(w.Details().Points))) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 118, Col: 52} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 110, Col: 52} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -205,7 +205,7 @@ func CreateRouteSegment(w *database.Workout) templ.Component { var templ_7745c5c3_Var12 string templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(helpers.A2S(len(w.Details().Points))) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 119, Col: 54} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 111, Col: 54} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { @@ -218,7 +218,7 @@ func CreateRouteSegment(w *database.Workout) templ.Component { var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Distance")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 126, Col: 59} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 118, Col: 59} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { @@ -231,7 +231,7 @@ func CreateRouteSegment(w *database.Workout) templ.Component { var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Create route segment")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 137, Col: 47} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/create_route_segment.templ`, Line: 129, Col: 47} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { @@ -243,19 +243,11 @@ func CreateRouteSegment(w *database.Workout) templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{ - Scripts: []string{ - "/dist/leaflet.js", - "/route_segments.js", - "/dist/apexcharts.min.js", - "/dist/shareon.iife.js", - }, - Styles: []string{ - "/dist/leaflet.css", - "/dist/apexcharts.css", - "/dist/shareon.min.css", - }, - }).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page( + partials.NewPageOptions(). + WithSharing().WithCharts().WithMaps(). + WithScripts("/route_segments.js"), + ).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/workouts/edit.templ b/views/workouts/edit.templ index 956b2f87..b7f9b0ff 100644 --- a/views/workouts/edit.templ +++ b/views/workouts/edit.templ @@ -8,7 +8,7 @@ import ( ) templ Edit(w *database.Workout) { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) {

@helpers.IconFor(w.Type.String()) diff --git a/views/workouts/edit_templ.go b/views/workouts/edit_templ.go index a4c578ff..a75fe32a 100644 --- a/views/workouts/edit_templ.go +++ b/views/workouts/edit_templ.go @@ -225,7 +225,7 @@ func Edit(w *database.Workout) templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/workouts/list.templ b/views/workouts/list.templ index d03ac598..bbde3b71 100644 --- a/views/workouts/list.templ +++ b/views/workouts/list.templ @@ -9,7 +9,7 @@ import ( ) templ List(workouts []*database.Workout, filters *database.WorkoutFilters) { - @partials.Page(partials.PageOptions{}) { + @partials.Page(partials.NewPageOptions()) {

@helpers.IconFor(`workout`) diff --git a/views/workouts/list_templ.go b/views/workouts/list_templ.go index 613bdedd..c4dd7f17 100644 --- a/views/workouts/list_templ.go +++ b/views/workouts/list_templ.go @@ -572,7 +572,7 @@ func List(workouts []*database.Workout, filters *database.WorkoutFilters) templ. } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page(partials.NewPageOptions()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/workouts/show.templ b/views/workouts/show.templ index 0d336de4..4cfe45f8 100644 --- a/views/workouts/show.templ +++ b/views/workouts/show.templ @@ -8,19 +8,11 @@ import ( ) templ Show(w *database.Workout) { - @partials.Page(partials.PageOptions{ - Scripts: []string{ - "/dist/leaflet.js", - "/route_segments.js", - "/dist/apexcharts.min.js", - "/dist/shareon.iife.js", - }, - Styles: []string{ - "/dist/leaflet.css", - "/dist/apexcharts.css", - "/dist/shareon.min.css", - }, - }) { + @partials.Page( + partials.NewPageOptions(). + WithSharing().WithCharts().WithMaps(). + WithScripts("/route_segments.js"), + ) { {{ currentUser := helpers.CurrentUser(ctx) }}
if w.User.ID == currentUser.ID { diff --git a/views/workouts/show_templ.go b/views/workouts/show_templ.go index 23ac526b..b22f50df 100644 --- a/views/workouts/show_templ.go +++ b/views/workouts/show_templ.go @@ -70,7 +70,7 @@ func Show(w *database.Workout) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "refresh in progress")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/show.templ`, Line: 31, Col: 43} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/show.templ`, Line: 23, Col: 43} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -101,7 +101,7 @@ func Show(w *database.Workout) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(w.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/show.templ`, Line: 39, Col: 12} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/show.templ`, Line: 31, Col: 12} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -169,7 +169,7 @@ func Show(w *database.Workout) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Matching route segments")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/show.templ`, Line: 72, Col: 46} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/show.templ`, Line: 64, Col: 46} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -204,7 +204,7 @@ func Show(w *database.Workout) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Notes")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/show.templ`, Line: 85, Col: 28} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/show.templ`, Line: 77, Col: 28} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -239,7 +239,7 @@ func Show(w *database.Workout) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Average speed")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/show.templ`, Line: 98, Col: 36} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/show.templ`, Line: 90, Col: 36} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -256,7 +256,7 @@ func Show(w *database.Workout) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "Elevation")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/show.templ`, Line: 103, Col: 32} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/workouts/show.templ`, Line: 95, Col: 32} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -279,19 +279,11 @@ func Show(w *database.Workout) templ.Component { } return nil }) - templ_7745c5c3_Err = partials.Page(partials.PageOptions{ - Scripts: []string{ - "/dist/leaflet.js", - "/route_segments.js", - "/dist/apexcharts.min.js", - "/dist/shareon.iife.js", - }, - Styles: []string{ - "/dist/leaflet.css", - "/dist/apexcharts.css", - "/dist/shareon.min.css", - }, - }).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = partials.Page( + partials.NewPageOptions(). + WithSharing().WithCharts().WithMaps(). + WithScripts("/route_segments.js"), + ).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }