types

package
v0.0.0-...-7609c90 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TwtHashLength = 7
)

Variables

View Source
var (
	ErrNotImplemented = errors.New("not implemented")
	ErrInvalidFeed    = errors.New("error: erroneous feed detected")
)
View Source
var NilTwt = nilTwt{}

Functions

func NormalizeUsername

func NormalizeUsername(username string) string

func SetTwtManager

func SetTwtManager(m TwtManager)

func SplitTwts

func SplitTwts(twts Twts, ttl time.Duration, N int) (Twts, Twts)

SplitTwts into two groupings. The first with created > ttl or at most N. the second all remaining twts.

Types

type Alternative

type Alternative struct {
	Type  string
	Title string
	URL   string
}

type Alternatives

type Alternatives []Alternative

type AuthRequest

type AuthRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

AuthRequest ...

func NewAuthRequest

func NewAuthRequest(r io.Reader) (req AuthRequest, err error)

NewAuthRequest ...

type AuthResponse

type AuthResponse struct {
	Token string `json:"token"`
}

AuthResponse ...

func (AuthResponse) Bytes

func (res AuthResponse) Bytes() ([]byte, error)

Bytes ...

type ConversationRequest

type ConversationRequest struct {
	Hash string `json:"hash"`
	Page int    `json:"page"`
}

ConversationRequest ...

func NewConversationRequest

func NewConversationRequest(r io.Reader) (req ConversationRequest, err error)

NewConversationRequest ...

type ExternalProfileRequest

type ExternalProfileRequest struct {
	URL  string `json:"url"`
	Nick string `json:"nick"`
}

ExternalProfileRequest ...

func NewExternalProfileRequest

func NewExternalProfileRequest(r io.Reader) (req ExternalProfileRequest, err error)

NewExternalProfileRequest ...

type Feed

type Feed struct {
	Nick string
	URL  string
}

Feed is an single twtxt.txt feed with a cannonical Nickname and URL for the feed

func (Feed) String

func (f Feed) String() string

String implements the Stringer interface and returns the Feed represented as a twtxt.txt URI in the form @<nick url>

type FeedLookup

type FeedLookup interface {
	FeedLookup(string) *Twter
}

type FeedLookupFn

type FeedLookupFn func(string) *Twter

func (FeedLookupFn) FeedLookup

func (fn FeedLookupFn) FeedLookup(s string) *Twter

type Feeds

type Feeds map[Feed]bool

Feeds is a mappping of Feed to booleans used to ensure unique feeds

type FetchTwtsRequest

type FetchTwtsRequest struct {
	URL  string `json:"url"`
	Nick string `json:"nick"`
	Page int    `json:"page"`
}

FetchTwtsRequest ...

func NewFetchTwtsRequest

func NewFetchTwtsRequest(r io.Reader) (req FetchTwtsRequest, err error)

NewFetchTwtsRequest ...

type FmtOpts

type FmtOpts interface {
	LocalURL() *url.URL
	IsLocalURL(string) bool
	UserURL(string) string
	ExternalURL(nick, uri string) string
	URLForTag(tag string) string
	URLForUser(user string) string
}

type FollowRequest

type FollowRequest struct {
	Nick string `json:"nick"`
	URL  string `json:"url"`
}

FollowRequest ...

func NewFollowRequest

func NewFollowRequest(r io.Reader) (req FollowRequest, err error)

NewFollowRequest ...

type Info

type Info interface {
	Followers() []Twter

	KV
}

type KV

type KV interface {
	GetN(string, int) (Value, bool)
	GetAll(string) []Value
	fmt.Stringer
}
type Link struct {
	Href string
	Rel  string
}
type LinkList []TwtLink
func (l LinkList) Links() []string
type Links []Link

type MentionList

type MentionList []TwtMention

func (MentionList) Mentions

func (ml MentionList) Mentions() []string

type MuteRequest

