models

package
v0.22.8 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeDateFormat = "2006-01-02 15:04" // YYYY-MM-DD HH:MM.
	DateFormat     = "2006-01-02"       // YYYY-MM-DD.
	TimeFormat     = "15:04"            //HH:MM
	AuthorNone     = "None"
)
View Source
const (
	ErrNoData      = "no data"
	ErrNoChecksum  = "no checksum"
	ErrBadChecksum = "bad checksum"
)
View Source
const (
	CR = "\r"
	LF = "\n"

	// NewLine is a new line.
	// This is the correct new line, as it used to be in the history of mankind.
	// If you are a user of Unix, Linux, Macintosh or something else, check the
	// Wikipedia: https://en.wikipedia.org/wiki/Newline
	NewLine = CR + LF
)

Variables

View Source
var Categories = map[string]*Category{
	"event": {
		Name:        "Events",
		Path:        "event",
		CssClass:    "tmbEvents",
		Description: "Latest events which may attract your attention.",
		Icon:        "event",
	},
	"game": {
		Name:     "Games",
		Path:     "game",
		CssClass: "tmbGames",
		Description: "Computer games of all kinds and for all platforms, " +
			"including consoles, portable gaming devices and smartphones.",
		Icon: "game",
	},
	"hard": {
		Name:     "Hardware",
		Path:     "hard",
		CssClass: "tmbHardware",
		Description: "Various computer hardware, from cases and power supply units " +
			"to microprocessors and GPUs.",
		Icon: "hard",
	},
	"life": {
		Name:     "Life",
		Path:     "life",
		CssClass: "tmbLife",
		Description: "Everything about life in the universe. [br]" +
			"From flowers and bees to animals and humanoids.",
		Icon: "life",
	},
	"media": {
		Name:     "Multimedia",
		Path:     "media",
		CssClass: "tmbMultimedia",
		Description: "Audio, video, animation, images, photography, literature. " +
			"Anything from a short ringtone sound to a full-length feature film.",
		Icon: "media",
	},
	"motor": {
		Name:     "Motorsport",
		Path:     "motor",
		CssClass: "tmbMotorsport",
		Description: "All kinds of automobile sports. From kart and buggy " +
			"to IndyCar and Formula One.",
		Icon: "motor",
	},
	"news": {
		Name:        "News",
		Path:        "news",
		CssClass:    "tmbNews",
		Description: "All kinds of news all around the world of planet Earth.",
		Icon:        "news",
	},
	"review": {
		Name:        "Reviews",
		Path:        "review",
		CssClass:    "tmbReviews",
		Description: "Reviews of all kinds. From bread toasters to supercomputers.",
		Icon:        "review",
	},
	"soft": {
		Name:        "Software",
		Path:        "soft",
		CssClass:    "tmbSoftware",
		Description: "Software of all kinds.",
		Icon:        "soft",
	},
	"tech": {
		Name:        "Technology",
		Path:        "tech",
		CssClass:    "tmbTechnology",
		Description: "Everything about past, modern and future technologies.",
		Icon:        "tech",
	},
}

Functions

This section is empty.

Types

type Article

type Article struct {
	DateTimeUTC time.Time
	Category    string
	Title       string
	Description string
	Content     string
	Icon        string
	Author      string
	CRC32Hex    string
}

func NewArticle

func NewArticle(
	category string,
	title string,
	description string,
	content string,
	icon string,
	author string,
) (article *Article, err error)

func NewArticleFromFile

func NewArticleFromFile(filePath string) (article *Article, err error)

func (*Article) CalculateCRC32

func (a *Article) CalculateCRC32() (sum uint32)

func (*Article) CheckCRC32

func (a *Article) CheckCRC32() (ok bool)

func (*Article) FillCRC32

func (a *Article) FillCRC32()

func (*Article) HasCRC32

func (a *Article) HasCRC32() bool

func (*Article) HasData

func (a *Article) HasData() bool

func (*Article) SaveAsFile

func (a *Article) SaveAsFile(filePath string) (err error)

func (*Article) Serialize

func (a *Article) Serialize() (ba []byte, err error)

type Category

type Category struct {
	Name        string
	Path        string
	CssClass    string
	Description string
	Icon        string
}

type RawArticle

type RawArticle struct {
	DateUTC     string `json:"Date"`
	TimeUTC     string `json:"Time"`
	Category    string `json:"Category"`
	Title       string `json:"Title"`
	Description string `json:"Description"`
	Content     string `json:"Content"`
	Icon        string `json:"Icon"`
	Author      string `json:"Author"`
	CRC32Hex    string `json:"CRC32"`
}

type SortedFile

type SortedFile struct {
	FilePath        string
	ArticleDateTime time.Time
}

type SortedFiles

type SortedFiles []*SortedFile

SortedFiles are files are sorted in a reverse way: first file is the newest one.

func (SortedFiles) GetNonTopItems

func (sfs SortedFiles) GetNonTopItems(n int) SortedFiles

GetNonTopItems tries to return non-top items excluding the N top items.

func (SortedFiles) GetTopItems

func (sfs SortedFiles) GetTopItems(n int) SortedFiles

GetTopItems tries to return N top items from the list. If there are less than N top items available, they are returned.

func (SortedFiles) Len

func (sfs SortedFiles) Len() int

func (SortedFiles) Less

func (sfs SortedFiles) Less(i, j int) bool

func (SortedFiles) Swap

func (sfs SortedFiles) Swap(i, j int)

Jump to

Keyboard shortcuts

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