mirror of https://github.com/golang/go.git
net/http: make FileServer look good on mobile
Currently when viewing directories on a phone, the text is small and often hard to tap correctly. This commit adds the viewport property to the page to make it look correct on phones. This commit also makes the page behave in Standards Mode instead of Quirks Mode which does not effect the behavior of this page but makes me feel good inside ☺️ Change-Id: I4babcf79085e85fba57453b7a235e4750a269a42 Reviewed-on: https://go-review.googlesource.com/c/go/+/552595 Auto-Submit: Ian Lance Taylor <iant@golang.org> Commit-Queue: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Max Coplan <mchcopl@gmail.com>
This commit is contained in:
parent
ef84d62cfc
commit
e0fc269f77
|
|
@ -151,6 +151,8 @@ func dirList(w ResponseWriter, r *Request, f File) {
|
|||
sort.Slice(dirs, func(i, j int) bool { return dirs.name(i) < dirs.name(j) })
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
fmt.Fprintf(w, "<!doctype html>\n")
|
||||
fmt.Fprintf(w, "<meta name=\"viewport\" content=\"width=device-width\">\n")
|
||||
fmt.Fprintf(w, "<pre>\n")
|
||||
for i, n := 0, dirs.len(); i < n; i++ {
|
||||
name := dirs.name(i)
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ func TestFileServerCleans(t *testing.T) {
|
|||
|
||||
func TestFileServerEscapesNames(t *testing.T) { run(t, testFileServerEscapesNames) }
|
||||
func testFileServerEscapesNames(t *testing.T, mode testMode) {
|
||||
const dirListPrefix = "<pre>\n"
|
||||
const dirListPrefix = "<!doctype html>\n<meta name=\"viewport\" content=\"width=device-width\">\n<pre>\n"
|
||||
const dirListSuffix = "\n</pre>\n"
|
||||
tests := []struct {
|
||||
name, escaped string
|
||||
|
|
|
|||
Loading…
Reference in New Issue