type MuteRequest struct {
	Nick string `json:"nick"`
	URL  string `json:"url"`
}

MuteRequest ...

func NewMuteRequest

func NewMuteRequest(r io.Reader) (req MuteRequest, err error)

NewMuteRequest ...

type PagedRequest

type PagedRequest struct {
	Page int `json:"page"`
}

PagedRequest ...

func NewPagedRequest

func NewPagedRequest(r io.Reader) (req PagedRequest, err error)

NewPagedRequest ...

type PagedResponse

type PagedResponse struct {
	Twts  Twts `json:"twts"`
	Pager PagerResponse
}

PagedResponse ...

func (PagedResponse) Bytes

func (res PagedResponse) Bytes() ([]byte, error)

Bytes ...

type PagerResponse

type PagerResponse struct {
	Current   int `json:"current_page"`
	MaxPages  int `json:"max_pages"`
	TotalTwts int `json:"total_twts"`
}

PagerResponse ...

type PostRequest

type PostRequest struct {
	PostAs string `json:"post_as"`
	Text   string `json:"text"`
}

PostRequest ...

func NewPostRequest

func NewPostRequest(r io.Reader) (req PostRequest, err error)

NewPostRequest ...

type PreambleFeed

type PreambleFeed struct {
	// contains filtered or unexported fields
}

func ReadPreambleFeed

func ReadPreambleFeed(r io.Reader) (*PreambleFeed, error)

func (*PreambleFeed) Preamble

func (p *PreambleFeed) Preamble() string

func (*PreambleFeed) Read

func (p *PreambleFeed) Read(b []byte) (n int, err error)

type Profile

type Profile struct {
	Type string

	Username  string
	Tagline   string
	URL       string
	TwtURL    string
	BlogsURL  string
	AvatarURL string

	// `true` if the User viewing the Profile has muted this user/feed
	Muted bool

	// `true` if the User viewing the Profile has follows this user/feed
	Follows bool

	// `true` if user/feed follows the User viewing the Profile.
	FollowedBy bool

	Bookmarks map[string]string
	Followers map[string]string
	Following map[string]string

	// `true` if the User viewing the Profile has permissions to show the
	// bookmarks/followers/followings of this user/feed
	ShowBookmarks bool
	ShowFollowers bool
	ShowFollowing bool
}

Profile represents a user/feed profile

type ProfileResponse

type ProfileResponse struct {
	Profile      Profile      `json:"profile"`
	Links        Links        `json:"links"`
	Alternatives Alternatives `json:"alternatives"`
	Twter        Twter        `json:"twter"`
}

ProfileResponse ...

type RegisterRequest

type RegisterRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Email    string `json:"email"`
}

RegisterRequest ...

func NewRegisterRequest

func NewRegisterRequest(r io.Reader) (req RegisterRequest, err error)

NewRegisterRequest ...

type ReportRequest

type ReportRequest struct {
	Nick string `json:"nick"`
	URL  string `json:"url"`

	Name     string `json:"name"`
	Email    string `json:"email"`
	Category string `json:"subject"`
	Message  string `json:"message"`
}

ReportRequest ...

func NewReportRequest

func NewReportRequest(r io.Reader) (req ReportRequest, err error)

NewReportRequest ...

type Subject

type Subject interface {
	Text() string
	Tag() TwtTag

	String() string
}

type SupportRequest

type SupportRequest struct {
	Name    string `json:"name"`
	Email   string `json:"email"`
	Subject string `json:"subject"`
	Message string `json:"message"`
}

SupportRequest ...

func NewSupportRequest

func NewSupportRequest(r io.Reader) (req SupportRequest, err error)

NewSupportRequest ...

type TagList

type TagList []TwtTag

func (*TagList) Tags

func (tags *TagList) Tags() []string

type Twt

