Add flash message when digest has been emailed.

This commit is contained in:
Mihai Parparita 2014-10-15 22:41:00 -07:00
parent 45364c385a
commit f0b15e7324
3 changed files with 28 additions and 0 deletions

View file

@ -229,10 +229,15 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
"RepositoryCount": repositoryCount,
"EmailAddress": emailAddress,
}
flashes := session.Flashes()
if len(flashes) > 0 {
session.Save(r, w)
}
var data = map[string]interface{}{
"User": user,
"SettingsSummary": settingsSummary,
"DetectTimezone": !account.HasTimezoneSet,
"Flashes": flashes,
}
if err := templates["index"].Execute(w, data); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
@ -281,6 +286,8 @@ func sendDigestHandler(w http.ResponseWriter, r *http.Request) {
return
}
session.AddFlash("Digest emailed!")
session.Save(r, w)
indexUrl, _ := router.Get("index").URL()
http.Redirect(w, r, indexUrl.String(), http.StatusFound)
}

View file

@ -85,3 +85,20 @@ input[type="submit"].destructive {
text-decoration: underline;
color: #900;
}
.flash {
position: absolute;
top: 20px;
right: 20px;
background: rgba(0, 0, 0, 0.75);
border-radius: 4px;
color: #fff;
font-size: 12pt;
padding: 10px;
transition: opacity ease-in-out 300ms;
opacity: 0;
}
.flash.visible {
opacity: 1;
}

View file

@ -2,6 +2,10 @@
{{define "body"}}
{{range .Flashes}}
{{template "flash" .}}
{{end}}
<p>
Signed in as
<a href="https://github.com/{{.User.Login}}"