db

package
v0.0.0-...-fc280d6 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: BSD-2-Clause-Views Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheDirectory = iota
	CacheRelationPage
	CacheImagePage
	CacheChapter
	CachePath

	CacheTotal
)
View Source
const (
	RelationViewChapter uint8 = iota
	RelationViewGrouping
	RelationViewOneShot
	RelationViewPairing
	RelationViewTotal
)
View Source
const (
	DateLayout      = "Jan 2, 2006"
	DateLayoutIndex = "Jan 2 '06"
)
View Source
const (
	DebugImageIndex uint8 = iota
	DebugImagePath
	DebugImageID
	DebugImageIDExt
)
View Source
const (
	MissingCoverPath = "/assets/cover_missing_medium.png"
)
View Source
const Revision = 2

Revision is the revision of the database format

Variables

View Source
var (
	ErrAlreadyOpen = errors.New("database already open")
	ErrClosed      = errors.New("database closed")
)
View Source
var (
	ErrChapterExists = errors.New("chapter already exists")
)
View Source
var (
	ErrNotSatisfied = errors.New("job does not satisfy this chapter")
)

Functions

func ResolveFilenameFromPath

func ResolveFilenameFromPath(pathRel string) string

ResolveFilenameFromPath resolves an image's file name from a pathRel string

func SanitisePath

func SanitisePath(pathRel string) (string, error)

SanitisePath sanitises a pathRel obtained from the website

func StringToHash

func StringToHash(str string) *[sha256.Size]byte

Types

type Acquisition

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

func DebugImage

func DebugImage(t uint8) (a Acquisition)

DebugImage returns an Acquisition struct for specified image database

func DebugInternal

func DebugInternal() (a Acquisition)

DebugInternal returns an Acquisition struct for the internal database

func DebugRelation

func DebugRelation(relType RelationType, ext bool) (a Acquisition)

DebugRelation returns an Acquisition struct for specified relation, where ext is whether the extended index is acquired

type Chapter

type Chapter struct {
	// Title is the title of the chapter
	Title string `json:"title"`
	// Creation records the time of creation of the chapter in database
	Creation time.Time `json:"creation"`
	// Release records the date/time of release of the chapter
	Release time.Time `json:"release"`
	// ReleasePost is the URL of the release post of the chapter
	ReleasePost string `json:"release_post"`
	// Images is an index to pathRel mapping
	Images ChapterImages `json:"images"`
	// Order stores the order of indexes
	Order ChapterIndexOrder `json:"order"`
	// contains filtered or unexported fields
}

Chapter represents a chapter's metadata

func (*Chapter) Diff

func (c *Chapter) Diff(images ChapterImages, order ChapterIndexOrder) bool

Diff returns whether chapter contents is identical

func (*Chapter) DiffPath

func (c *Chapter) DiffPath(pathToIndex PendingChapterImages, order ChapterIndexOrder) bool

DiffPath diffs against path to index mapping instead

type ChapterExt

type ChapterExt struct {
	Anthologies []ChapterRelation `json:"anthologies"`
	Doujins     []ChapterRelation `json:"doujins"`
	Issues      []ChapterRelation `json:"issues"`
	Series      []ChapterRelation `json:"series"`
	Authors     []ChapterRelation `json:"authors"` // note that chapters inherit authors from their series
	Scanlators  []ChapterRelation `json:"scanlators"`
	Tags        []ChapterRelation `json:"tags"`
	Pairings    []ChapterRelation `json:"pairings"`

	// Xattr are extended attributes for internal housekeeping data
	Xattr map[string]any `json:"-"`
}

ChapterExt are scalable extension data of a chapter

func (*ChapterExt) Has

func (ext *ChapterExt) Has(relType RelationType, rel ChapterRelation) bool

Has returns whether a ChapterExt already has a relation

func (*ChapterExt) InheritAuthors

func (ext *ChapterExt) InheritAuthors(s *Instance) error

InheritAuthors inherits authors from series

func (*ChapterExt) Removed

func (ext *ChapterExt) Removed() bool

Removed returns whether chapter is recorded to have been removed from dynasty scans

type ChapterHistory

