Documentation
¶
Overview ¶
Package changes is a web frontend for a change tracking service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BaseURIContextKey = &contextKey{"BaseURI"}
BaseURIContextKey is a context key for the request's base URI. That value specifies the base URI prefix to use for all absolute URLs. The associated value will be of type string.
var RepoSpecContextKey = &contextKey{"RepoSpec"}
RepoSpecContextKey is a context key for the request's repo spec. That value specifies which repo the changes are to be displayed for. The associated value will be of type string.
Functions ¶
func New ¶
New returns a changes app http.Handler using given services and options. If users is nil, then there is no way to have an authenticated user. Emojis image data is expected to be available at /emojis/emojis.png, unless opt.DisableReactions is true.
In order to serve HTTP requests, the returned http.Handler expects each incoming request to have 2 parameters provided to it via RepoSpecContextKey and BaseURIContextKey context keys. For example:
changesApp := changes.New(...) http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { req = req.WithContext(context.WithValue(req.Context(), changes.RepoSpecContextKey, string(...))) req = req.WithContext(context.WithValue(req.Context(), changes.BaseURIContextKey, string(...))) changesApp.ServeHTTP(w, req) })
An HTTP API must be available (currently, only EditComment endpoint is used):
// Register HTTP API endpoints. apiHandler := httphandler.Change{Change: service} http.Handle(httproute.EditComment, errorHandler(apiHandler.EditComment))
Types ¶
type Options ¶
type Options struct { // Notifications, if not nil, is used to highlight changes containing // unread notifications, and to mark changes that are viewed as read. Notifications notifications.Service DisableReactions bool // Disable all support for displaying and toggling reactions. HeadPre, HeadPost template.HTML BodyPre string // An html/template definition of "body-pre" template. // BodyTop provides components to include on top of <body> of page rendered for req. It can be nil. BodyTop func(*http.Request, common.State) ([]htmlg.Component, error) }
Options for configuring changes app.
Directories
¶
Path | Synopsis |
---|---|
Package assets contains assets for changes.
|
Package assets contains assets for changes. |
cmd
|
|
changesdev
changesdev is a sample program that serves changes.
|
changesdev is a sample program that serves changes. |
Package common contains common code for backend and frontend.
|
Package common contains common code for backend and frontend. |
Package component contains individual components that can render themselves as HTML.
|
Package component contains individual components that can render themselves as HTML. |
frontend script for changes.
|
frontend script for changes. |