krista

package
v0.0.0-...-6974182 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

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"`
}

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
}

type Language

type Language struct {
	Name  string
	Color string
}

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(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) 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