Skip to content

Commit

Permalink
switch to SVG website icon
Browse files Browse the repository at this point in the history
An SVG icon is better than PNG because it uses vector graphics. That
results in higher precision at different sizes. SVG can also support
dark mode via a prefers-color-scheme CSS query, whereas PNG cannot.

SVG icons were not widely supported by modern browsers earlier.
They are by now, so it has become viable to make the switch.

For #21.
  • Loading branch information
dmitshur committed Dec 27, 2020
1 parent d14a491 commit 7d656fd
Show file tree
Hide file tree
Showing 19 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion about.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
var aboutHTML = template.Must(template.New("").Parse(`<html>
<head>
{{.AnalyticsHTML}} <title>Dmitri Shuralyov - About</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
Expand Down
2 changes: 1 addition & 1 deletion action.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const newRepoHTML = `<!DOCTYPE html>
<html lang="en">
<head>
<title>Dmitri Shuralyov</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<style type="text/css">
Expand Down
2 changes: 1 addition & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (h *appHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) error {
var appHTML = template.Must(template.New("").Parse(`<!DOCTYPE html>
<html lang="en">
<head>
{{.AnalyticsHTML}} <link href="/icon.png" rel="icon" type="image/png">
{{.AnalyticsHTML}} <link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<style type="text/css">
Expand Down
4 changes: 2 additions & 2 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ var signInHTML = template.Must(template.New("").Parse(`<!DOCTYPE html>
<html lang="en">
<head>
<title>Dmitri Shuralyov - Sign In</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<style type="text/css">
Expand Down Expand Up @@ -851,7 +851,7 @@ var consentHTML = template.Must(template.New("").Funcs(template.FuncMap{
<html lang="en">
<head>
<title>Dmitri Shuralyov - Consent</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<style type="text/css">
Expand Down
4 changes: 2 additions & 2 deletions blog.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
var blogHTML = template.Must(template.New("").Parse(`<html>
<head>
{{.AnalyticsHTML}} <title>Dmitri Shuralyov - Blog</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<link href="/blog/assets/gfm/gfm.css" rel="stylesheet" type="text/css">
Expand All @@ -48,7 +48,7 @@ func initBlog(mux *http.ServeMux, issuesService issues.Service, blog issues.Repo
Notifications: v2tov1.Service{V2: notification},

HeadPre: analyticsHTML + `<title>Dmitri Shuralyov - Blog</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<style type="text/css">
Expand Down
4 changes: 2 additions & 2 deletions code_test.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type commitHandler struct {
var commitHTML = template.Must(template.New("").Parse(`<html>
<head>
{{.AnalyticsHTML}} <title>{{.FullName}} - Commit {{.Hash}}</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<link href="/assets/commit/style.css" rel="stylesheet" type="text/css">
Expand Down
2 changes: 1 addition & 1 deletion commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type commitsHandler struct {
var commitsHTML = template.Must(template.New("").Parse(`<html>
<head>
{{.AnalyticsHTML}} <title>{{.FullName}} - History</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<link href="/assets/commits/style.css" rel="stylesheet" type="text/css">
Expand Down
2 changes: 1 addition & 1 deletion idiomaticgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
var idiomaticGoHTML = template.Must(template.New("").Parse(`<html>
<head>
{{.AnalyticsHTML}} <title>Idiomatic Go</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<link href="/blog/assets/gfm/gfm.css" rel="stylesheet" type="text/css">
Expand Down
2 changes: 1 addition & 1 deletion index.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var indexHTML = template.Must(template.New("").Parse(`<!DOCTYPE html>
<html lang="en">
<head>
{{.AnalyticsHTML}} <title>Dmitri Shuralyov</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<link href="/assets/index/style.css" rel="stylesheet" type="text/css">
Expand Down
2 changes: 1 addition & 1 deletion issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func initIssuesV1(mux *http.ServeMux, issuesService issues.Service, notification
opt := issuesapp.Options{
Notifications: notifications,

HeadPre: analyticsHTML + `<link href="/icon.png" rel="icon" type="image/png">
HeadPre: analyticsHTML + `<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<style type="text/css">
Expand Down
9 changes: 4 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,11 @@ func run(ctx context.Context, cancel context.CancelFunc, storeDir, stateFile, an
})
}
if component.RedLogo {
http.HandleFunc("/icon.png", func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "image/png")
w.Header()["Content-Encoding"] = nil // Disable automatic gzip compression, png is already compressed.
err := serveFile(w, req, filepath.Join(os.Getenv("HOME"), "Dropbox", "Public", "dmitri", "icon-red.png"))
http.HandleFunc("/icon.svg", func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "image/svg+xml")
err := serveFile(w, req, filepath.Join(os.Getenv("HOME"), "Dropbox", "Public", "dmitri", "icon-red.svg"))
if err != nil {
log.Println(`serveFile("icon-red.png"):`, err)
log.Println(`serveFile("icon-red.svg"):`, err)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func initNotifications(
// Register notifications app endpoints.
opt := notificationsapp.Options{
HeadPre: analyticsHTML + `<title>Notifications</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<style type="text/css">
Expand Down
2 changes: 1 addition & 1 deletion package.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type packageHandler struct {
var packageHTML = template.Must(template.New("").Parse(`<html>
<head>
{{.AnalyticsHTML}} <title>{{.FullName}}</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<link href="/assets/package/style.css" rel="stylesheet" type="text/css">
Expand Down
2 changes: 1 addition & 1 deletion packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
var packagesHTML = template.Must(template.New("").Parse(`<html>
<head>
{{.AnalyticsHTML}} <title>Packages</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<link href="/assets/packages/style.css" rel="stylesheet" type="text/css">
Expand Down
2 changes: 1 addition & 1 deletion projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
var projectsHTML = template.Must(template.New("").Parse(`<html>
<head>
{{.AnalyticsHTML}} <title>Dmitri Shuralyov - Projects</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<link href="/assets/projects/style.css" rel="stylesheet" type="text/css">
Expand Down
2 changes: 1 addition & 1 deletion repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type repositoryHandler struct {
var repositoryHTML = template.Must(template.New("").Parse(`<html>
<head>
{{.AnalyticsHTML}} <title>Repository {{.Name}} - Packages</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<link href="/assets/repository/style.css" rel="stylesheet" type="text/css">
Expand Down
2 changes: 1 addition & 1 deletion resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
var resumeHTML = template.Must(template.New("").Funcs(template.FuncMap{"noescape": func(s string) template.HTML { return template.HTML(s) }}).Parse(`<html>
<head>
{{.AnalyticsHTML}} <title>Dmitri Shuralyov - Resume</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<link href="/assets/resume/style.css" rel="stylesheet" type="text/css">
Expand Down
2 changes: 1 addition & 1 deletion talks.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
var talksHTML = template.Must(template.New("").Parse(`<html>
<head>
{{.AnalyticsHTML}} <title>Dmitri Shuralyov - Talks</title>
<link href="/icon.png" rel="icon" type="image/png">
<link href="/icon.svg" rel="icon" type="image/svg+xml">
<meta name="viewport" content="width=device-width">
<link href="/assets/fonts/fonts.css" rel="stylesheet" type="text/css">
<link href="/assets/talks/style.css" rel="stylesheet" type="text/css">
Expand Down

0 comments on commit 7d656fd

Please sign in to comment.