type ChapterHistory map[time.Time]struct {
	ChapterImages
	ChapterIndexOrder
}

ChapterHistory are snapshots of the chapter at the time of change, appended to when the chapter is amended

type ChapterImages

type ChapterImages map[string]string

ChapterImages are index to image mapping in a chapter

type ChapterIndexOrder

type ChapterIndexOrder []string

ChapterIndexOrder is a slice storing order of chapter image indexes

type ChapterRelation

type ChapterRelation struct {
	Relation string
	Category string
}

ChapterRelation stores the relation name and category name of a chapter relation in ChapterExt

type CompletionState

type CompletionState uint8
const (
	CompletionAbandoned CompletionState = iota
	CompletionCancelled
	CompletionCompleted
	CompletionDropped
	CompletionLicensed
	CompletionOnHiatus
	CompletionOnHold
	CompletionOngoing
	CompletionRemoved
	CompletionTotal
)

func (CompletionState) String

func (c CompletionState) String() string

type CompletionStates

type CompletionStates [CompletionTotal]bool

func (CompletionStates) All

All returns all CompletionState available in CompletionStates

func (CompletionStates) Has

Has returns whether CompletionState has a specific CompletionState

func (CompletionStates) String

func (s CompletionStates) String() string

type Debug

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

func (*Debug) Delete

func (d *Debug) Delete(key DebugPayload) error

func (*Debug) Get

func (d *Debug) Get(key DebugPayload) (DebugPayload, error)

func (*Debug) Has

func (d *Debug) Has(key DebugPayload) (bool, error)

func (*Debug) List

func (d *Debug) List() ([]DebugPayload, error)

func (*Debug) Put

func (d *Debug) Put(key, value DebugPayload) error

func (*Debug) Stats

func (d *Debug) Stats() (leveldb.DBStats, error)

type DebugPayload

type DebugPayload []byte

func (DebugPayload) String

func (d DebugPayload) String() string

type DirectoryPageCache

type DirectoryPageCache struct {
	Index []string
	Body  map[string][]RelationLink
	Cover map[string]string
}

type ImageIDExt

type ImageIDExt struct {
	// Relations are direct image relations associated with the image
	Relations map[RelationReference]bool `json:"relations,omitempty"`
	// Source is the source of an image
	Source string `json:"source,omitempty"`
	// Creation is the creation time of the image on dynasty scans
	Creation *time.Time `json:"creation,omitempty"`
}

func (ImageIDExt) RelationsSlice

func (i ImageIDExt) RelationsSlice() []RelationReference

type ImageLinkBig

type ImageLinkBig struct {
	ID      int
	Hash    string
	TagData string
}

type ImageLinkPage

type ImageLinkPage []ImageLinkBig

type ImageMeta

type ImageMeta struct {
	// Path is the path relative to dynasty scans' web root, usually with a leading slash
	Path []string `json:"path"`

	// Xattr are extended attributes for internal housekeeping data
	Xattr map[string]any `json:"-"`
}

type ImagePreviewCache

type ImagePreviewCache [imagePreviewLenRel]struct {
	ID   int
	Hash string
}

ImagePreviewCache stores 10 structs where if ID equals to or greater than zero is an image ID, otherwise indicates an unset slot

type Instance

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

func New

func New(path string) *Instance

func (*Instance) AcquireDebug

func (s *Instance) AcquireDebug(acquisition Acquisition) *Debug

AcquireDebug acquires Debug from an Acquisition struct

func (*Instance) AddImage

func (s *Instance) AddImage(data []byte) ([sha256.Size]byte, error)

AddImage hashes an image and writes it and its metadata into the store

func (*Instance) AmendChapter

func (s *Instance) AmendChapter(identifier string, images ChapterImages, order ChapterIndexOrder) error

AmendChapter amends an existing chapter unconditionally and stores a snapshot of the chapter contents and modification date

func (*Instance) AmendImageExt

func (s *Instance) AmendImageExt(id int, source *string, creation **time.Time) error

AmendImageExt amends a direct relation image's extended metadata

func (*Instance) Close

func (s *Instance) Close() error

Close closes all databases on an instance

func (*Instance) DrainSearchPrimers

