Documentation ¶
Index ¶
- Constants
- Variables
- func AnnotationOrdinal(dbh *sql.DB, pasteId int64) (int, error)
- func InsertPaste(dbh *sql.DB, paste *Paste) (int64, error)
- type ActionFunc
- type AnyMap
- type BrowseOpts
- type Config
- type HttpError
- type LineNumber
- type Paste
- func (p Paste) AuthorDef() string
- func (p Paste) ChannelDef() string
- func (p Paste) CreatedDisplay() string
- func (p Paste) CreatedRel() string
- func (p Paste) CreatedTime() time.Time
- func (p Paste) LanguageDef() string
- func (p Paste) LineNumbers() (ns []LineNumber)
- func (p Paste) ReplyTitle() string
- func (p Paste) RootId() int64
- func (p Paste) TitleDef() string
- type PasteData
- type PastePage
- type PasteView
- type Query
- type Server
Constants ¶
const ( DefaultDriver = "sqlite3" DefaultDatabase = "gopaste.sqlite" DefaultPort = 80 )
const ( InvalidPasteId = -1 TimeFormat = "2006-01-02 15:04:05 -07:00" )
Variables ¶
var LanguageNames = map[string]string{}/* 110 elements not displayed */
LanguageNames maps language identifers to the human-readable names of the languages supported by highlightjs.
var LanguageNamesSorted = []languageName{}
LanguageNamesSorted is a list of known languages, sorted by name.
Functions ¶
func AnnotationOrdinal ¶
AnnotationOrdinal returns N such that the paste is the Nth annotation of its parent.
Types ¶
type ActionFunc ¶
type BrowseOpts ¶
func NewBrowseOpts ¶
func NewBrowseOpts() *BrowseOpts
func (*BrowseOpts) NewPage ¶
func (o *BrowseOpts) NewPage(page int) *BrowseOpts
func (*BrowseOpts) Next ¶
func (o *BrowseOpts) Next() *BrowseOpts
func (*BrowseOpts) Parse ¶
func (o *BrowseOpts) Parse(args []string) error
func (*BrowseOpts) Prev ¶
func (o *BrowseOpts) Prev() *BrowseOpts
func (*BrowseOpts) String ¶
func (o *BrowseOpts) String() string
type Config ¶
type Config struct { DbDriver string DbSource string Port uint ExternalHost string HubotHost string }
func ParseConfig ¶
func ParseConfig() *Config
ParseConfig creates a new Config object by reading the command-line arguments.
type LineNumber ¶
type Paste ¶
type Paste struct { Id int64 `sql:"id"` Title sql.NullString `sql:"title"` Content string `sql:"content"` Author sql.NullString `sql:"author"` Language sql.NullString `sql:"language"` Channel sql.NullString `sql:"channel"` Annotates sql.NullInt64 `sql:"annotates"` Private bool `sql:"private"` Created int64 `sql:"created"` AnnotationNum int `sql:"-"` }
Paste represents an individual paste.
func GetAnnotations ¶
GetAnnotations fetches all annotations of the paste with the given ID.
func (Paste) ChannelDef ¶
ChannelDef returns the paste channel if set, or the empty string otherwise.
func (Paste) CreatedDisplay ¶
CreatedDisplay returns the paste creation date in a human-readable format.
func (Paste) CreatedRel ¶
CreatedRel returns a string describing how long ago the paste was created, in a human-friendly format (e.g. "3 days ago").
func (Paste) CreatedTime ¶
CreatedTime returns the paste's creation time as a time.Time object.
func (Paste) LanguageDef ¶
LanguageDef returns the full name of the paste language if set, or "plain text" otherwise.
func (Paste) LineNumbers ¶
func (p Paste) LineNumbers() (ns []LineNumber)
LineNumbers returns a list of LineNumber objects for a paste.
func (Paste) ReplyTitle ¶
ReplyTitle returns the paste title prefixed with "Re:" if it doesn't already begin that way.
type PasteData ¶
PasteData represents a paste and all of its annotations.
func GetPasteData ¶
GetPasteData fetches a paste and its annotations from the given paste ID.
func (PasteData) AnnotationsView ¶
type PastePage ¶
func TopLevelPastes ¶
func TopLevelPastes(dbh *sql.DB, opts *BrowseOpts) (*PastePage, error)
TopLevelPastes fetches the paste IDs for all pastes which are not private or annotations