Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added viewport tag to make all html pages mobile-friendly #334

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions html/core/footer_row.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package core

import "io"
import "time"

// FooterRow appears on all pages at the bottom.
type FooterRow struct{}
Expand All @@ -15,9 +16,13 @@ func (c *FooterRow) WriteHTMLTo(w io.Writer) (int64, error) {
"https://github.com/elliotchance/gedcom",
)

curTime := time.Now()
layout := "Jan 2, 2006, 3.04 pm"
content := NewComponents(
NewText("Generated with "),
link,
NewText(" on "),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're going to add this, it needs to be off by default (enabled through a CLI flag) otherwise the output is not deterministic for source control and other syncing.

Also, please run go fmt to fix up the indenting.

NewText(curTime.Format(layout)),
)

return NewComponents(
Expand Down
4 changes: 3 additions & 1 deletion html/core/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ func (c *Page) WriteHTMLTo(w io.Writer) (int64, error) {
footer := NewFooterRow()
title := NewTag("title", nil, NewText(c.title))

n := appendString(w, `<html><head><meta charset="UTF-8">`)
// make all html files mobile friendly
n := appendString(w, `<html><head><meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1">`)

n += appendComponent(w, googleAnalytics)
n += appendComponent(w, title)
n += appendString(w, `<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet">
Expand Down