Skip to content

Commit 53c676d

Browse files
committed
_content: create explicit lib/godoc tree
For historical reasons, files in _content/, like _content/play.js, were served as https://golang.org/lib/godoc/play.js. Remove some complex setup by moving them to names that match the actual serving location, such as _content/lib/godoc/play.js. Change-Id: Ib92c3db7566b24da40e803781aca590f6bc22c8b Reviewed-on: https://go-review.googlesource.com/c/website/+/293414 Trust: Russ Cox <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 66996d0 commit 53c676d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+6
-18
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

cmd/golangorg/local.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func earlySetup() {
2727
os.Exit(2)
2828
}
2929
dir := filepath.Join(file, "../../../_content")
30-
if _, err := os.Stat(filepath.Join(dir, "godoc.html")); err != nil {
30+
if _, err := os.Stat(filepath.Join(dir, "lib/godoc/godoc.html")); err != nil {
3131
log.Printf("warning: cannot find template dir; using embedded copy")
3232
return
3333
}

cmd/golangorg/main.go

+3-11
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"log"
2727
"net/http"
2828
"os"
29-
"path/filepath"
3029
"regexp"
3130
"runtime"
3231

@@ -84,21 +83,14 @@ func main() {
8483
rootfs := gatefs.New(vfs.OS(*goroot), fsGate)
8584
fs.Bind("/", rootfs, "/", vfs.BindReplace)
8685

87-
// Try serving files in /doc from a local copy before trying the main
86+
// Try serving files from _content before trying the main
8887
// go repository. This lets us update some documentation outside the
8988
// Go release cycle. This includes root.html, which redirects to "/".
9089
// See golang.org/issue/29206.
9190
if *templateDir != "" {
92-
fs.Bind("/doc", vfs.OS(*templateDir), "/doc", vfs.BindBefore)
93-
fs.Bind("/lib/godoc", vfs.OS(*templateDir), "/", vfs.BindBefore)
94-
root := filepath.Join(*templateDir, "..")
95-
fs.Bind("/robots.txt", vfs.OS(root), "/robots.txt", vfs.BindBefore)
96-
fs.Bind("/favicon.ico", vfs.OS(root), "/favicon.ico", vfs.BindBefore)
91+
fs.Bind("/", vfs.OS(*templateDir), "/", vfs.BindBefore)
9792
} else {
98-
fs.Bind("/doc", vfs.FromFS(website.Content), "/doc", vfs.BindBefore)
99-
fs.Bind("/lib/godoc", vfs.FromFS(website.Content), "/", vfs.BindReplace)
100-
fs.Bind("/robots.txt", vfs.FromFS(website.Root), "/robots.txt", vfs.BindBefore)
101-
fs.Bind("/favicon.ico", vfs.FromFS(website.Root), "/favicon.ico", vfs.BindBefore)
93+
fs.Bind("/", vfs.FromFS(website.Content), "/", vfs.BindBefore)
10294
}
10395

10496
corpus := godoc.NewCorpus(fs)

cmd/golangorg/release_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build go1.16
56
// +build go1.16
67

78
package main
@@ -27,8 +28,7 @@ func TestReleaseHistory(t *testing.T) {
2728
origFS, origPres := fs, pres
2829
defer func() { fs, pres = origFS, origPres }()
2930
fs = vfs.NameSpace{}
30-
fs.Bind("/doc", vfs.FromFS(website.Content), "/doc", vfs.BindBefore)
31-
fs.Bind("/lib/godoc", vfs.FromFS(website.Content), "/", vfs.BindReplace)
31+
fs.Bind("/", vfs.FromFS(website.Content), "/", vfs.BindReplace)
3232
pres = godoc.NewPresentation(godoc.NewCorpus(fs))
3333
readTemplates(pres)
3434
mux := registerHandlers(pres)

content.go

-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,3 @@ func subdir(fsys fs.FS, path string) fs.FS {
2626
}
2727
return s
2828
}
29-
30-
// Root is the website root files: favicon.ico and robots.txt.
31-
//go:embed favicon.ico robots.txt
32-
var Root embed.FS

0 commit comments

Comments
 (0)