booktypes

package
v0.0.0-...-9d7fed6 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetWords

func GetWords(s string) []string

GetWords retrieves a lowercased list of alphanumeric strings from an input string

Types

type Agent

type Agent struct {
	ID        string    `json:"id,omitempty"`
	Name      string    `json:"name,omitempty"`
	Aliases   []string  `json:"aliases,omitempty"`
	BirthDate date.Date `json:"birth_date,omitempty"`
	DeathDate date.Date `json:"death_date,omitempty"`
	Webpages  []string  `json:"webpages,omitempty"`
}

Agent is a record for a human (Project Gutenberg calls these agents). This can be an author, editor, or illustrator.

func (Agent) AddWords

func (a Agent) AddWords(w *stringset.StringSet)

AddWords the list of lower-case alphanumerics in the Agent Name and Aliases to the given StringSet

type CompType

type CompType int

CompType indicates the type of standalone compression in use (Note that some formats are inherently compressed.)

const (
	CompNone CompType = iota
	CompZip
)

Types of compression Currently PG only supports zip, but if they ever add more, it would go here

type EBook

type EBook struct {
	ID              string               `json:"id,omitempty"`
	Publisher       string               `json:"publisher,omitempty"`
	Title           string               `json:"title,omitempty"`
	Creators        []string             `json:"creators,omitempty"`
	Illustrators    []string             `json:"illustrators,omitempty"`
	TableOfContents string               `json:"table_of_contents,omitempty"`
	Language        string               `json:"language,omitempty"`
	Subjects        []string             `json:"subjects,omitempty"`
	Issued          date.Date            `json:"issued,omitempty"`
	DownloadCount   int                  `json:"download_count,omitempty"`
	Rights          string               `json:"rights,omitempty"`
	Copyright       string               `json:"copyright,omitempty"`
	Edition         string               `json:"edition,omitempty"`
	Type            string               `json:"type,omitempty"`
	Files           []PGFile             `json:"files,omitempty"`
	Agents          map[string]Agent     `json:"agents,omitempty"`
	CopyrightDates  []date.Date          `json:"-"`
	Words           *stringset.StringSet `json:"-"`
}

EBook is the parsed and processed structure of an ebook object.

func (*EBook) ExtractWords

func (e *EBook) ExtractWords()

ExtractWords retrieves a stringSet of individual words

func (*EBook) FullCreators

func (e *EBook) FullCreators() []Agent

FullCreators is a helper function for templates to extract the creator name(s)

type PGFile

type PGFile struct {
	Location string    `json:"location,omitempty"`
	Format   string    `json:"format,omitempty"`
	Comp     CompType  `json:"comp,omitempty"`
	FileSize int       `json:"filesize,omitempty"`
	Modified date.Date `json:"modified,omitempty"`
	BookID   string    `json:"bookid,omitempty"`
}

PGFile is the parsed and processed structure of an object within the Project Gutenberg data that corresponds to a single downloadable entity -- a particular version of the content.

func BuildFile

func BuildFile(id string, loc string, formats []string, siz int, modified string) PGFile

BuildFile makes a PGFile object from a set of parameters. In particular, it gets a slice of formats, which will be either one or two items, one of which might be a compression format. These get broken out into base format and an optional compression format.

Jump to

Keyboard shortcuts

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