-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/frontend: move base types to their own packages
This change moves serverError, basePage and errorPage out to different packages so that the fetch page logic can use them but be moved out of internal/frontend. For golang/go#61399 Change-Id: I72ccee40d1847d3211ca851a320530c4c1dcf2e2 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/517976 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Michael Matloob <[email protected]> kokoro-CI: kokoro <[email protected]> Reviewed-by: Robert Findley <[email protected]>
- Loading branch information
Showing
16 changed files
with
265 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2023 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// Package page defines common fields shared by pages when rendering templages. | ||
package page | ||
|
||
import ( | ||
"github.com/google/safehtml" | ||
"github.com/google/safehtml/template" | ||
"golang.org/x/pkgsite/internal/experiment" | ||
) | ||
|
||
// BasePage contains fields shared by all pages when rendering templates. | ||
type BasePage struct { | ||
// HTMLTitle is the value to use in the page’s <title> tag. | ||
HTMLTitle string | ||
|
||
// MetaDescription is the html used for rendering the <meta name="Description"> tag. | ||
MetaDescription safehtml.HTML | ||
|
||
// Query is the current search query (if applicable). | ||
Query string | ||
|
||
// Experiments contains the experiments currently active. | ||
Experiments *experiment.Set | ||
|
||
// DevMode indicates whether the server is running in development mode. | ||
DevMode bool | ||
|
||
// LocalMode indicates whether the server is running in local mode (i.e. ./cmd/pkgsite). | ||
LocalMode bool | ||
|
||
// AppVersionLabel contains the current version of the app. | ||
AppVersionLabel string | ||
|
||
// GoogleTagManagerID is the ID used to load Google Tag Manager. | ||
GoogleTagManagerID string | ||
|
||
// AllowWideContent indicates whether the content should be displayed in a | ||
// way that’s amenable to wider viewports. | ||
AllowWideContent bool | ||
|
||
// Enables the two and three column layouts on the unit page. | ||
UseResponsiveLayout bool | ||
|
||
// SearchPrompt is the prompt/placeholder for search input. | ||
SearchPrompt string | ||
|
||
// SearchMode is the search mode for the current search request. | ||
SearchMode string | ||
|
||
// SearchModePackage is the value of const searchModePackage. It is used in | ||
// the search bar dropdown. | ||
SearchModePackage string | ||
|
||
// SearchModeSymbol is the value of const searchModeSymbol. It is used in | ||
// the search bar dropdown. | ||
SearchModeSymbol string | ||
} | ||
|
||
func (p *BasePage) SetBasePage(bp BasePage) { | ||
bp.SearchMode = p.SearchMode | ||
*p = bp | ||
} | ||
|
||
// ErrorPage contains fields for rendering a HTTP error page. | ||
type ErrorPage struct { | ||
BasePage | ||
TemplateName string | ||
MessageTemplate template.TrustedTemplate | ||
MessageData any | ||
} |
Oops, something went wrong.