~netlandish/gobwebs

126f0f16331b27018b4653e3c0e1e5a38252f650 — Peter Sanchez 10 months ago a51b316
Module rename
M accounts/confirm.go => accounts/confirm.go +2 -2
@@ 7,8 7,8 @@ import (
	"time"

	"github.com/segmentio/ksuid"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"hg.code.netlandish.com/~netlandish/gobwebs/database"
	"netlandish.com/x/gobwebs"
	"netlandish.com/x/gobwebs/database"
)

const (

M accounts/helpers.go => accounts/helpers.go +2 -2
@@ 4,8 4,8 @@ import (
	"context"
	"database/sql"

	"hg.code.netlandish.com/~netlandish/gobwebs"
	"hg.code.netlandish.com/~netlandish/gobwebs/database"
	"netlandish.com/x/gobwebs"
	"netlandish.com/x/gobwebs/database"
)

// UpdateLastLogin updates the last login time for a user

M accounts/input.go => accounts/input.go +4 -4
@@ 6,10 6,10 @@ import (
	"strings"

	"github.com/labstack/echo/v4"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"hg.code.netlandish.com/~netlandish/gobwebs/core"
	"hg.code.netlandish.com/~netlandish/gobwebs/server"
	"hg.code.netlandish.com/~netlandish/gobwebs/validate"
	"netlandish.com/x/gobwebs"
	"netlandish.com/x/gobwebs/core"
	"netlandish.com/x/gobwebs/server"
	"netlandish.com/x/gobwebs/validate"
)

// LoginForm ...

M accounts/routes.go => accounts/routes.go +6 -6
@@ 9,12 9,12 @@ import (
	"time"

	"github.com/labstack/echo/v4"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"hg.code.netlandish.com/~netlandish/gobwebs/auth"
	"hg.code.netlandish.com/~netlandish/gobwebs/database"
	"hg.code.netlandish.com/~netlandish/gobwebs/email"
	"hg.code.netlandish.com/~netlandish/gobwebs/server"
	"hg.code.netlandish.com/~netlandish/gobwebs/validate"
	"netlandish.com/x/gobwebs"
	"netlandish.com/x/gobwebs/auth"
	"netlandish.com/x/gobwebs/database"
	"netlandish.com/x/gobwebs/email"
	"netlandish.com/x/gobwebs/server"
	"netlandish.com/x/gobwebs/validate"
)

// Service is the base accounts service struct

M auth/helpers.go => auth/helpers.go +1 -1
@@ 4,7 4,7 @@ import (
	"strconv"

	"github.com/labstack/echo/v4"
	"hg.code.netlandish.com/~netlandish/gobwebs/server"
	"netlandish.com/x/gobwebs/server"
)

var userIDKey = "accounts.UserID"

M auth/middleware.go => auth/middleware.go +2 -2
@@ 8,8 8,8 @@ import (
	"strconv"

	"github.com/labstack/echo/v4"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"hg.code.netlandish.com/~netlandish/gobwebs/server"
	"netlandish.com/x/gobwebs"
	"netlandish.com/x/gobwebs/server"
)

var userCtxKey = &contextKey{"user"}

M cookies/cookies.go => cookies/cookies.go +1 -1
@@ 10,7 10,7 @@ import (
	"strings"

	"github.com/labstack/echo/v4"
	"hg.code.netlandish.com/~netlandish/gobwebs/crypto"
	"netlandish.com/x/gobwebs/crypto"
)

// Base code is heavily taken from this Alex Edwards article:

M core/local.go => core/local.go +2 -2
@@ 4,8 4,8 @@ import (
	"fmt"

	"github.com/labstack/echo/v4"
	"hg.code.netlandish.com/~netlandish/gobwebs/internal/localizer"
	"hg.code.netlandish.com/~netlandish/gobwebs/server"
	"netlandish.com/x/gobwebs/internal/localizer"
	"netlandish.com/x/gobwebs/server"
)

var sessionLanguage string = "_language"

M core/template.go => core/template.go +3 -3
@@ 2,9 2,9 @@ package core

import (
	"github.com/labstack/echo/v4"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"hg.code.netlandish.com/~netlandish/gobwebs/messages"
	"hg.code.netlandish.com/~netlandish/gobwebs/server"
	"netlandish.com/x/gobwebs"
	"netlandish.com/x/gobwebs/messages"
	"netlandish.com/x/gobwebs/server"
)

// AddContext will add the echo.Context into the template namespace

M email/email.go => email/email.go +2 -2
@@ 7,8 7,8 @@ import (

	work "git.sr.ht/~sircmpwn/dowork"
	"github.com/labstack/echo/v4"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"petersanchez.com/carrier"
	"netlandish.com/x/gobwebs"
	"petersanchez.com/x/carrier"
)

var emailCtxKey = &contextKey{"email"}

M email/helper.go => email/helper.go +2 -2
@@ 6,8 6,8 @@ import (
	"html/template"
	"io"

	"hg.code.netlandish.com/~netlandish/gobwebs"
	"petersanchez.com/carrier"
	"netlandish.com/x/gobwebs"
	"petersanchez.com/x/carrier"
)

// TMap is a template mapping map

M go.mod => go.mod +5 -4
@@ 1,4 1,4 @@
module hg.code.netlandish.com/~netlandish/gobwebs
module netlandish.com/x/gobwebs

go 1.20



@@ 18,16 18,17 @@ require (
	golang.org/x/crypto v0.14.0
	golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
	golang.org/x/text v0.13.0
	petersanchez.com/carrier v0.1.1
	petersanchez.com/x/carrier v0.2.0
)

require (
	github.com/ProtonMail/go-crypto v0.0.0-20220113124808-70ae35bab23f // indirect
	github.com/ProtonMail/go-crypto v0.0.0-20220930113650-c6815a8c17ad // indirect
	github.com/agnivade/levenshtein v1.1.1 // indirect
	github.com/beorn7/perks v1.0.1 // indirect
	github.com/cespare/xxhash/v2 v2.1.2 // indirect
	github.com/cloudflare/circl v1.2.0 // indirect
	github.com/dustin/go-humanize v1.0.0 // indirect
	github.com/emersion/go-message v0.15.0 // indirect
	github.com/emersion/go-message v0.16.0 // indirect
	github.com/emersion/go-pgpmail v0.2.0 // indirect
	github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594 // indirect
	github.com/go-playground/locales v0.14.1 // indirect

M go.sum => go.sum +15 -5
@@ 40,8 40,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
github.com/ProtonMail/go-crypto v0.0.0-20211112122917-428f8eabeeb3/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/ProtonMail/go-crypto v0.0.0-20220113124808-70ae35bab23f h1:J2FzIrXN82q5uyUraeJpLIm7U6PffRwje2ORho5yIik=
github.com/ProtonMail/go-crypto v0.0.0-20220113124808-70ae35bab23f/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/ProtonMail/go-crypto v0.0.0-20220930113650-c6815a8c17ad h1:QeeqI2zxxgZVe11UrYFXXx6gVxPVF40ygekjBzEg4XY=
github.com/ProtonMail/go-crypto v0.0.0-20220930113650-c6815a8c17ad/go.mod h1:UBYPn8k0D56RtnR8RFQMjmh4KrZzWJ5o7Z9SYjossQ8=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=


@@ 64,6 64,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/bwesterb/go-ristretto v1.2.1/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=


@@ 72,6 74,9 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
github.com/cloudflare/circl v1.2.0 h1:NheeISPSUcYftKlfrLuOo4T62FkmD4t4jviLfFFYaec=
github.com/cloudflare/circl v1.2.0/go.mod h1:Ch2UgYr6ti2KTtlejELlROl0YIYj7SLjAC8M+INXlMk=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=


@@ 80,8 85,9 @@ github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/emersion/go-message v0.15.0 h1:urgKGqt2JAc9NFJcgncQcohHdiYb803YTH9OQwHBHIY=
github.com/emersion/go-message v0.15.0/go.mod h1:wQUEfE+38+7EW8p8aZ96ptg6bAb1iwdgej19uXASlE4=
github.com/emersion/go-message v0.16.0 h1:uZLz8ClLv3V5fSFF/fFdW9jXjrZkXIpE1Fn8fKx7pO4=
github.com/emersion/go-message v0.16.0/go.mod h1:pDJDgf/xeUIF+eicT6B/hPX/ZbEorKkUMPOxrPVG2eQ=
github.com/emersion/go-pgpmail v0.2.0 h1:BU9kEGQcDVXi6n0v3JBsWAikyo63xsUGZ1lnVaWa6ks=
github.com/emersion/go-pgpmail v0.2.0/go.mod h1:8mQ8Rpn+w28DDaiP8HvJuZjSAymaWr87K3zA/bwwkU0=
github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594 h1:IbFBtwoTQyw0fIM5xv1HF+Y+3ZijDR839WMulgxCcUY=


@@ 325,8 331,10 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=


@@ 451,9 459,11 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=


@@ 621,8 631,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
petersanchez.com/carrier v0.1.1 h1:yZWQVPb0FRhgFAblyE5wFn4vNE5BhFAbt9G+QB/ov+Q=
petersanchez.com/carrier v0.1.1/go.mod h1:EUf2gWVEWQO75kBxDfJ5qOvGyIqd7G5IgkOrfr2QuuQ=
petersanchez.com/x/carrier v0.2.0 h1:9sPn8qzHM3BUIn0WTlulFuGLDjLhSglW1Bw4y5wmtf4=
petersanchez.com/x/carrier v0.2.0/go.mod h1:icdyLAZQvS5OLNmwpGtEqyLWR2XEzfezBnYpMS1t27g=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

M internal/localizer/localizer.go => internal/localizer/localizer.go +1 -1
@@ 5,7 5,7 @@ import (
	// is run. It's really important that we do this here so that the
	// default message catalog is updated to use our translations
	// *before* we initialize the message.Printer instances below.
	trans "hg.code.netlandish.com/~netlandish/gobwebs/internal/translations"
	trans "netlandish.com/x/gobwebs/internal/translations"

	"golang.org/x/text/language"
	"golang.org/x/text/message"

M internal/translations/translations.go => internal/translations/translations.go +1 -1
@@ 1,3 1,3 @@
package translations

//go:generate gotext -srclang=en update -out=catalog.go -lang=en,es hg.code.netlandish.com/~netlandish/gobwebs/accounts hg.code.netlandish.com/~netlandish/gobwebs/server
//go:generate gotext -srclang=en update -out=catalog.go -lang=en,es netlandish.com/x/gobwebs/accounts netlandish.com/x/gobwebs/server

M messages/messages.go => messages/messages.go +1 -1
@@ 5,7 5,7 @@ import (
	"sync"

	"github.com/labstack/echo/v4"
	"hg.code.netlandish.com/~netlandish/gobwebs/server"
	"netlandish.com/x/gobwebs/server"
)

// Shut up golint

M server/server.go => server/server.go +8 -8
@@ 31,14 31,14 @@ import (
	"github.com/labstack/echo/v4"
	"github.com/labstack/echo/v4/middleware"
	"golang.org/x/crypto/acme/autocert"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"hg.code.netlandish.com/~netlandish/gobwebs/config"
	"hg.code.netlandish.com/~netlandish/gobwebs/email"
	"hg.code.netlandish.com/~netlandish/gobwebs/internal/localizer"
	"hg.code.netlandish.com/~netlandish/gobwebs/sessions"
	"hg.code.netlandish.com/~netlandish/gobwebs/storage"
	"hg.code.netlandish.com/~netlandish/gobwebs/validate"
	"petersanchez.com/carrier"
	"netlandish.com/x/gobwebs"
	"netlandish.com/x/gobwebs/config"
	"netlandish.com/x/gobwebs/email"
	"netlandish.com/x/gobwebs/internal/localizer"
	"netlandish.com/x/gobwebs/sessions"
	"netlandish.com/x/gobwebs/storage"
	"netlandish.com/x/gobwebs/validate"
	"petersanchez.com/x/carrier"

	// Postgres
	_ "github.com/lib/pq"

M validate/template.go => validate/template.go +1 -1
@@ 8,7 8,7 @@ import (

	"github.com/labstack/echo/v4"
	"github.com/labstack/echo/v4/middleware"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"netlandish.com/x/gobwebs"

	// Postgres
	_ "github.com/lib/pq"

M validate/validate.go => validate/validate.go +2 -2
@@ 9,8 9,8 @@ import (

	"github.com/go-playground/validator/v10"
	"github.com/labstack/echo/v4"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"hg.code.netlandish.com/~netlandish/gobwebs/internal/localizer"
	"netlandish.com/x/gobwebs"
	"netlandish.com/x/gobwebs/internal/localizer"
)

// InputErrors map of many InputError's