func (s *Instance) DrainSearchPrimers()

DrainSearchPrimers re-initialises the search primer cache

func (*Instance) DropQueue

func (s *Instance) DropQueue() error

DropQueue drops the queue on a database level

func (*Instance) Export

func (s *Instance) Export(dir string, printer func(msg string)) error

Export exports all chapters and basic metadata to the specified directory

func (*Instance) FlushCaches

func (s *Instance) FlushCaches() error

FlushCaches flushes all caches

func (*Instance) FlushChapterCache

func (s *Instance) FlushChapterCache() error

func (*Instance) FlushImagePageCache

func (s *Instance) FlushImagePageCache() error

func (*Instance) FlushIndexCache

func (s *Instance) FlushIndexCache(relType RelationType) error

func (*Instance) FlushPathCache

func (s *Instance) FlushPathCache() error

func (*Instance) FlushRelationPageCache

func (s *Instance) FlushRelationPageCache() error

func (*Instance) GetChapter

func (s *Instance) GetChapter(identifier string) (*Chapter, error)

GetChapter returns primary metadata of a chapter

func (*Instance) GetChapterExt

func (s *Instance) GetChapterExt(identifier string) (*ChapterExt, error)

GetChapterExt returns extended metadata of a chapter

func (*Instance) GetChapterPrimer

func (s *Instance) GetChapterPrimer(identifier string) (map[string]interface{}, error)

func (*Instance) GetImage

func (s *Instance) GetImage(hash [sha256.Size]byte) ([]byte, error)

GetImage returns an image's data

func (*Instance) GetImageHashByPath

func (s *Instance) GetImageHashByPath(pathRel string) ([sha256.Size]byte, error)

GetImageHashByPath returns an image's hash by path

func (*Instance) GetImageMeta

func (s *Instance) GetImageMeta(hash [sha256.Size]byte) (ImageMeta, error)

GetImageMeta returns an image's metadata

func (*Instance) GetImageMetaByPath

func (s *Instance) GetImageMetaByPath(pathRel string) (ImageMeta, error)

GetImageMetaByPath returns an image's metadata from its pathRel

func (*Instance) GetImagePathByID

func (s *Instance) GetImagePathByID(id int) (string, error)

GetImagePathByID returns path of image by ID

func (*Instance) GetImagePreview

func (s *Instance) GetImagePreview(hash [sha256.Size]byte, big bool) ([]byte, error)

GetImagePreview returns an image's preview data (always in jpeg)

func (*Instance) GetImagesPage

func (s *Instance) GetImagesPage(rRef RelationReference, page int) (ImageLinkPage, int, error)

func (*Instance) GetIndex

func (s *Instance) GetIndex(relType RelationType, page int) (DirectoryPageCache, int, error)

func (*Instance) GetPathHash

func (s *Instance) GetPathHash(pathRel string) (*[sha256.Size]byte, error)

func (*Instance) GetQueue

func (s *Instance) GetQueue() (*Queue, error)

GetQueue gets the state of the current queue from disk

func (*Instance) GetRelationPage

func (*Instance) HasImage

func (s *Instance) HasImage(hash [sha256.Size]byte) (bool, error)

HasImage returns whether an image exists

func (*Instance) ImageExt

func (s *Instance) ImageExt(id int) (ImageIDExt, error)

ImageExt returns extended metadata of a direct relation image

func (*Instance) MakeSearchPrimer

func (s *Instance) MakeSearchPrimer(results []SearchResult, r *SearchRequest) map[string]interface{}

MakeSearchPrimer generates a search primer from a search result slice

func (*Instance) Open

func (s *Instance) Open() error

Open opens all databases on an instance; cannot be used if already open

func (*Instance) PutAnthology

func (s *Instance) PutAnthology(relation, category, identifier string, clear bool) error

PutAnthology adds an anthology relation

func (*Instance) PutAuthor

func (s *Instance) PutAuthor(relation, category, identifier string, clear bool) error

PutAuthor adds an author relation

func (*Instance) PutChapter

func (s *Instance) PutChapter(identifier, title, releasePost string, images ChapterImages, order ChapterIndexOrder, release time.Time) error

