Add basic CSS styling to digests.

This commit is contained in:
Mihai Parparita 2014-08-01 23:00:21 -07:00
parent 2635512896
commit bc9427a2e0
5 changed files with 109 additions and 26 deletions

View file

@ -165,9 +165,13 @@ func sendDigestForAccount(account *Account, c appengine.Context) error {
}
var digestHtml bytes.Buffer
digestHtml.WriteString("<html><head><style>")
digestHtml.Write(getDigestStyles())
digestHtml.WriteString("</style></head><body>")
if err := templates.ExecuteTemplate(&digestHtml, "digest", digest); err != nil {
return err
}
digestHtml.WriteString("</body></html>")
emails, _, err := githubClient.Users.ListEmails(nil)
if err != nil {
@ -195,6 +199,14 @@ func sendDigestForAccount(account *Account, c appengine.Context) error {
return err
}
func getDigestStyles() []byte {
b, err := ioutil.ReadFile("static/digest.css")
if err != nil {
log.Panicf("Could not read digest CSS: %s", err.Error())
}
return b
}
func githubOAuthCallbackHandler(w http.ResponseWriter, r *http.Request) {
code := r.FormValue("code")
c := appengine.NewContext(r)

71
app/static/digest.css Normal file
View file

@ -0,0 +1,71 @@
/* The strange format of these selectors is due to Gmail's limited CSS support
-- only tag names may be used. Therefore the entire digest is in a mostly-
harmless <dl> tag so that all selectors may be scoped. For more details, see:
http://codeascraft.com/2014/03/13/responsive-emails-that-really-work/ */
dl {
font-family: Helvetica, Arial, sans-serif;
font-size: 10pt;
color: #000;
max-width: 800px;
margin: 0;
}
dl a {
text-decoration: none;
color: #4183c4;
}
/* Digest intro paragraph */
dl > p {
font-size: 12pt;
}
/* User link */
dl > p > a {
font-weight: bold;
color: #000;
}
dl > p > a img {
vertical-align: bottom;
padding-right: 3px;
}
/* Repository header */
dl > h2 {
font-size: 20pt;
font-weight: bold;
margin: .75em 0 .5em 0;
}
/* Commit */
dl > div > div {
background: #fafafa;
border: solid 1px #ccc;
border-radius: 3px;
margin: 1em 0;
}
/* Commit message */
dl > div > div > pre {
margin: 0;
padding: 8px;
}
/* Commit footer */
dl > div > div > pre + div {
background: #fff;
border-top: solid 1px #ddd;
padding: 8px;
}
dl > div > div > pre + div > i {
color: #666;
}
dl > div > div > pre + div > a {
font-family: monospace;
float: right;
}

View file

@ -1,8 +1,3 @@
html, body {
margin: 0;
padding: 0;
}
body {
font-family: Helvetica, Arial, sans-serif;
font-size: 10pt;

View file

@ -1,25 +1,29 @@
{{define "digest"}}
{{.User.Login}}'s digest:
<ul>
{{range $index, $repoDigest := .RepoDigests}}
<li>
<a href="https://github.com/{{.Repo.FullName}}">
{{.Repo.FullName}}
</a>
<ul>
{{range .Commits }}
<li>
<code><a href="https://github.com/{{$repoDigest.Repo.FullName}}/commit/{{.SHA}}">{{.SHA}}</a></code>
-
<i>{{.Commit.Author.Date}}</i>
<br>
<pre>{{.Commit.Message}}</pre>
</li>
{{end}}
</ul>
</li>
{{end}}
</ul>
<dl>
<p>Activity a year ago for <a href="https://github.com/{{.User.Login}}" title={{.User.Name}}><img src={{.User.AvatarURL}} width="20" height="20" border="0">{{.User.Login}}</a>.</p>
{{range $index, $repoDigest := .RepoDigests}}
<h2>
<a href="https://github.com/{{.Repo.FullName}}">
{{.Repo.FullName}}
</a>
</h2>
<div>
{{range .Commits }}
<div>
<pre>{{.Commit.Message}}</pre>
<div>
<a href="https://github.com/{{$repoDigest.Repo.FullName}}/commit/{{.SHA}}">{{.SHA}}</a>
<i>{{.Commit.Author.Date}}</i>
</div>
</div>
{{end}}
</div>
{{end}}
</dl>
{{end}}

View file

@ -6,6 +6,7 @@
<meta charset="utf-8">
<title>GitHop</title>
<link rel="stylesheet" href="/static/main.css">
<link rel="stylesheet" href="/static/digest.css">
</head>
<body>
<h1>GitHop!</h1>