params

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2015 License: MIT Imports: 13 Imported by: 6

Documentation

Index

Constants

View Source
const (
	FS     int // 1
	MP         // 2
	AVAIL      // 3
	USEPCT     // 4
	USED       // 5
	TOTAL      // 6
)

Constants for DF sorting criterion.

View Source
const (
	PID  int // 1
	UID      // 2
	USER     // 3
	PRI      // 4
	NICE     // 5
	VIRT     // 6
	RES      // 7
	TIME     // 8
	NAME     // 9
)

Constants for PS sorting criterion.

Variables

View Source
var (
	NumType   = reflect.TypeOf(Num{})
	DelayType = reflect.TypeOf(Delay{})
)

Functions

func ContainsPrefix

func ContainsPrefix(words []string, prefix string) (string, bool)

func SprintfAttr

func SprintfAttr(format string, args ...interface{}) template.HTMLAttr

func TagsOk

func TagsOk(sf reflect.StructField) ([]string, bool)

Types

type ALink struct {
	Href       string
	Text       string
	Badge      string `json:"-"`
	Class      string `json:"-"`
	ExtraClass string `json:",omitempty"`
}

type Delay

type Delay struct {
	D       time.Duration
	Above   *time.Duration
	Below   *time.Duration
	Default time.Duration
	Ticks   int
}

Delay has it's own MarshalJSON.

func (Delay) EncodeValues

func (d Delay) EncodeValues(key string, values *url.Values) error

func (Delay) Expired

func (d Delay) Expired() bool

Expired satisfying receiver interface.

func (Delay) MarshalJSON

func (d Delay) MarshalJSON() ([]byte, error)

func (Delay) String

func (d Delay) String() string

func (*Delay) Tick

func (d *Delay) Tick()

func (*Delay) UnmarshalText

func (d *Delay) UnmarshalText(text []byte) error
type Dlinks struct {
	More, Less ALink
}
type Nlinks struct {
	More, Less ALink
}

type Num

type Num struct {
	Negative        bool
	Absolute        int
	DefaultNegative bool `json:"-"`
	DefaultAbsolute int  `json:"-"`
	Limit           int  `json:"-"`
	Alpha           bool `json:"-"`
	PositiveOnly    bool `json:"-"`
}

Num has no MarshalJSON.

func NumPrefix

func NumPrefix(words []string, prefix string) (Num, error)

func (Num) EncodeString

func (num Num) EncodeString() string

EncodeString returns string repr of Num. Templates render .Absolute value explicitly.

func (Num) EncodeValues

func (num Num) EncodeValues(key string, values *url.Values) error

func (*Num) UnmarshalText

func (num *Num) UnmarshalText(text []byte) error

type Params

type Params struct {
	Schema
	ParamsFuncs
	Defaults    map[interface{}]Num `json:"-"`
	Delays      map[string]*Delay   `json:"-"`
	DelayBounds flags.DelayBounds   `json:"-"`
}

func NewParams

func NewParams(dbounds flags.DelayBounds) *Params

NewParams constructs new Params.

func (*Params) Decode

func (p *Params) Decode(req *http.Request) error
func (p Params) Dlinks() map[string]Dlinks

func (Params) Encode

func (p Params) Encode() (string, error)

func (*Params) EncodeD

func (p *Params) EncodeD(d *Delay, set time.Duration) (string, error)

func (*Params) EncodeN

func (p *Params) EncodeN(num *Num, absolute int, setNegative *bool) (string, error)

func (*Params) EncodeT

func (p *Params) EncodeT(num *Num) (string, error)

func (Params) Expired

func (p Params) Expired() bool

Expired satisfying receiver interface.

func (*Params) MarshalJSON

func (p *Params) MarshalJSON() ([]byte, error)
func (p Params) Nlinks() map[string]Nlinks

func (Params) NonZeroPsn

func (p Params) NonZeroPsn() bool

func (*Params) ResetSchema

func (p *Params) ResetSchema()

func (*Params) SetDefaults

func (p *Params) SetDefaults(form url.Values)

func (*Params) Tick

func (p *Params) Tick()
func (p *Params) Tlinks() map[string]string
func (p *Params) Vlinks() map[string][]VLink

type ParamsFuncs

type ParamsFuncs struct{}

func (ParamsFuncs) DelayLess

func (f ParamsFuncs) DelayLess(d Delay, step time.Duration) time.Duration

func (ParamsFuncs) DelayMore

func (f ParamsFuncs) DelayMore(d Delay, step time.Duration) time.Duration

func (ParamsFuncs) HrefT

func (f ParamsFuncs) HrefT(p *Params, num *Num) (template.HTMLAttr, error)

func (ParamsFuncs) LessD

func (f ParamsFuncs) LessD(p *Params, d *Delay, bclass string) (ALink, error)

func (ParamsFuncs) LessN

func (f ParamsFuncs) LessN(p *Params, num *Num, bclass string) (ALink, error)

func (ParamsFuncs) LinkD

func (f ParamsFuncs) LinkD(p *Params, d *Delay, bclass string, set time.Duration, badge string) (ALink, error)

func (ParamsFuncs) LinkN

func (f ParamsFuncs) LinkN(p *Params, num *Num, bclass string, absolute int, badge string) (ALink, error)

func (ParamsFuncs) MoreD

func (f ParamsFuncs) MoreD(p *Params, d *Delay, bclass string) (ALink, error)

func (ParamsFuncs) MoreN

func (f ParamsFuncs) MoreN(p *Params, num *Num, bclass string) (ALink, error)

func (ParamsFuncs) Pow2Less

func (f ParamsFuncs) Pow2Less(v int) int

func (ParamsFuncs) Pow2More

func (f ParamsFuncs) Pow2More(v int) int
func (f ParamsFuncs) Vlink(p *Params, num *Num, absolute int, text string) (VLink, error)

type RenamedConstError

type RenamedConstError string

RenamedConstError denotes an error.

func (RenamedConstError) Error

func (rc RenamedConstError) Error() string

type Schema

type Schema struct {
	// Still is here to be preserved for url encoding.
	// Not in use by Go code, but by js.
	Still Num `url:"still,posonly,default0"`

	CPUd Delay `url:"cpud,omitempty"`
	Dfd  Delay `url:"dfd,omitempty"`
	Ifd  Delay `url:"ifd,omitempty"`
	Lad  Delay `url:"lad,omitempty"`
	Memd Delay `url:"memd,omitempty"`
	Psd  Delay `url:"psd,omitempty"`

	CPUn Num `url:"cpun,default-2"`
	Dfn  Num `url:"dfn,default-2"`
	Ifn  Num `url:"ifn,default-2"`
	Lan  Num `url:"lan,default-3"`
	Memn Num `url:"memn,default-2"`
	Psn  Num `url:"psn,default0"`

	Psk Num `url:"psk,default1,enumerate9"` // sort, default PID
	Dfk Num `url:"dfk,default1,enumerate6"` // sort, default FS
}
type VLink struct {
	CaretClass string
	LinkClass  string
	LinkHref   string
	LinkText   string `json:"-"` // static
}

Jump to

Keyboard shortcuts

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