GoPLS Viewer

Home|gopls/godoc/page.go
1// Copyright 2009 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package godoc
6
7import (
8    "net/http"
9    "os"
10    "path/filepath"
11    "runtime"
12)
13
14// Page describes the contents of the top-level godoc webpage.
15type Page struct {
16    Title    string
17    Tabtitle string
18    Subtitle string
19    SrcPath  string
20    Query    string
21    Body     []byte
22    TreeView bool // page needs to contain treeview related js and css
23
24    // filled in by ServePage
25    SearchBox       bool
26    Playground      bool
27    Version         string
28    GoogleAnalytics string
29}
30
31func (p *PresentationServePage(w http.ResponseWriterpage Page) {
32    if page.Tabtitle == "" {
33        page.Tabtitle = page.Title
34    }
35    page.SearchBox = p.Corpus.IndexEnabled
36    page.Playground = p.ShowPlayground
37    page.Version = runtime.Version()
38    page.GoogleAnalytics = p.GoogleAnalytics
39    applyTemplateToResponseWriter(wp.GodocHTMLpage)
40}
41
42func (p *PresentationServeError(w http.ResponseWriterr *http.Requestrelpath stringerr error) {
43    w.WriteHeader(http.StatusNotFound)
44    if perrok := err.(*os.PathError); ok {
45        relerr := filepath.Rel(runtime.GOROOT(), perr.Path)
46        if err != nil {
47            perr.Path = "REDACTED"
48        } else {
49            perr.Path = filepath.Join("$GOROOT"rel)
50        }
51    }
52    p.ServePage(wPage{
53        Title:           "File " + relpath,
54        Subtitle:        relpath,
55        Body:            applyTemplate(p.ErrorHTML"errorHTML"err),
56        GoogleAnalyticsp.GoogleAnalytics,
57    })
58}
59
MembersX
Page.Body
Presentation.ServeError.w
Page.Title
Page.Tabtitle
Page.SearchBox
Presentation.ServePage.p
Presentation.ServeError.p
Presentation.ServeError.relpath
Presentation.ServeError.r
http
Page
Page.Query
Page.TreeView
Page.Playground
Page.GoogleAnalytics
Presentation.ServePage.page
Presentation.ServeError.BlockStmt.rel
Presentation.ServeError.BlockStmt.err
Page.Subtitle
Page.SrcPath
Page.Version
Presentation.ServePage
Presentation.ServePage.w
Presentation.ServeError
Presentation.ServeError.err
Members
X