archivebook

package
v1.2.26 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMediaTypes = []string{
	".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".svg", ".avif",
}

DefaultMediaTypes 是 Comigo 默认展示的压缩包内媒体类型。

Functions

func IsSupportMedia

func IsSupportMedia(checkPath string, mediaTypes []string) bool

IsSupportMedia 判断压缩包内文件是否应作为页面展示。

func ReadPage

func ReadPage(ctx context.Context, filename string, source io.Reader, nameInArchive string, opt Options) ([]byte, error)

ReadPage 读取压缩包内指定文件的原始字节。

func SortPages

func SortPages(pages []Page, sortBy string)

SortPages 按 Comigo 的页面排序规则排序。

Types

type Options

type Options struct {
	BookID       string
	TextEncoding string
	MediaTypes   []string
	ExcludeDirs  []string
	SortBy       string
}

Options 控制压缩包扫描和读取行为。

type Page

type Page struct {
	Name    string    `json:"name"`
	Path    string    `json:"path"`
	Size    int64     `json:"size"`
	ModTime time.Time `json:"mod_time"`
	URL     string    `json:"url"`
	PageNum int       `json:"page_num"`
}

Page 描述压缩包内可阅读的单个媒体文件。 该结构保持轻量,方便服务端模板与 wasm 前端共同使用。

func ListPages

func ListPages(ctx context.Context, filename string, source io.ReaderAt, size int64, opt Options) ([]Page, error)

ListPages 从压缩包流中扫描可阅读页面。 source 需要支持 ReaderAt 与 Seeker,bytes.Reader、os.File、远程缓存 Reader 均可适配。

Jump to

Keyboard shortcuts

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