Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackgroundTiles ¶
Types ¶
type Config ¶
type Config struct { APIURLExternal string `toml:"api_url_external"` APIURLInternal string `toml:"api_url_internal"` APISocketPath string `toml:"api_socket_path"` SessionCookieDomain string `toml:"session_cookie_domain"` ResourceDir string `toml:"resource_dir"` DebugMode bool `toml:"debug_mode"` ProxyAPIRequests bool `toml:"proxy_api_requests"` MaintenanceMode bool `toml:"maintenance_mode"` }
type ExtraActions ¶
type ExtraActions struct { // Redirects the browser to a different URL with a HTTP 303: See Other // status. This is useful for redirecting the user to a different page if // the form submission was successful RedirectTo string // A cookie to install in the browser when the form is rendered. Useful for // setting / destroying user sessions or configurations SetCookie *http.Cookie }
ExtraActions contains extra actions to performs when rendering the form
type Field ¶
type Field struct { // Used for reading the data. Entered data is POSTed back to the same URL with this name Name string // Is entered in the input field by default. If this is empty when running // Form.ReadInput() it will be set to the value entered by the user DefaultValue string // The value entered by the user. Filled in when running Form.ReadInput() EnteredValue string // Text next to the input field Label string // Text below the input field Description template.HTML Type FieldType // Only used when Type == FieldTypeCaptcha CaptchaSiteKey string // Only used when Type == FieldTypeRadio RadioValues []string }
Field is a single input field in a form
type FieldType ¶
type FieldType string
FieldType defines the type a form field has and how it should be rendered
const ( FieldTypeText FieldType = "text" FieldTypeTextarea FieldType = "textarea" FieldTypeNumber FieldType = "number" FieldTypeUsername FieldType = "username" FieldTypeEmail FieldType = "email" FieldTypeRadio FieldType = "radio" FieldTypeCurrentPassword FieldType = "current-password" FieldTypeNewPassword FieldType = "new-password" FieldTypeCaptcha FieldType = "captcha" FieldTypeDescription FieldType = "description" )
Fields which can be in a form
type Form ¶
type Form struct { // Name of the form. When this form is submitted this name will be in the `form` parameter Name string Title string // Shown in a large font above the form PreFormHTML template.HTML // Content to be rendered above the form Fields []Field SubmitLabel string // Label for the submit button SubmitRed bool // If the submit button should be red or green PostFormHTML template.HTML // Content to be rendered below the form // Fields to render if the form has been submitted once Submitted bool // If the form has been submitted SubmitSuccess bool // If the submission was a success SubmitMessages []template.HTML // Messages telling the user the results // Used for letting the browser know which user is logged in Username string // Actions to perform when the form is rendered Extra ExtraActions }
Form is a form which can be rendered in HTML and submitted
type Gradient ¶
func NewGradient ¶
type HSL ¶
HSL color
type TemplateData ¶
type TemplateData struct { Authenticated bool User pixelapi.UserInfo UserAgent string APIEndpoint template.URL PixelAPI pixelapi.PixelAPI Hostname template.HTML // Only used on file viewer page Title string OGData ogData Other interface{} URLQuery url.Values // Only used for pages containing forms Form Form // contains filtered or unexported fields }
TemplateData is a struct that every template expects when being rendered. In the field Other you can pass your own template-specific variables.
type TemplateManager ¶
type TemplateManager struct {
// contains filtered or unexported fields
}
TemplateManager parses templates and provides utility functions to the templates' scripting language
func NewTemplateManager ¶
func NewTemplateManager(resourceDir, externalAPIEndpoint string, debugMode bool) *TemplateManager
NewTemplateManager creates a new template manager
func (*TemplateManager) ParseTemplates ¶
func (tm *TemplateManager) ParseTemplates(silent bool)
ParseTemplates parses the templates in the template directory which is defined in the config file. If silent is false it will print an info log message for every template found
type WebController ¶
type WebController struct {
// contains filtered or unexported fields
}
WebController controls how requests are handled and makes sure they have proper context when running
func New ¶
func New(r *httprouter.Router, prefix string, conf Config) (wc *WebController)
New initializes a new WebController by registering all the request handlers and parsing all templates in the resource directory