mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-04-27 15:07:43 +00:00
Add summary of settings to the index page.
This commit is contained in:
parent
976beb08cc
commit
7405cb5651
2 changed files with 38 additions and 3 deletions
|
|
@ -185,7 +185,37 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
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)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,12 @@
|
||||||
<form id="send-form" method="POST" action="{{routeUrl "send-digest"}}">
|
<form id="send-form" method="POST" action="{{routeUrl "send-digest"}}">
|
||||||
<input type="submit" value="Email Digest">
|
<input type="submit" value="Email Digest">
|
||||||
</form>
|
</form>
|
||||||
-
|
|
||||||
<a href="{{routeUrl "settings"}}">Settings</a>
|
<p>
|
||||||
|
You'll be getting a {{.SettingsSummary.Frequency}} digest of your past
|
||||||
|
past activity in {{.SettingsSummary.RepositoryCount}} repositories sent to
|
||||||
|
<code>{{.SettingsSummary.EmailAddress}}</code>.
|
||||||
|
<a href="{{routeUrl "settings"}}">Change settings</a>
|
||||||
|
<p>
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue