From bc9427a2e02a5c58c87258761a4d15979f36f01c Mon Sep 17 00:00:00 2001 From: Mihai Parparita Date: Fri, 1 Aug 2014 23:00:21 -0700 Subject: [PATCH] Add basic CSS styling to digests. --- app/githop.go | 12 +++++++ app/static/digest.css | 71 +++++++++++++++++++++++++++++++++++++++ app/static/main.css | 5 --- app/templates/digest.html | 46 +++++++++++++------------ app/templates/index.html | 1 + 5 files changed, 109 insertions(+), 26 deletions(-) create mode 100644 app/static/digest.css diff --git a/app/githop.go b/app/githop.go index 1de5a91..9dbd6ef 100644 --- a/app/githop.go +++ b/app/githop.go @@ -165,9 +165,13 @@ func sendDigestForAccount(account *Account, c appengine.Context) error { } var digestHtml bytes.Buffer + digestHtml.WriteString("") if err := templates.ExecuteTemplate(&digestHtml, "digest", digest); err != nil { return err } + digestHtml.WriteString("") 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) diff --git a/app/static/digest.css b/app/static/digest.css new file mode 100644 index 0000000..ab6dfab --- /dev/null +++ b/app/static/digest.css @@ -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
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; +} diff --git a/app/static/main.css b/app/static/main.css index 740e844..7b78c98 100644 --- a/app/static/main.css +++ b/app/static/main.css @@ -1,8 +1,3 @@ -html, body { - margin: 0; - padding: 0; -} - body { font-family: Helvetica, Arial, sans-serif; font-size: 10pt; diff --git a/app/templates/digest.html b/app/templates/digest.html index 5a8636f..cc2df44 100644 --- a/app/templates/digest.html +++ b/app/templates/digest.html @@ -1,25 +1,29 @@ {{define "digest"}} -{{.User.Login}}'s digest: - +
+ +

Activity a year ago for {{.User.Login}}.

+ +{{range $index, $repoDigest := .RepoDigests}} +

+ + {{.Repo.FullName}} + +

+ +
+ {{range .Commits }} +
+
{{.Commit.Message}}
+
+ {{.SHA}} + {{.Commit.Author.Date}} +
+
+ {{end}} +
+{{end}} + +
{{end}} diff --git a/app/templates/index.html b/app/templates/index.html index 02e020c..c4440a5 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -6,6 +6,7 @@ GitHop +

GitHop!