PutChapter adds a new chapter with unique identifier string found in the URLs, with specified images and release date

func (*Instance) PutDoujin

func (s *Instance) PutDoujin(relation, category, identifier string, clear bool) error

PutDoujin adds a doujin relation

func (*Instance) PutImageID

func (s *Instance) PutImageID(id int, path string) error

PutImageID puts image ID to path reference

func (*Instance) PutIssue

func (s *Instance) PutIssue(relation, category, identifier string, clear bool) error

PutIssue adds an issue relation

func (*Instance) PutPairing

func (s *Instance) PutPairing(relation, category, identifier string, clear bool) error

PutPairing adds a pairing relation

func (*Instance) PutRelationOrder

func (s *Instance) PutRelationOrder(rRef RelationReference, order []string) error

PutRelationOrder puts an order slice to a relation

func (*Instance) PutScanlator

func (s *Instance) PutScanlator(relation, category, identifier string, clear bool) error

PutScanlator adds a scanlator relation

func (*Instance) PutSeries

func (s *Instance) PutSeries(relation, category, identifier string, clear bool) error

PutSeries adds a series relation

func (*Instance) PutTag

func (s *Instance) PutTag(relation, category, identifier string, clear bool) error

PutTag adds a tag relation

func (*Instance) Relation

func (s *Instance) Relation(rRef RelationReference) (*Relation, error)

Relation returns a relation's base metadata

func (*Instance) RelationAddImage

func (s *Instance) RelationAddImage(rRef RelationReference, image int) error

RelationAddImage adds a direct image reference to a relation

func (*Instance) RelationDeduplicateOrder

func (s *Instance) RelationDeduplicateOrder() error

RelationDeduplicateOrder de-duplicates the order slice of relations; this is necessary because the final page of any relation contains a duplicate entry as its first entry

func (*Instance) RelationExt

func (s *Instance) RelationExt(rRef RelationReference) (*RelationExt, error)

RelationExt returns a relation's extended metadata

func (*Instance) RelationSortImages

func (s *Instance) RelationSortImages() error

RelationSortImages sorts direct relation images

func (s *Instance) ResolveRelationLink(rRef RelationReference) (RelationLink, error)

ResolveRelationLink resolves a relation's RelationLink; avoid this method unless the Relation it fetches is not needed for anything else

func (*Instance) Scrub

func (s *Instance) Scrub() error

Scrub performs some miscellaneous database maintenance items

func (*Instance) Search

func (s *Instance) Search(r *SearchRequest) ([]SearchResult, error)

Search returns up to searchEntryLimit SearchResult matching the SearchRequest, or nil if the SearchRequest is invalid

func (*Instance) SearchInit

func (s *Instance) SearchInit() error

SearchInit loads search-related data into memory

func (*Instance) SearchPrimer

func (s *Instance) SearchPrimer(r *SearchRequest, page int) (map[string]interface{}, int, error)

SearchPrimer returns a search primer from a SearchRequest

func (*Instance) SetImagePath

func (s *Instance) SetImagePath(hash [sha256.Size]byte, pathRel string) error

SetImagePath sets an image hash's associated path

func (*Instance) SetImageRelation

func (s *Instance) SetImageRelation(id int, rRef RelationReference, clear bool) error

SetImageRelation creates a direct association between a direct relation image and a relation

func (*Instance) SetRemovedChapter

func (s *Instance) SetRemovedChapter(identifier string, removed bool) error

SetRemovedChapter sets the removed extended attribute of a chapter

func (*Instance) Stats

func (s *Instance) Stats() (Stats, error)

Stats returns a copy of system-wide stats

func (*Instance) StoreQueue

func (s *Instance) StoreQueue(queue *Queue) error

StoreQueue stores the state of the current queue on disk

func (*Instance) Suggest

func (s *Instance) Suggest(substr string) Suggest

Suggest suggests up to suggestLimit relations from a substring

func (*Instance) UpdateAnthology

func (s *Instance) UpdateAnthology(relation string, alias, tag, pairing, author, doujin []string, name, description *string, completion *CompletionStates) error

UpdateAnthology updates the metadata of an anthology