type Twt interface {
	IsZero() bool
	Clone() Twt

	Twter() Twter
	Created() time.Time

	Hash() string
	Subject() Subject
	Mentions() MentionList
	Links() LinkList
	Tags() TagList

	ExpandLinks(FmtOpts, FeedLookup)

	// TODO: remove FormatText and add func to update links for UI
	FormatText(TwtTextFormat, FmtOpts) string

	fmt.Formatter
}

Twt ...

func DecodeJSON

func DecodeJSON(b []byte) (Twt, error)

func MakeTwt

func MakeTwt(twter Twter, ts time.Time, text string) Twt

func ParseLine

func ParseLine(line string, twter Twter) (twt Twt, err error)

type TwtFile

type TwtFile interface {
	Twter() Twter
	Info() Info
	Twts() Twts
}

func ParseFile

func ParseFile(r io.Reader, twter Twter) (TwtFile, error)
type TwtLink interface {
	Text() string
	Target() string
}

type TwtManager

type TwtManager interface {
	DecodeJSON([]byte) (Twt, error)
	ParseLine(string, Twter) (Twt, error)
	ParseFile(io.Reader, Twter) (TwtFile, error)
	MakeTwt(twter Twter, ts time.Time, text string) Twt
}

type TwtMap

type TwtMap map[string]Twt

TwtMap ...

type TwtMention

type TwtMention interface {
	Twter() Twter
}

type TwtTag

type TwtTag interface {
	Text() string
	Target() string
}

type TwtTextFormat

type TwtTextFormat int

TwtTextFormat represents the format of which the twt text gets formatted to

const (
	// MarkdownFmt to use markdown format
	MarkdownFmt TwtTextFormat = iota
	// HTMLFmt to use HTML format
	HTMLFmt
	// TextFmt to use for og:description
	TextFmt
)

type Twter

type Twter struct {
	Nick    string
	URL     string
	Avatar  string
	Tagline string
	Follow  map[string]Twter
}

Twter ...

func (Twter) Domain

func (twter Twter) Domain() string

func (Twter) DomainNick

func (twter Twter) DomainNick() string

func (Twter) IsZero

func (twter Twter) IsZero() bool

func (Twter) MarshalJSON

func (twter Twter) MarshalJSON() ([]byte, error)

func (Twter) String

func (twter Twter) String() string

type Twts

type Twts []Twt

Twts typedef to be able to attach sort methods

func (Twts) Clone

func (twts Twts) Clone() Twts

func (Twts) Len

func (twts Twts) Len() int

func (Twts) Less

func (twts Twts) Less(i, j int) bool

func (Twts) LinkCount

func (twts Twts) LinkCount() map[string]int
func (twts Twts) Links() LinkList

Links ...

func (Twts) MentionCount

func (twts Twts) MentionCount() map[string]int

func (Twts) Mentions

func (twts Twts) Mentions() MentionList

Mentions ...

func (Twts) SubjectCount

func (twts Twts) SubjectCount() map[string]int

func (Twts) Subjects

func (twts Twts) Subjects() []Subject

Subjects ...

func (Twts) Swap

func (twts Twts) Swap(i, j int)

func (Twts) TagCount

func (twts Twts) TagCount() map[string]int

func (Twts) Tags

func (twts Twts) Tags() TagList

Tags ...

func (*Twts) UnmarshalJSON

func (twts *Twts) UnmarshalJSON(data []byte) error

type UnfollowRequest

type UnfollowRequest struct {
	Nick string `json:"nick"`
}

UnfollowRequest ...

func NewUnfollowRequest

func NewUnfollowRequest(r io.Reader) (req UnfollowRequest, err error)

NewUnfollowRequest ...

type UnmuteRequest

type UnmuteRequest struct {
	Nick string `json:"nick"`
}

UnmuteRequest ...

func NewUnmuteRequest

func NewUnmuteRequest(r io.Reader) (req UnmuteRequest, err error)

NewUnmuteRequest ...

type Value

type Value interface {
	Key() string
	Value() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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