types

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package types provides common data types used across all Betula, all conveniently collected in a single box for resolving import cycles nicely.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalCategoryName

func CanonicalCategoryName(rawName string) string

func JoinCategories

func JoinCategories(cats []Category) string

Types

type Category

type Category struct {
	Name      string
	PostCount uint
}

func SplitCategories

func SplitCategories(commaSeparated string) []Category

type Post

type Post struct {
	// ID is a unique identifier of the post. Do not set this field by yourself.
	ID int
	// CreationTime is UNIX seconds. Do not set this field by yourself.
	CreationTime int64
	// Categories are categories of this post. Do not set this field by yourself.
	Categories []Category

	// URL is a URL with any protocol.
	URL string
	// Title is a name for the link.
	Title string
	// Description is a Mycomarkup-formatted document. Currently, just unescaped plain text.
	Description string
	// Visibility sets who can see the post.
	Visibility Visibility
}

Post is a link, along with some data.

func (Post) FixMixUp

func (post Post) FixMixUp() Post

FixMixUp returns a copy of post. Its Title and URL are swapped, iff Title is a valid URL, and URL is not a valid URL.

type Visibility

type Visibility int

Visibility determines where the post is seen.

const (
	// Private posts are only seen by the author.
	Private Visibility = iota
	// Public posts are seen by everyone, and are federated.
	Public
)

func VisibilityFromString

func VisibilityFromString(s string) Visibility

VisibilityFromString turns a string into a Visbility.

Jump to

Keyboard shortcuts

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