func (*Instance) UpdateAuthor

func (s *Instance) UpdateAuthor(relation string, alias []string, name, url, description *string) error

UpdateAuthor updates the metadata of an author; image can be set separately

func (*Instance) UpdateDoujin

func (s *Instance) UpdateDoujin(relation string, alias, tag, pairing []string, name, description *string) error

UpdateDoujin updates the metadata of a doujin; image can be set separately

func (*Instance) UpdateImageExt

func (s *Instance) UpdateImageExt(id int, f func(extRef *ImageIDExt)) error

UpdateImageExt provides a reference to an ImageIDExt struct to update

func (*Instance) UpdateIssue

func (s *Instance) UpdateIssue(relation string, alias, author []string, name, category *string, completion *CompletionStates) error

UpdateIssue updates the metadata of an issue; note that completion state is set as-is unconditionally as it is optional

func (*Instance) UpdatePairing

func (s *Instance) UpdatePairing(relation string, doujin, alias []string, name, category, description *string) error

UpdatePairing updates the metadata of a pairing; image can be set separately

func (*Instance) UpdateScanlator

func (s *Instance) UpdateScanlator(relation string, alias []string, name, url, description *string) error

UpdateScanlator updates the metadata of a scanlator; category is a chapter to category map; image can be set separately

func (*Instance) UpdateSeries

func (s *Instance) UpdateSeries(relation string, chapterCategory map[string][]RelationChapterLink, chapterCategoryOrder, alias, tag, pairing, author, doujin []string, name, description *string, completion *CompletionStates) error

UpdateSeries updates the metadata of a series; category is a chapter to category name map; image can be set separately

func (*Instance) UpdateTag

func (s *Instance) UpdateTag(relation string, alias []string, name, description *string) error

UpdateTag updates the metadata of a tag; image can be set separately

type Job

type Job struct {
	Path     string     `json:"path"`
	Source   string     `json:"source,omitempty"`
	Creation *time.Time `json:"creation,omitempty"`
	ID       int        `json:"id,omitempty"`

	// Satisfies are chapter identifiers that Job satisfies on completion
	Satisfies map[string]bool `json:"-"`
	// Relation are pending relation operations for current image
	Relation []*RelOp `json:"-"`
	// contains filtered or unexported fields
}

Job is a pending image download job, uniquely identified by its path in place of its to-be-acquired digest

func (*Job) Finalise

func (j *Job) Finalise(data []byte) error

Finalise commits the image into the database and completes its satisfaction information

func (*Job) Try

func (j *Job) Try() (bool, error)

Try tries to commit image relations to database by reusing an existing image of the same pathRel

type Page

type Page struct {
	Path  string `json:"image"`
	Index string `json:"name"`
}

Page is information of a page, appearing in the web pages

type Pages

type Pages []Page

Pages can be marshalled into from a partial

type PendingChapter

type PendingChapter struct {
	Title       string      `json:"title"`
	Identifier  string      `json:"identifier"`
	Release     time.Time   `json:"release"`
	ReleasePost string      `json:"release_post"`
	Ext         *ChapterExt `json:"ext"`

	// SatisfiedBy are jobs that satisfy the pending chapter
	SatisfiedBy map[string]bool `json:"satisfied_by"`
	// Satisfied is a ChapterImages map containing already satisfied images
	Satisfied ChapterImages `json:"satisfied"`
	// Amend stores whether the chapter should be an amendment
	Amend bool `json:"amend"`
	// PathToIndex is a relative path to index map used to construct the index to hash map on satisfaction
	PathToIndex PendingChapterImages `json:"-"`
	// Order is identical to the Order field in Chapter
	Order ChapterIndexOrder `json:"-"`
}

PendingChapter is a chapter pending satisfaction from a slice of Job

type PendingChapterImages

type PendingChapterImages map[string]string

PendingChapterImages is a relative path to index map storing a pending chapter's images

type Queue

type Queue struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Queue) CommitSatisfied

func (q *Queue) CommitSatisfied() error

CommitSatisfied commits all fully satisfied PendingChapter and direct image relations

func (*Queue) Dequeue

func (q *Queue) Dequeue() *Job

