diff --git a/app/githop.go b/app/githop.go index ae8cb28..6591396 100644 --- a/app/githop.go +++ b/app/githop.go @@ -185,7 +185,37 @@ func indexHandler(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusInternalServerError) return } - if err := templates["index"].Execute(w, nil); err != nil { + + oauthTransport := githubOAuthTransport(c) + oauthTransport.Token = &account.OAuthToken + githubClient := github.NewClient(oauthTransport.Client()) + + user, _, err := githubClient.Users.Get("") + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + repos, err := getRepos(c, githubClient, account, user) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + emailAddress, err := account.GetDigestEmailAddress(githubClient) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + var settingsSummary = map[string]interface{}{ + "Frequency": account.Frequency, + "RepositoryCount": strconv.Itoa(len(repos.AllRepos) - len(account.ExcludedRepoIds)), + "EmailAddress": emailAddress, + } + var data = map[string]interface{}{ + "SettingsSummary": settingsSummary, + } + if err := templates["index"].Execute(w, data); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } } diff --git a/app/templates/index.html b/app/templates/index.html index 5ecbba0..fa22e41 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -13,7 +13,12 @@
-- -Settings + +
+ You'll be getting a {{.SettingsSummary.Frequency}} digest of your past
+ past activity in {{.SettingsSummary.RepositoryCount}} repositories sent to
+ {{.SettingsSummary.EmailAddress}}.
+ Change settings
+
{{end}}