aozorafs

package
v0.50.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

README

Overview

Package aozorafs provides functionality for browsing the database of Aozora Bunko by exposing the contents of the library as an fs.FS.

Documentation

Overview

Package aozorafs provides functionality for browsing the database of Aozora Bunko by exposing the contents of the library as an fs.FS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDownloader added in v0.9.0

func SetDownloader(f func(path string) []byte)

Types

type ContribRole added in v0.2.0

type ContribRole struct {
	Role     string
	AuthorID string
	B        *Record
}

ContribRole is for storing various contributors to a book.

type LibFS added in v0.9.0

type LibFS interface {
	fs.StatFS
	CreateFile(name string, data []byte) (fs.File, error)
	CreateEphemeral(name string, data []byte) (fs.File, error)
	Exists(name string) bool
	RemoveAll()
	Path() string
}

type LibFile added in v0.9.0

type LibFile interface {
	fs.File
	Write(b []byte) (n int, err error)
}

type Library

type Library struct {
	Categories map[string]string
	// contains filtered or unexported fields
}

Library is stores basic information. Root is the path to the original aozora file tree. Cache is path to the storage directory for server. Resources holds the templates, css. Catalog is for stroing Library information.

func NewLibrary

func NewLibrary() *Library

NewLibrary returns a new Library.

func (*Library) BookList added in v0.50.1

func (lib *Library) BookList() []*Record

func (*Library) FetchLibrary added in v0.9.0

func (lib *Library) FetchLibrary()

func (*Library) FindBooksWithMatchingCategories added in v0.9.0

func (lib *Library) FindBooksWithMatchingCategories(q string) (categories []*Record)

func (*Library) FindMatchingAuthors added in v0.3.0

func (lib *Library) FindMatchingAuthors(q string) (authors []*Record)

FindMatchingAuthors finds the authors whose names include q.

func (*Library) FindMatchingCategories added in v0.3.0

func (lib *Library) FindMatchingCategories(q string) (categories []string)

FindMatchingCategories finds the books whose NDC category include q

func (*Library) FindMatchingTitles added in v0.3.0

func (lib *Library) FindMatchingTitles(q string) (titles []*Record)

FindMatchingTitles finds the books whose title+subtitle contain q.

func (*Library) FirstBookBy added in v0.9.0

func (lib *Library) FirstBookBy(b *Record) *Record

func (*Library) GenRandomBook added in v0.9.0

func (lib *Library) GenRandomBook() (fs.File, error)

func (*Library) GenSearchResults added in v0.9.0

func (lib *Library) GenSearchResults(q string) []byte

func (*Library) GetBookRecord added in v0.9.0

func (lib *Library) GetBookRecord(name string) (*Record, error)

func (*Library) GetBooklist added in v0.50.1

func (lib *Library) GetBooklist(d []byte)

func (*Library) GetRecordWithID added in v0.9.0

func (lib *Library) GetRecordWithID(authorid, bookid string) *Record

func (*Library) ImportTemplates added in v0.9.0

func (lib *Library) ImportTemplates(dir fs.ReadDirFS)

func (*Library) Initialize

func (lib *Library) Initialize(src string, dir string, clean, verbose, kids, strict bool)

Initialize initalized the library lib to the given specifications.

  • dir is the root directory of the library on the local file system.
  • clean specifies whether or not to start with an empty library directory.
  • verbose toggles verbose logging to screen. Logging to aozora.log will always take place.
  • kids specifies toggles children's library (removes books that are not marked as children's book in the Aozora Bunko database.
  • strict toggles whether or not to include books that are not in the public domain.
  • checkInt specifies the interval for checking for updates to the library upstream.

func (*Library) LastBookBy added in v0.9.0

func (lib *Library) LastBookBy(b *Record) *Record

func (*Library) LenDistinctBooks added in v0.50.1

func (lib *Library) LenDistinctBooks() int

func (*Library) NextAuthor

func (lib *Library) NextAuthor(b *Record) *Record

NextAuthor returns the next author where the current author is the author of b.

func (*Library) NextBook

func (lib *Library) NextBook(b *Record) *Record

NextBook returns the next book by the same author.

func (*Library) Open

func (lib *Library) Open(name string) (f fs.File, err error)

func (*Library) PrevAuthor

func (lib *Library) PrevAuthor(b *Record) *Record

PrevAuthor returns the previous author where the current author is the author of b.

func (*Library) PrevBook

func (lib *Library) PrevBook(b *Record) *Record

PrevBook returns the previous book by the same author.

func (*Library) RandomBook added in v0.9.0

func (lib *Library) RandomBook() *Record

func (*Library) SetCache added in v0.9.0

func (lib *Library) SetCache(fs LibFS)

func (*Library) SetKids added in v0.9.0

func (lib *Library) SetKids(k bool)

func (*Library) SetSrc added in v0.9.0

func (lib *Library) SetSrc(name string)

func (*Library) SortByAvailDate added in v0.50.1

func (lib *Library) SortByAvailDate()

type Record

type Record struct {
	BookID          string
	Title           string
	TitleY          string
	TitleSort       string
	Subtitle        string
	SubtitleY       string
	SubtitleSort    string
	OriginalTitle   string
	PublDate        string
	NDC             string
	Category        string
	Categories      [][3]string
	KanaZukai       string
	WorkCopyright   string
	FirstAvailable  string
	ModTime         string
	AuthorID        string
	NameSei         string
	NameMei         string
	NameSeiY        string
	NameMeiY        string
	NameSeiSort     string
	NameMeiSort     string
	NameSeiR        string
	NameMeiR        string
	Role            string
	DoBirth         string
	DoDeath         string
	AuthorCopyright string
	URI             string
	Kids            bool
	Contributors    []ContribRole

	TxtFileName string
	// contains filtered or unexported fields
}

Record is for storing information about individual books.

func (*Record) Dates

func (b *Record) Dates() string

Dates returns the dates of the author of b.

func (*Record) FileName

func (b *Record) FileName() string

FileName returns the filename of the file associated with b.

func (*Record) FullName

func (b *Record) FullName() string

FullName returns the full name in Japanese order (family name first), with a space between family and given name.

func (*Record) FullNameY

func (b *Record) FullNameY() string

FullNameY returns the yomi of full name. It return a blank when there is no kanji in the name.

func (*Record) NameParts added in v0.10.0

func (b *Record) NameParts() []string

func (*Record) RealBookID

func (b *Record) RealBookID() string

RealBookID returns the book id without any suffixes.

func (*Record) SetCategoryString added in v0.50.1

func (b *Record) SetCategoryString(ndc map[string]string)

Directories

Path Synopsis
Package stringops provides some functionality to assist with working with strings.
Package stringops provides some functionality to assist with working with strings.
Package zipfs provides some helper functions to help working with zip files.
Package zipfs provides some helper functions to help working with zip files.

Jump to

Keyboard shortcuts

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