Dequeue removes an entry from the queue and returns it; the item being returned is undefined behaviour and thus shall not be relied on for order; trying to dequeue an empty queue returns nil

func (*Queue) Drop

func (q *Queue) Drop()

Drop drops the entire queue

func (*Queue) Dump

func (q *Queue) Dump(writer io.Writer) error

Dump dumps queue content in JSON to a writer

func (*Queue) DumpChapter

func (q *Queue) DumpChapter(writer io.Writer) error

DumpChapter dumps pending chapters in JSON to a writer

func (*Queue) DumpDirect

func (q *Queue) DumpDirect(writer io.Writer) error

DumpDirect dumps pending direct image relations in JSON to a writer

func (*Queue) DumpIDCache

func (q *Queue) DumpIDCache(writer io.Writer) error

DumpIDCache dumps the ID cache in JSON to a writer

func (*Queue) HasChapter

func (q *Queue) HasChapter(identifier string) bool

HasChapter returns whether the Queue already holds a PendingChapter with the specified identifier

func (*Queue) ID

func (q *Queue) ID(id int) (string, bool)

ID returns the in-queue pathRel of an ID

func (*Queue) PutChapter

func (q *Queue) PutChapter(identifier, title, releasePost string, pathToIndex PendingChapterImages, order ChapterIndexOrder, release time.Time) bool

PutChapter adds a PendingChapter to the Queue

func (*Queue) PutChapterAmend

func (q *Queue) PutChapterAmend(identifier string, pathToIndex PendingChapterImages, order ChapterIndexOrder) bool

PutChapterAmend adds an amending PendingChapter to the Queue

func (*Queue) PutDirect

func (q *Queue) PutDirect(id int, rRef RelationReference)

PutDirect adds a direct image relation to the Queue

func (*Queue) PutRelOp

func (q *Queue) PutRelOp(pathRel string, op RelOp) bool

PutRelOp registers a relation operation on a queued Job

func (*Queue) Queue

func (q *Queue) Queue(pathRel, source string, creation time.Time, identifier string, id int)

Queue adds a Job to the Queue

func (*Queue) Size

func (q *Queue) Size() int

Size returns the size of the queue

func (*Queue) SizeChapter

func (q *Queue) SizeChapter() int

SizeChapter returns the size of pending chapters

func (*Queue) SizeDirect

func (q *Queue) SizeDirect() int

SizeDirect returns the size of pending direct image relations

func (*Queue) SizeIDCache

func (q *Queue) SizeIDCache() int

SizeIDCache returns the size of the ID cache

func (*Queue) UpdateChapterExt

func (q *Queue) UpdateChapterExt(identifier string, update func(extRef *ChapterExt, relLookup func(relType RelationType) *[]ChapterRelation)) bool

UpdateChapterExt updates a PendingChapter's Ext field

type RelOp

type RelOp struct {
	Cover bool
	RelationReference
}

RelOp represents a pending relation operation for when a job is complete

type Relation

type Relation struct {
	// Name is the friendly name of the relation
	Name string `json:"name"`
	// Tag are tags associated with the relation
	Tag []string `json:"tag"`
	// Pairing are special pairing tags associated with the relation
	Pairing []string `json:"pairing"`
	// Author is optional author information
	Author []string `json:"author,omitempty"`
	// Doujin is the optional doujin information
	Doujin []string `json:"doujin,omitempty"`
	// Description is the optional description string
	Description string `json:"description,omitempty"`

	// Category is the relation's category, not applicable to all relations
	Category string `json:"category,omitempty"`
	// Cover is the pathRel of the relation's cover, not applicable to all relations
	Cover string `json:"cover,omitempty"`
	// Completion is the completion state of the relation, not applicable to all relations
	Completion CompletionStates `json:"completion"`
	// URL is the URL of the relation, not applicable to all relations
	URL string `json:"url,omitempty"`
	// Alias are alternative friendly names for the relation, not applicable to all relations
	Alias []string `json:"alias,omitempty"`
}

Relation stores base relation metadata

type RelationChapterEntry

