topi

package
v0.0.0-...-c5cf049 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StyleDark  = styles.Get("github-dark")
	StyleLight = styles.Get("github")
)

Functions

func FormatBuildVersion

func FormatBuildVersion(version string, commit string, buildTime string) string

Types

type CacheConfig

type CacheConfig struct {
	Size int           `yaml:"size"`
	TTL  time.Duration `yaml:"ttl"`
}

func (CacheConfig) String

func (c CacheConfig) String() string

type Comment

type Comment struct {
	Author    string
	AvatarURL template.URL
	CreatedAt time.Time
	Upvotes   int
	Content   template.HTML
	Body      string
	Replies   []Reply
}

type Config

type Config struct {
	Log        LogConfig    `yaml:"log"`
	Debug      bool         `yaml:"debug"`
	DevMode    bool         `yaml:"dev_mode"`
	ListenAddr string       `yaml:"listen_addr"`
	GitHub     GitHubConfig `yaml:"github"`
	Cache      *CacheConfig `yaml:"cache"`
	LastFM     LastFMConfig `yaml:"lastfm"`
}

func LoadConfig

func LoadConfig(path string) (Config, error)

func (Config) String

func (c Config) String() string

type ExecuteTemplateFunc

type ExecuteTemplateFunc func(wr io.Writer, name string, data any) error

type GitHubConfig

type GitHubConfig struct {
	AccessToken string `yaml:"access_token"`
	User        string `yaml:"user"`
}

func (GitHubConfig) String

func (c GitHubConfig) String() string

type Home

type Home struct {
	Body    string
	Content template.HTML
	LastFM  LastFM
}

type Image

type Image []struct {
	Size string `json:"size"`
	Text string `json:"#text"`
}

type Language

type Language struct {
	Name  string
	Color string
}

type LastFM

type LastFM struct {
	Track *LastFMTrack
	URL   string
	Error string
}

type LastFMConfig

type LastFMConfig struct {
	Username string        `yaml:"username"`
	APIKey   string        `yaml:"api_key"`
	Size     int           `yaml:"size"`
	TTL      time.Duration `yaml:"ttl"`
}

func (LastFMConfig) String

func (c LastFMConfig) String() string

type LastFMResponse

type LastFMResponse struct {
	RecentTracks struct {
		Track []struct {
			Artist struct {
				URL   string `json:"url"`
				Name  string `json:"name"`
				Image Image  `json:"image"`
				MbID  string `json:"mbid"`
			} `json:"artist"`
			Date struct {
				Uts  int64  `json:"uts,string"`
				Text string `json:"#text"`
			} `json:"date"`
			MbID       string `json:"mbid"`
			Name       string `json:"name"`
			Image      Image  `json:"image"`
			URL        string `json:"url"`
			Streamable int    `json:"streamable,string"`
			Album      struct {
				MbID string `json:"mbid"`
				Text string `json:"#text"`
			}
			Loved int `json:"loved,string"`
			Attr  struct {
				NowPlaying string `json:"nowplaying"`
			} `json:"@attr"`
		}
	} `json:"recenttracks"`
	Attr struct {
		User       string `json:"user"`
		TotalPages int    `json:"totalPages,string"`
		Page       int    `json:"page,string"`
		Total      int    `json:"total,string"`
		PerPage    int    `json:"perPage,string"`
	} `json:"@attr"`
}

type LastFMTrack

type LastFMTrack struct {
	Name      string
	Artist    string
	ArtistURL string
	Album     string
	Artwork   string
	URL       string
	Loved     bool
}

type LogConfig

type LogConfig struct {
	Level     slog.Level `cfg:"level"`
	Format    string     `cfg:"format"`
	AddSource bool       `cfg:"add_source"`
	NoColor   bool       `cfg:"no_color"`
}

func (LogConfig) String

func (c LogConfig) String() string

type Post

type Post struct {
	Title     string
	CreatedAt time.Time
	URL       template.URL
	Content   template.HTML
	Body      string
	Upvotes   int
	Comments  []Comment
}

type Project

type Project struct {
	Name        string
	Description string
	URL         template.URL
	Stars       int
	Forks       int
	UpdatedAt   time.Time
	Language    *Language
	Topics      []Topic
}

type Reply

type Reply struct {
	Author    string
	AvatarURL template.URL
	CreatedAt time.Time
	Content   template.HTML
	Body      string
}

type Repositories

type Repositories struct {
	Nodes []struct {
		Name             string
		URL              string
		Description      string
		StargazerCount   int
		ForkCount        int
		PushedAt         time.Time
		RepositoryTopics struct {
			Nodes []struct {
				Topic struct {
					Name string
				}
				URL string
			}
		} `graphql:"repositoryTopics(first: $topics)"`
		Languages struct {
			Nodes []struct {
				Name  string
				Color string
			}
		} `graphql:"languages(first: 1, orderBy: {field: SIZE, direction: DESC})"`
	}
	PageInfo struct {
		EndCursor   string
		HasNextPage bool
	}
}

type Server

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

func NewServer

func NewServer(version string, cfg Config, httpClient *http.Client, githubClient *githubv4.Client, md goldmark.Markdown, assets http.FileSystem, tmpl ExecuteTemplateFunc) *Server

func (*Server) Close

func (s *Server) Close()

func (*Server) FetchData

func (s *Server) FetchData(ctx context.Context) (*Variables, error)

func (*Server) FetchLastFM

func (s *Server) FetchLastFM(ctx context.Context) LastFM

func (*Server) FetchRepositories

func (s *Server) FetchRepositories(ctx context.Context, after string) (*Variables, error)

func (*Server) HighlightData

func (s *Server) HighlightData(vars *Variables) error

func (*Server) Routes

func (s *Server) Routes() http.Handler

func (*Server) Start

func (s *Server) Start()

type Topic

type Topic struct {
	Name string
	URL  string
}

type User

type User struct {
	Name      string
	AvatarURL template.URL
}

type Variables

type Variables struct {
	User          User
	Home          Home
	Posts         []Post
	PostsAfter    string
	Projects      []Project
	ProjectsAfter string
	Dark          bool
	Description   string
	CSS           template.CSS
}

Jump to

Keyboard shortcuts

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