issuesapp: github.com/shurcooL/issuesapp Index | Files | Directories

package issuesapp

import "github.com/shurcooL/issuesapp"

Package issuesapp is a web frontend for an issues service.

Note, the canonical issue tracker for this package is currently hosted at https://dmitri.shuralyov.com/issues/github.com/shurcooL/issuesapp. It is implemented using this very package.

Index

Package Files

display.go doc.go main.go mock.go tabs.go

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 issues.RepoSpec. That value specifies which repo the issues are to be displayed for. The associated value will be of type issues.RepoSpec.

func New Uses

func New(service issues.Service, usersService users.Service, opt Options) http.Handler

New returns an issues app http.Handler using given services and options. If usersService 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:

issuesApp := issuesapp.New(...)

http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
	req = req.WithContext(context.WithValue(req.Context(), issuesapp.RepoSpecContextKey, issues.RepoSpec{...}))
	req = req.WithContext(context.WithValue(req.Context(), issuesapp.BaseURIContextKey, string(...)))
	issuesApp.ServeHTTP(w, req)
})

An HTTP API must be available (currently, only EditComment endpoint is used for reacting):

// Register HTTP API endpoints.
apiHandler := httphandler.Issues{Issues: service}
http.Handle(httproute.List, errorHandler(apiHandler.List))
http.Handle(httproute.Count, errorHandler(apiHandler.Count))
http.Handle(httproute.ListComments, errorHandler(apiHandler.ListComments))
http.Handle(httproute.ListEvents, errorHandler(apiHandler.ListEvents))
http.Handle(httproute.EditComment, errorHandler(apiHandler.EditComment))

type Options Uses

type Options struct {
    Notifications    notifications.Service // If not nil, issues containing unread notifications are highlighted.
    DisableReactions bool                  // Disable all support for displaying and toggling reactions.

    HeadPre 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(req *http.Request) ([]htmlg.Component, error)
}

Options for configuring issues app.

Directories

PathSynopsis
assetsPackage assets contains assets for issuesapp.
commonPackage common contains common code for backend and frontend.
componentPackage component contains individual components that can render themselves as HTML.
httpclientPackage httpclient contains issues.Service implementation over HTTP.
httphandlerPackage httphandler contains an API handler for issues.Service.
httproutePackage httproute contains route paths for httpclient, httphandler.

Package issuesapp imports 31 packages (graph) and is imported by 2 packages. Updated 2017-07-10. Refresh now. Tools for package owners.