type RelationChapterEntry struct {
	Chapter                              RelationChapterLink
	Author, Doujin, Tag, Pairing, Series []RelationLink
	ReleaseDate                          string

	// Category is set when this entry is a category spacer
	Category string
	IsCat    bool
}
type RelationChapterLink struct {
	Name       string
	Identifier string
}

type RelationExt

type RelationExt struct {
	// Chapter are category to chapter mapping associated to the relation
	Chapter map[string][]string `json:"chapter"`
	// Order is the order of chapter identifiers, does not have to exist
	Order []string `json:"order"`

	// Image are standalone image IDs associated with the relation, not applicable to all relations
	Image []int `json:"image,omitempty"`
	// ChapterCategory is a category to RelationChapterLink map, not applicable to all relations
	ChapterCategory map[string][]RelationChapterLink `json:"chapter_category"`
	// CategoryOrder is the order of all category strings
	CategoryOrder []string `json:"category_order"`

	// Xattr are extended attributes for internal housekeeping data
	Xattr map[string]interface{} `json:"-"`
}

RelationExt stores extended relation metadata

type RelationGenericEntry

type RelationGenericEntry struct {
	Name, Path string
	Cover      string
}
type RelationLink struct {
	Name string
	RelationReference
}

func (RelationLink) String

func (r RelationLink) String() string

type RelationPageCache

type RelationPageCache []RelationChapterEntry

type RelationPageCacheHeader

type RelationPageCacheHeader struct {
	// Pages is negative when relation is explicitly not paged
	Pages      [RelationViewTotal]int
	Alias      []string
	Images     *ImagePreviewCache
	Cover      string
	Completion CompletionStates
	// exact values in relation storage
	Title, Description, URL, Category string
	// these are for relation-wide relation links, should not overlap with guests
	Author, Doujin, Tags, Pairings []RelationLink
	// this is for author relations
	Series []relationLinkWithCover
	// this stores inline entries for relations with paging disabled
	Inline RelationPageCache
	// this is currently specific to series
	InlineOverride RelationPageCache
}

RelationPageCacheHeader is a header that stores relation-wide cache information

type RelationPageLinkCache

type RelationPageLinkCache []RelationGenericEntry

type RelationReference

type RelationReference struct {
	Relation string
	RelType  RelationType
}

type RelationType

type RelationType uint8
const (
	RelationAnthology RelationType = iota
	RelationDoujin
	RelationIssue
	RelationSeries
	RelationAuthor
	RelationScanlator
	RelationTag
	RelationPairing
	RelationTotal
)

func ParseRelation

func ParseRelation(str string) RelationType

ParseRelation finds the corresponding relation of str

func (RelationType) String

func (t RelationType) String() string

func (RelationType) StringPlural

func (t RelationType) StringPlural() string

type SearchRequest

type SearchRequest struct {
	SearchRequestRaw
	// contains filtered or unexported fields
}

func (SearchRequest) Advanced

func (r SearchRequest) Advanced() bool

type SearchRequestRaw

type SearchRequestRaw struct {
	Query   string   `form:"q"`
	Classes []string `form:"classes[]"`
	With    []string `form:"with[]"`
	Without []string `form:"without[]"`
	Sort    string   `form:"sort"`
}

type SearchResult

type SearchResult struct {
	Tag               bool
	Authors, Tags     []RelationLink
	Release, Creation time.Time
	RelationLink
}

func (*SearchResult) ReleaseDate

func (s *SearchResult) ReleaseDate() string

type Stats

type Stats struct {
	Search StatsSearch

	StatsCached
}

type StatsCached

type StatsCached struct {
	Chapter, Paths, Hashes int
	Relation               [RelationTotal]int
}

type StatsSearch

type StatsSearch struct {
	Cap    int
	Total  int
	Spills int
}

type Suggest

type Suggest []SuggestEntry

type SuggestEntry

type SuggestEntry struct {
	// ID stores the unique relation string of the entry
	ID string `json:"id"` // this was supposed to be an integer, but I'll have relation here instead
	// Name stores the friendly name of the relation
	Name string `json:"name"`
	// Type stores the singular title case name of the relation, with tag being General as an exception
	Type string `json:"type"`
}

Jump to

Keyboard shortcuts

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