Documentation
¶
Index ¶
- Constants
- func CoverMimeType(ext string) string
- func FileTypeMimeType(fileType string) string
- func RegisterRoutes(e *echo.Echo, db *bun.DB, cfg *config.Config, authMiddleware *auth.Middleware)
- type Author
- type AuthorInfo
- type Content
- type Entry
- type Feed
- type Link
- type OpenSearchDescription
- type OpenSearchURL
- type PaginationQuery
- type SearchQuery
- type Service
- func (svc *Service) BuildCatalogFeed(ctx context.Context, baseURL, fileTypes string, libraryIDs []int) (*Feed, error)
- func (svc *Service) BuildLibraryAllBooksFeed(ctx context.Context, baseURL, fileTypes string, libraryID, limit, offset int, ...) (*Feed, error)
- func (svc *Service) BuildLibraryAllBooksFeedKepub(ctx context.Context, baseURL, fileTypes string, libraryID, limit, offset int, ...) (*Feed, error)
- func (svc *Service) BuildLibraryAuthorBooksFeed(ctx context.Context, baseURL, fileTypes string, libraryID int, ...) (*Feed, error)
- func (svc *Service) BuildLibraryAuthorBooksFeedKepub(ctx context.Context, baseURL, fileTypes string, libraryID int, ...) (*Feed, error)
- func (svc *Service) BuildLibraryAuthorsListFeed(ctx context.Context, baseURL, fileTypes string, libraryID, limit, offset int) (*Feed, error)
- func (svc *Service) BuildLibraryCatalogFeed(ctx context.Context, baseURL, fileTypes string, libraryID int) (*Feed, error)
- func (svc *Service) BuildLibraryOpenSearchDescription(baseURL, fileTypes string, libraryID int) *OpenSearchDescription
- func (svc *Service) BuildLibrarySearchFeed(ctx context.Context, baseURL, fileTypes string, libraryID int, query string, ...) (*Feed, error)
- func (svc *Service) BuildLibrarySearchFeedKepub(ctx context.Context, baseURL, fileTypes string, libraryID int, query string, ...) (*Feed, error)
- func (svc *Service) BuildLibrarySeriesBooksFeed(ctx context.Context, baseURL, fileTypes string, ...) (*Feed, error)
- func (svc *Service) BuildLibrarySeriesBooksFeedKepub(ctx context.Context, baseURL, fileTypes string, ...) (*Feed, error)
- func (svc *Service) BuildLibrarySeriesListFeed(ctx context.Context, baseURL, fileTypes string, libraryID, limit, offset int) (*Feed, error)
- func (svc *Service) ListAuthorsInLibrary(ctx context.Context, libraryID, limit, offset int) ([]AuthorInfo, int, error)
- func (svc *Service) ListBooksByAuthor(ctx context.Context, libraryID int, authorName string, fileTypes []string, ...) ([]*models.Book, int, error)
Constants ¶
const ( AtomNS = "http://www.w3.org/2005/Atom" DCNS = "http://purl.org/dc/terms/" OPDSNS = "http://opds-spec.org/2010/catalog" OpenSearch = "http://a9.com/-/spec/opensearch/1.1/" )
OPDS namespaces.
const ( RelSelf = "self" RelStart = "start" RelUp = "up" RelSubsection = "subsection" RelNext = "next" RelPrevious = "previous" RelFirst = "first" RelLast = "last" RelSearch = "search" RelAcquisition = "http://opds-spec.org/acquisition" RelImage = "http://opds-spec.org/image" RelThumbnail = "http://opds-spec.org/image/thumbnail" )
Link relation types.
const ( MimeTypeAtom = "application/atom+xml" MimeTypeAcquisition = "application/atom+xml;profile=opds-catalog;kind=acquisition" MimeTypeOpenSearch = "application/opensearchdescription+xml" MimeTypeEPUB = "application/epub+zip" MimeTypeKepub = "application/kepub+zip" MimeTypeCBZ = "application/vnd.comicbook+zip" MimeTypeM4B = "audio/mp4" MimeTypePDF = "application/pdf" MimeTypeJPEG = "image/jpeg" MimeTypePNG = "image/png" MimeTypeWebP = "image/webp" )
MIME types.
Variables ¶
This section is empty.
Functions ¶
func CoverMimeType ¶
CoverMimeType returns the MIME type for a given cover extension.
func FileTypeMimeType ¶
FileTypeMimeType returns the MIME type for a given file type.
func RegisterRoutes ¶
RegisterRoutes registers all OPDS routes.
Types ¶
type AuthorInfo ¶
AuthorInfo holds aggregated author information.
type Entry ¶
type Entry struct {
ID string `xml:"id"`
Title string `xml:"title"`
Updated time.Time `xml:"updated"`
Published time.Time `xml:"published,omitempty"`
Authors []Author `xml:"author,omitempty"`
Summary string `xml:"summary,omitempty"`
Content *Content `xml:"content,omitempty"`
Links []Link `xml:"link"`
// Dublin Core elements
Language string `xml:"dc:language,omitempty"`
Publisher string `xml:"dc:publisher,omitempty"`
Identifier string `xml:"dc:identifier,omitempty"`
}
Entry represents an OPDS entry (book or navigation item).
func (*Entry) AddAcquisitionLink ¶
AddAcquisitionLink adds a download link for a file.
func (*Entry) AddImageLink ¶
AddImageLink adds a cover image link.
func (*Entry) AddThumbnailLink ¶
AddThumbnailLink adds a thumbnail image link.
type Feed ¶
type Feed struct {
XMLName xml.Name `xml:"feed"`
Xmlns string `xml:"xmlns,attr"`
XmlnsDC string `xml:"xmlns:dc,attr,omitempty"`
XmlnsOPDS string `xml:"xmlns:opds,attr,omitempty"`
ID string `xml:"id"`
Title string `xml:"title"`
Updated time.Time `xml:"updated"`
Author *Author `xml:"author,omitempty"`
Links []Link `xml:"link"`
Entries []Entry `xml:"entry"`
}
Feed represents an OPDS Atom feed.
type Link ¶
type Link struct {
Rel string `xml:"rel,attr,omitempty"`
Href string `xml:"href,attr"`
Type string `xml:"type,attr,omitempty"`
Title string `xml:"title,attr,omitempty"`
FacetGroup string `xml:"opds:facetGroup,attr,omitempty"`
ActiveFacet bool `xml:"opds:activeFacet,attr,omitempty"`
}
Link represents an Atom link element.
type OpenSearchDescription ¶
type OpenSearchDescription struct {
XMLName xml.Name `xml:"OpenSearchDescription"`
Xmlns string `xml:"xmlns,attr"`
ShortName string `xml:"ShortName"`
Description string `xml:"Description"`
InputEncoding string `xml:"InputEncoding"`
OutputEncoding string `xml:"OutputEncoding"`
URLs []OpenSearchURL `xml:"Url"`
}
OpenSearchDescription represents an OpenSearch description document.
func NewOpenSearchDescription ¶
func NewOpenSearchDescription(shortName, description, searchTemplate string) *OpenSearchDescription
NewOpenSearchDescription creates a new OpenSearch description.
type OpenSearchURL ¶
OpenSearchURL represents an OpenSearch URL template.
type PaginationQuery ¶
PaginationQuery represents pagination query parameters.
type SearchQuery ¶
type SearchQuery struct {
Q string `query:"q"`
Limit int `query:"limit"`
Offset int `query:"offset"`
}
SearchQuery represents search query parameters.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles OPDS feed generation.
func (*Service) BuildCatalogFeed ¶
func (svc *Service) BuildCatalogFeed(ctx context.Context, baseURL, fileTypes string, libraryIDs []int) (*Feed, error)
BuildCatalogFeed builds the root navigation feed listing all libraries. If libraryIDs is non-nil, only libraries with those IDs are included.
func (*Service) BuildLibraryAllBooksFeed ¶
func (svc *Service) BuildLibraryAllBooksFeed(ctx context.Context, baseURL, fileTypes string, libraryID, limit, offset int, sort []sortspec.SortLevel) (*Feed, error)
BuildLibraryAllBooksFeed builds an acquisition feed with all books in a library.
func (*Service) BuildLibraryAllBooksFeedKepub ¶
func (svc *Service) BuildLibraryAllBooksFeedKepub(ctx context.Context, baseURL, fileTypes string, libraryID, limit, offset int, sort []sortspec.SortLevel) (*Feed, error)
BuildLibraryAllBooksFeedKepub builds an acquisition feed with all books using KePub download links.
func (*Service) BuildLibraryAuthorBooksFeed ¶
func (svc *Service) BuildLibraryAuthorBooksFeed(ctx context.Context, baseURL, fileTypes string, libraryID int, authorName string, limit, offset int, sort []sortspec.SortLevel) (*Feed, error)
BuildLibraryAuthorBooksFeed builds an acquisition feed with books by an author.
func (*Service) BuildLibraryAuthorBooksFeedKepub ¶
func (svc *Service) BuildLibraryAuthorBooksFeedKepub(ctx context.Context, baseURL, fileTypes string, libraryID int, authorName string, limit, offset int, sort []sortspec.SortLevel) (*Feed, error)
BuildLibraryAuthorBooksFeedKepub builds an acquisition feed with books by an author using KePub download links.
func (*Service) BuildLibraryAuthorsListFeed ¶
func (svc *Service) BuildLibraryAuthorsListFeed(ctx context.Context, baseURL, fileTypes string, libraryID, limit, offset int) (*Feed, error)
BuildLibraryAuthorsListFeed builds a navigation feed listing all authors in a library.
func (*Service) BuildLibraryCatalogFeed ¶
func (svc *Service) BuildLibraryCatalogFeed(ctx context.Context, baseURL, fileTypes string, libraryID int) (*Feed, error)
BuildLibraryCatalogFeed builds a navigation feed for a specific library.
func (*Service) BuildLibraryOpenSearchDescription ¶
func (svc *Service) BuildLibraryOpenSearchDescription(baseURL, fileTypes string, libraryID int) *OpenSearchDescription
BuildLibraryOpenSearchDescription builds an OpenSearch description for a library.
func (*Service) BuildLibrarySearchFeed ¶
func (svc *Service) BuildLibrarySearchFeed(ctx context.Context, baseURL, fileTypes string, libraryID int, query string, limit, offset int, sort []sortspec.SortLevel) (*Feed, error)
BuildLibrarySearchFeed builds an acquisition feed with search results.
func (*Service) BuildLibrarySearchFeedKepub ¶
func (svc *Service) BuildLibrarySearchFeedKepub(ctx context.Context, baseURL, fileTypes string, libraryID int, query string, limit, offset int, sort []sortspec.SortLevel) (*Feed, error)
BuildLibrarySearchFeedKepub builds an acquisition feed with search results using KePub download links.
func (*Service) BuildLibrarySeriesBooksFeed ¶
func (svc *Service) BuildLibrarySeriesBooksFeed(ctx context.Context, baseURL, fileTypes string, libraryID, seriesID, limit, offset int, sort []sortspec.SortLevel) (*Feed, error)
BuildLibrarySeriesBooksFeed builds an acquisition feed with books in a series.
func (*Service) BuildLibrarySeriesBooksFeedKepub ¶
func (svc *Service) BuildLibrarySeriesBooksFeedKepub(ctx context.Context, baseURL, fileTypes string, libraryID, seriesID, limit, offset int, sort []sortspec.SortLevel) (*Feed, error)
BuildLibrarySeriesBooksFeedKepub builds an acquisition feed with books in a series using KePub download links.
func (*Service) BuildLibrarySeriesListFeed ¶
func (svc *Service) BuildLibrarySeriesListFeed(ctx context.Context, baseURL, fileTypes string, libraryID, limit, offset int) (*Feed, error)
BuildLibrarySeriesListFeed builds a navigation feed listing all series in a library.
func (*Service) ListAuthorsInLibrary ¶
func (svc *Service) ListAuthorsInLibrary(ctx context.Context, libraryID, limit, offset int) ([]AuthorInfo, int, error)
ListAuthorsInLibrary lists distinct authors in a library with book counts.
func (*Service) ListBooksByAuthor ¶
func (svc *Service) ListBooksByAuthor(ctx context.Context, libraryID int, authorName string, fileTypes []string, limit, offset int, sort []sortspec.SortLevel) ([]*models.Book, int, error)
ListBooksByAuthor lists books by a specific author in a library.
Implementation note: the original version queried for unsorted book IDs, paginated those IDs in Go, then fetched the entire library's books with sort applied and filtered down to the paginated IDs. That pattern broke pagination (page 1 wasn't "first N in sort order") and scaled poorly. We now look up the person row (library-scoped via peopleService.RetrievePerson) and delegate to the books service's PersonID filter, which lets SQL apply the sort, limit, and offset together.
Name-match semantics change: the old implementation used `p.name = ?` (case-sensitive under SQLite's default BINARY collation), whereas peopleService.RetrievePerson uses `LOWER(p.name) = LOWER(?)`. This aligns with the creation-side invariant — `persons` has a UNIQUE index on (name COLLATE NOCASE, library_id), so there's at most one person per (library, name) regardless of case, and the canonical casing is whatever was first inserted. Any author URL Shisho generates itself is already canonical; the change only affects OPDS clients that hand-craft URLs with non-canonical casing — those now resolve instead of 404ing.