models

package
v0.0.0-...-4abef1a Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ImageDir string = "images/cover_images"
View Source
const LargeCover = "L"
View Source
const MediumCover = "M"
View Source
const Missing int64 = -999998
View Source
const SmallCover = "S"
View Source
const Verbose bool = false

Variables

View Source
var (
	Unknown     = Rating{"Not Rated"}
	VeryGood    = Rating{"Very-Good"}
	Excellent   = Rating{"Excellent"}
	Kindle      = Rating{"Kindle"}
	Interesting = Rating{"Interesting"}
	NotGood     = Rating{"Not-Good"}
)

Functions

func CaptureAllSizeCovers

func CaptureAllSizeCovers(b Book, imageDir string)

func CaptureCoverImages

func CaptureCoverImages(db *gorm.DB, books []Book, imageDir string) error

func CreateBooksDatabase

func CreateBooksDatabase(databaseName string) *gorm.DB

func ExtractSurname

func ExtractSurname(fullName string) string

This might need to get more sophisticated

func GetBookByOlId

func GetBookByOlId(olid string) (gol.Book, error)

func TransferJsonBooksToDatabase

func TransferJsonBooksToDatabase(jsonFileName string, db *gorm.DB) error

Types

type Author

type Author struct {
	gorm.Model
	FullName string
	Surname  string
	Books    []Book `gorm:"many2many:book_authors;"`
}

func (Author) GetBooks

func (a Author) GetBooks() []Book

func (Author) HasBook

func (a Author) HasBook(book Book) bool

func (Author) SiteName

func (a Author) SiteName() string

type Book

type Book struct {
	gorm.Model
	PubDate                int64
	DateAdded              time.Time
	AuthorFullName         string
	AuthorSurname          string
	MainTitle              string
	SubTitle               string
	Review                 string
	Rating                 string
	AmazonLink             string
	CoverImageUrl          string
	OpenLibraryUrl         string
	IsfdbUrl               string
	OpenLibraryBookIsbns   []OpenLibraryBookIsbn
	OlCoverId              int64 // Used as the base ID for the image (add suffix -M, -S, -L for sizing.)
	OpenLibraryBookAuthors []OpenLibraryBookAuthor
	OlCoverEditionId       string   // Used to pull up an entry based on a cover
	Authors                []Author `gorm:"many2many:book_authors;"`
}

func LoadAllBooks

func LoadAllBooks(db *gorm.DB) ([]Book, error)

func (Book) AlternateAuthorFullNames

func (b Book) AlternateAuthorFullNames() []string
func (b Book) BookPageLink(args ...string) template.HTML

func (Book) BookPageURL

func (b Book) BookPageURL(args ...string) string

func (Book) Create

func (b Book) Create(db *gorm.DB) (uint, error)

func (Book) DisplayRating

func (b Book) DisplayRating() string

func (Book) FormatPubDate

func (b Book) FormatPubDate() string

func (Book) FormatRating

func (b Book) FormatRating() string

func (Book) FormatTitle

func (b Book) FormatTitle() string

func (Book) HasCoverImageId

func (b Book) HasCoverImageId() bool

func (Book) HasOpenLibraryId

func (b Book) HasOpenLibraryId() bool

func (Book) MakeCoverImageFilename

func (b Book) MakeCoverImageFilename(imageDir string, size string) string

func (Book) MakeCoverImageUrl

func (b Book) MakeCoverImageUrl(size string) string

func (Book) MakeLinkedLargeCoverImageTag

func (b Book) MakeLinkedLargeCoverImageTag(args ...string) template.HTML

func (Book) MakeLinkedMediumCoverImageTag

func (b Book) MakeLinkedMediumCoverImageTag(args ...string) template.HTML

func (Book) MakeLinkedSmallCoverImageTag

func (b Book) MakeLinkedSmallCoverImageTag(args ...string) template.HTML

func (Book) ReviewHTML

func (b Book) ReviewHTML() template.HTML

func (Book) ReviewPreviewHTML

func (b Book) ReviewPreviewHTML() template.HTML

func (Book) ReviewPreviewIsTruncated

func (b Book) ReviewPreviewIsTruncated() bool

func (Book) SiteFileName

func (b Book) SiteFileName() string

func (Book) UpdateFromOpenLibrary

func (b Book) UpdateFromOpenLibrary(db *gorm.DB, olSearchResult BookSearchResult) (Book, error)

type BookSearchResult

type BookSearchResult struct {
	Number             int
	FirstYearPublished int
	Title              string
	Authors            []string
	Languages          []string
	CoverEditionKey    string
	CoverImageId       string
	AuthorIds          []string // Can be more than one author
	// contains filtered or unexported fields
}

func SearchBook

func SearchBook(title string, author string) []BookSearchResult

func (BookSearchResult) GetBookCoverUrl

func (s BookSearchResult) GetBookCoverUrl(size string) string

func (BookSearchResult) HasCoverImageId

func (s BookSearchResult) HasCoverImageId() bool

func (BookSearchResult) HasEnglishLanguage

func (s BookSearchResult) HasEnglishLanguage() bool

func (BookSearchResult) Print

func (s BookSearchResult) Print() string

type BooksByAuthor

type BooksByAuthor map[string][]Book

func AllBooksFromJson

func AllBooksFromJson(bookFile string) BooksByAuthor

type OpenLibraryBookAuthor

type OpenLibraryBookAuthor struct {
	gorm.Model
	BookId     uint
	OlAuthorId string
}

type OpenLibraryBookIsbn

type OpenLibraryBookIsbn struct {
	gorm.Model
	BookId uint
	Isbn   string
}

type Rating

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

func StringToRating

func StringToRating(s string) (Rating, error)

func (Rating) Display

func (r Rating) Display() string

func (*Rating) Scan

func (r *Rating) Scan(value interface{}) error

func (Rating) String

func (r Rating) String() string

func (Rating) Value

func (r Rating) Value() (driver.Value, error)

For Gorm

Jump to

Keyboard shortcuts

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