server

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2023 License: GPL-3.0 Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package server serves a web interface for interacting with dotfiles stored in a database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config Config) (*http.Server, error)

New returns a dotfilehub web server.

Types

type Config

type Config struct {
	Addr           string      // Address to listen at.
	DBPath         string      // The path to store the sqlite database file.
	Secure         bool        // Tell the server code that the host is using https.
	ProxyHeaders   bool        // Sets request IP from reverse proxy headers.
	Host           string      // Overrides http.Request.Host when not empty.
	SMTP           *SMTPConfig // Sets up a SMTP Client
	SMTPConfigPath string      // Sets SMTP from this file's JSON when not empty.
}

Config configures the server.

func (Config) URL

func (c Config) URL(r *http.Request) string

URL returns the configured url. If c.Host is not set it will use the requests host header.

type Link struct {
	URL    string
	Title  string
	Active bool
}

Link populates a navbar link.

func (*Link) Class

func (l *Link) Class() string

Class returns a class name for active styling.

type Page

type Page struct {
	Title          string
	SuccessMessage string
	ErrorMessage   string
	Links          []Link
	Vars           map[string]string
	Data           map[string]interface{}

	Table   *db.HTMLTable
	Session *db.UserSession
	// contains filtered or unexported fields
}

Page renders pages and tracks request state. Exported fields/methods may be used within templates.

func (*Page) CLIToken

func (p *Page) CLIToken() string

CLIToken returns the logged in user's CLI token.

func (*Page) Dark

func (p *Page) Dark() bool

Dark returns whether dark mode is turned on.

func (*Page) Email

func (p *Page) Email() string

Email returns the logged in user's email.

func (*Page) Owned

func (p *Page) Owned() bool

Owned returns whether the logged in user owns the page. Pages without the {username} var are owned by every user.

func (*Page) Theme

func (p *Page) Theme() db.UserTheme

Theme returns the logged in user's theme.

func (*Page) Timezone

func (p *Page) Timezone() *string

Timezone returns the logged in user's timezone.

func (*Page) UserCreatedAt

func (p *Page) UserCreatedAt() string

UserCreatedAt returns the logged in user's creation date.

func (*Page) Username

func (p *Page) Username() string

Username returns the logged in user's username.

type SMTPConfig

type SMTPConfig struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Username string `json:"username"`
	Password string `json:"password"`
	Sender   string `json:"sender"`
}

SMTPConfig configures a SMTP client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL