squantified

package
v0.0.0-...-9896159 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderRuns

func RenderRuns(c *modulir.Context, viewsChanged bool,
	getLocals func(string, map[string]interface{}) map[string]interface{},
) error

RenderRuns renders the `/runs` page by fetching and processing data.

This traditionally used a Black Swan database for run information, but I've deprecated that project, so to work again it needs to be converted over to use a qself flat file containing run information, like Goodreads and Twitter already do in this file.

func RenderTwitter

func RenderTwitter(c *modulir.Context, viewsChanged bool,
	getLocals func(string, map[string]interface{}) map[string]interface{},
	tweets []*Tweet, withReplies bool,
) error

RenderTwitter renders the `/twitter` page.

Types

type Reading

type Reading struct {
	Authors       []*ReadingAuthor `toml:"authors"`
	ID            int              `toml:"id"`
	ISBN          string           `toml:"isbn"`
	ISBN13        string           `toml:"isbn13"`
	NumPages      int              `toml:"num_pages"`
	PublishedYear int              `toml:"published_year"`
	ReadAt        time.Time        `toml:"read_at"`
	Rating        int              `toml:"rating"`
	Review        string           `toml:"review"`
	ReviewHTML    template.HTML    `toml:"-"`
	ReviewID      int              `toml:"review_id"`
	Title         string           `toml:"title"`

	// AuthorsDisplay is just the names of all authors combined together for
	// display on a page.
	AuthorsDisplay string `toml:"-"`
}

Reading is a single Goodreads book stored to a TOML file.

func GetReadingsData

func GetReadingsData(c *modulir.Context, target string) ([]*Reading, error)

type ReadingAuthor

type ReadingAuthor struct {
	ID   int    `toml:"id"`
	Name string `toml:"name"`
}

ReadingAuthor is a single Goodreads author stored to a TOML file.

func (*ReadingAuthor) UnmarshalText

func (a *ReadingAuthor) UnmarshalText(data []byte) error

Only kicks in if the author value is a single string. Otherwise the full object is unmarshaled into the struct.

type ReadingDB

type ReadingDB struct {
	Readings []*Reading `toml:"readings"`
}

ReadingDB is a database of Goodreads readings stored to a TOML file.

type Run

type Run struct {
	// Distance is the distance traveled for the run in meters.
	Distance float64

	// ElevationGain is the total gain in elevation in meters.
	ElevationGain float64

	// LocationCity is the closest city to which the run occurred. It may be
	// an empty string if Strava wasn't able to match anything.
	LocationCity string

	// MovingTime is the amount of time that the run took.
	MovingTime time.Duration

	// OccurredAt is the local time in which the run occurred. Note that we
	// don't use UTC here so as to not make runs in other timezones look to
	// have occurred at crazy times.
	OccurredAt *time.Time
}

Run is a run as downloaded from Strava.

type RunDB

type RunDB struct {
	Runs []*Run `toml:"runs"`
}

RunDB is a database of runs stored to a TOML file.

type Tweet

type Tweet struct {
	CreatedAt     time.Time      `toml:"created_at"`
	Entities      *TweetEntities `toml:"entities"`
	FavoriteCount int            `toml:"favorite_count"`
	ID            int64          `toml:"id"`
	Reply         *TweetReply    `toml:"reply"`
	Retweet       *TweetRetweet  `toml:"retweet"`
	RetweetCount  int            `toml:"retweet_count"`
	Text          string         `toml:"text"`

	// ImageURLs are the URLs of all images associated with a given tweet, if
	// any.
	ImageURLs []string `toml:"-"`

	// ReplyOrMention is assigned to tweets which are either a direct mention
	// or reply, and which therefore don't go in the main timeline. It gives us
	// an easy way to access this information from a template.
	ReplyOrMention bool `toml:"-"`

	// TextHTML is Text rendered to HTML using a variety of special Twitter
	// rules. It's rendered once and added to the struct so that it can be
	// reused across multiple pages.
	TextHTML template.HTML `toml:"-"`
}

Tweet is a single tweet stored to a TOML file.

func ReadTwitterData

func ReadTwitterData(c *modulir.Context, source string) ([]*Tweet, error)

ReadTwitterData reads Twitter data from a TOML data file and does a little bit of post-processing to add some convenience properties and an HTML rendering of each tweet.

type TweetDB

type TweetDB struct {
	Tweets []*Tweet `toml:"tweets"`
}

TweetDB is a database of tweets stored to a TOML file.

type TweetEntities

type TweetEntities struct {
	Medias       []*TweetEntitiesMedia       `toml:"medias"`
	URLs         []*TweetEntitiesURL         `toml:"urls"`
	UserMentions []*TweetEntitiesUserMention `toml:"user_mentions"`
}

TweetEntities contains various multimedia entries that may be contained in a tweet.

type TweetEntitiesMedia

type TweetEntitiesMedia struct {
	ID   int64  `toml:"id"`
	Type string `toml:"type"`
	URL  string `toml:"url"`
	// contains filtered or unexported fields
}

TweetEntitiesMedia is an image or video stored in a tweet.

func (*TweetEntitiesMedia) OriginalExt

func (p *TweetEntitiesMedia) OriginalExt() string

type TweetEntitiesURL

type TweetEntitiesURL struct {
	DisplayURL  string `toml:"display_url"`
	ExpandedURL string `toml:"expanded_url"`
	URL         string `toml:"url"`
}

TweetEntitiesURL is a URL referenced in a tweet.

type TweetEntitiesUserMention

type TweetEntitiesUserMention struct {
	User   string `toml:"user"`
	UserID int64  `toml:"user_id"`
}

TweetEntitiesUserMention is another user being mentioned in a tweet.

type TweetReply

type TweetReply struct {
	StatusID int64  `toml:"status_id"`
	User     string `toml:"user"`
	UserID   int64  `toml:"user_id"`
}

TweetReply is populated with reply information for when a tweet is a reply.

type TweetRetweet

type TweetRetweet struct {
	StatusID int64  `toml:"status_id"`
	User     string `toml:"user"`
	UserID   int64  `toml:"user_id"`
}

TweetRetweet is populated with retweet information for when a tweet is a retweet.

Jump to

Keyboard shortcuts

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