josie / simplegit

package web

import (
	"net/http"
	"time"
)

// Shared limits, states, and literals for the web handlers, so issues.go,
// pulls.go, comments.go, and the settings pages share one home.
const (
	maxIssueBody = 64 << 10
	issueFormMax = 1 << 20
	maxTitleLen  = 300
	maxNameLen   = 100
	maxEmailLen  = 200

	guestThreadCap  = 10
	guestCommentCap = 60
	guestWindow     = time.Hour

	tokenLabelMax = 100

	maxDiffBytes        = 2 << 20
	diffTruncatedNotice = "Diff is larger than 2 MB; truncated."
	diffLexeme          = "x.diff"

	rawLimit = 16 << 20

	visibilityPublic  = "public"
	visibilityPrivate = "private"

	stateOpen   = "open"
	stateClosed = "closed"
	stateMerged = "merged"

	submittedParam = "submitted"
	honeypotField  = "website"
	showAll        = "all"
)

// submitted reports whether the ?submitted=1 confirmation flag is set.
func submitted(r *http.Request) bool {
	return r.URL.Query().Get(submittedParam) == "1"
}