diff --git a/go.mod b/go.mod index 8ea38edf..a6169970 100644 --- a/go.mod +++ b/go.mod @@ -9,11 +9,14 @@ require ( github.com/go-chi/chi/v5 v5.2.3 github.com/go-webauthn/webauthn v0.14.0 github.com/golang-jwt/jwt/v5 v5.3.0 + github.com/google/go-cmp v0.7.0 github.com/jackc/pgx/v5 v5.7.6 github.com/jaswdr/faker/v2 v2.8.1 github.com/lib/pq v1.10.9 github.com/pressly/goose/v3 v3.26.0 + github.com/riverqueue/river/rivershared v0.26.0 github.com/stephenafamo/bob v0.41.1 + github.com/stephenafamo/scan v0.7.0 github.com/wasilibs/go-pgquery v0.0.0-20250409022910-10ac41983c07 golang.org/x/crypto v0.42.0 ) @@ -31,7 +34,6 @@ require ( github.com/pganalyze/pg_query_go/v6 v6.1.0 // indirect github.com/qdm12/reprint v0.0.0-20200326205758-722754a53494 // indirect github.com/sethvargo/go-retry v0.3.0 // indirect - github.com/stephenafamo/scan v0.7.0 // indirect github.com/tetratelabs/wazero v1.9.0 // indirect github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 // indirect github.com/x448/float16 v0.8.4 // indirect diff --git a/go.sum b/go.sum index 6dae47a3..3d1b3e63 100644 --- a/go.sum +++ b/go.sum @@ -135,6 +135,8 @@ github.com/qdm12/reprint v0.0.0-20200326205758-722754a53494 h1:wSmWgpuccqS2IOfmY github.com/qdm12/reprint v0.0.0-20200326205758-722754a53494/go.mod h1:yipyliwI08eQ6XwDm1fEwKPdF/xdbkiHtrU+1Hg+vc4= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/riverqueue/river/rivershared v0.26.0 h1:tsMvxTIdG58GoYXd3788DwjNq87Y7CcfRlV7TAzeuhw= +github.com/riverqueue/river/rivershared v0.26.0/go.mod h1:/BEdbdGEqfcFP9FtChwK81e2AWF8e82RC6z5mwQ3y1g= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE= github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas= diff --git a/html.go b/html.go index 604228fe..56d38e30 100644 --- a/html.go +++ b/html.go @@ -5,16 +5,20 @@ import ( "fmt" "html/template" "io" + "log/slog" "os" + "strings" + "github.com/riverqueue/river/rivershared/util/slogutil" "github.com/Gleipnir-Technology/nidus-sync/models" ) var ( - dashboard = newBuiltTemplate("dashboard", "base") + dashboard = newBuiltTemplate("dashboard", "authenticated") signin = newBuiltTemplate("signin", "base") signup = newBuiltTemplate("signup", "base") ) +var components = [ ... ]string{"header"} type BuiltTemplate struct { files []string @@ -26,13 +30,17 @@ type Link struct { Title string } type ContentDashboard struct { - BabbleLinks []Link - Username string + User User } type ContentSignin struct { InvalidCredentials bool } type ContentSignup struct { } +type User struct { + DisplayName string + Initials string + Username string +} func (bt *BuiltTemplate) ExecuteTemplate(w io.Writer, data any) error { name := bt.files[0] + ".html" @@ -51,9 +59,26 @@ func (bt *BuiltTemplate) ExecuteTemplate(w io.Writer, data any) error { } } +func extractInitials(name string) string { + parts := strings.Fields(name) + var initials strings.Builder + + for _, part := range parts { + if len(part) > 0 { + initials.WriteString(strings.ToUpper(string(part[0]))) + } + } + + return initials.String() +} + func htmlDashboard(w io.Writer, user *models.User) error { data := ContentDashboard{ - Username: user.Username, + User: User{ + DisplayName: user.DisplayName, + Initials: extractInitials(user.DisplayName), + Username: user.Username, + }, } return dashboard.ExecuteTemplate(w, data) } @@ -108,6 +133,10 @@ func parseFromDisk(files []string) (*template.Template, error) { paths = append(paths, "templates/"+f+".html") } name := files[0] + ".html" + for _, f := range components { + paths = append(paths, "templates/components/"+f+".html") + } + slog.Info("Rendering templates from disk", slog.Any("paths", slogutil.SliceString(paths))) templ, err := template.New(name).Funcs(funcMap).ParseFiles(paths...) if err != nil { return nil, fmt.Errorf("Failed to parse %s: %v", paths, err) diff --git a/templates/authenticated.html b/templates/authenticated.html new file mode 100644 index 00000000..d898960f --- /dev/null +++ b/templates/authenticated.html @@ -0,0 +1,19 @@ + + +
+ + +At this point, pretend I'm showing you the result of some ArcGIS data.
+Link your data to get started
+To provide you with the best experience, we need to connect to your ArcGIS account. This allows us to securely access and visualize your spatial data within our platform.
+ +When you click the "Connect to ArcGIS" button below, you'll be redirected to the official ArcGIS login page. This connection is secure and uses OAuth 2.0 protocol.
+After logging in with your ArcGIS credentials, you'll be asked to approve permissions for our application to access your data. We only request access to what's needed for the platform to function.
+Once authentication is complete, you'll be automatically redirected back to our platform where your data will be available to work with.
+By connecting your ArcGIS account, you'll be able to:
+You can disconnect your account at any time in settings
+