Documentation
¶
Index ¶
- func CanonicalConfigPath(home string) string
- func CreateExampleConfig(path string) error
- func DefaultLibraryPath(home string) string
- func DownloadAliasNames() []string
- func EnsureLibraryExists() error
- func ExtractFileName(path string) string
- func ExtractTopicFromWikipediaFilename(filename string) string
- func FindArticleInAnyFile(articleTitle string) string
- func FormatSize(bytes int64) string
- func GetLibraryFile(name string) (string, error)
- func GetLibraryPath() string
- func HasArticle(zimPath, articleTitle string) bool
- func IsInteractive() bool
- func NormalizeZIMURL(raw string) string
- func OpenZIM(path string) (*zim.File, error)
- func PipeThrough(content string) error
- func RemoveFromLibrary(name string) error
- func RenderHTML(data []byte, width int) (string, error)
- func ResolveEntry(z *zim.File, url string) (zim.DirectoryEntry, bool)
- func ResolveZIMPath(pathOrName string) (string, error)
- func ResolveZIMPathWithArticleContext(pathOrName, articleTitle string) (string, error)
- func ResolveZIMPathWithInteraction(pathOrName string) (string, error)
- func SelectFromMultipleMatches(pattern string, matches []LibraryEntry) (string, error)
- func StripHTML(content []byte) string
- func TruncateString(s string, maxLen int) string
- type AmbiguousMatchError
- type CatalogEntry
- type Config
- type ConfigLoader
- type DirectoryEntry
- type DownloadAlias
- type IndexConfig
- type Library
- func (l *Library) Ensure() error
- func (l *Library) List() ([]LibraryEntry, error)
- func (l *Library) Remove(name string) (string, error)
- func (l *Library) Resolve(pathOrName string) (string, error)
- func (l *Library) ResolveWebPath(requested, startup string) (string, error)
- func (l *Library) Root() string
- type LibraryConfig
- type LibraryEntry
- type LoadedConfig
- type Namespace
- type SearchConfig
- type ServerConfig
- type ZIMFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalConfigPath ¶
func CreateExampleConfig ¶
func DefaultLibraryPath ¶
func DownloadAliasNames ¶
func DownloadAliasNames() []string
DownloadAliasNames returns supported shortcuts in display order.
func EnsureLibraryExists ¶
func EnsureLibraryExists() error
EnsureLibraryExists creates the library directory if it doesn't exist
func ExtractFileName ¶
ExtractFileName extracts a readable name from a file path
func ExtractTopicFromWikipediaFilename ¶
ExtractTopicFromWikipediaFilename extracts the topic from Wikipedia filenames e.g., "wikipedia_en_comics_nopic_2025-08.zim" -> "comics"
func FindArticleInAnyFile ¶
FindArticleInAnyFile searches all ZIM files for a specific article
func FormatSize ¶
FormatSize formats byte size to human readable format
func GetLibraryFile ¶
GetLibraryFile returns the full path to a ZIM file in the library
func GetLibraryPath ¶
func GetLibraryPath() string
GetLibraryPath returns the path to the ZIM library directory
func HasArticle ¶
HasArticle checks if a ZIM file contains a specific article
func IsInteractive ¶
func IsInteractive() bool
IsInteractive checks if we're running in an interactive terminal
func NormalizeZIMURL ¶
NormalizeZIMURL converts Kiwix Metalink acquisition URLs to the archive URL.
func PipeThrough ¶
PipeThrough sends content through a pager (bat or less) when stdout is a TTY. Falls back to direct printing when piped or no pager is available.
func RemoveFromLibrary ¶
RemoveFromLibrary removes a ZIM file from the library
func RenderHTML ¶
RenderHTML converts HTML content to styled terminal output using glamour. It first converts HTML to markdown, then renders with glamour for rich display.
func ResolveEntry ¶
ResolveEntry tries to find a ZIM directory entry by URL, attempting namespace C then A, and retrying with underscore/space variants of the URL.
Fallback order:
- Namespace C, original URL
- Namespace A, original URL
- Namespace C, underscores → spaces
- Namespace A, underscores → spaces
- Namespace C, spaces → underscores
- Namespace A, spaces → underscores
func ResolveZIMPath ¶
ResolveZIMPath resolves a ZIM file path - checks library first, then treats as regular path
func ResolveZIMPathWithArticleContext ¶
ResolveZIMPathWithArticleContext resolves a ZIM path using article context for smarter selection
func ResolveZIMPathWithInteraction ¶
ResolveZIMPathWithInteraction resolves a ZIM path and handles ambiguous matches interactively
func SelectFromMultipleMatches ¶
func SelectFromMultipleMatches(pattern string, matches []LibraryEntry) (string, error)
SelectFromMultipleMatches presents a list of options and returns the selected one
func TruncateString ¶
TruncateString truncates a string to specified length with ellipsis
Types ¶
type AmbiguousMatchError ¶
type AmbiguousMatchError struct {
Pattern string
Matches []LibraryEntry
}
AmbiguousMatchError represents an error where multiple files match a pattern
func (*AmbiguousMatchError) Error ¶
func (e *AmbiguousMatchError) Error() string
type CatalogEntry ¶
type CatalogEntry struct {
Name string `json:"name"`
Flavor string `json:"flavor"`
Title string `json:"title"`
Description string `json:"description"`
Language string `json:"language"`
Size int64 `json:"size"`
Date string `json:"date"`
URL string `json:"url"`
Tags string `json:"tags"`
}
CatalogEntry represents a single ZIM file available from Kiwix.
func FetchCatalog ¶
func FetchCatalog(lang string) ([]CatalogEntry, error)
FetchCatalog returns catalog entries, using cache when fresh. Falls back to stale cache on network errors.
func FetchCatalogByName ¶
func FetchCatalogByName(ctx context.Context, name string) ([]CatalogEntry, error)
FetchCatalogByName fetches the bounded exact-name result set used by download aliases. It does not use the broad browsing cache, so a shortcut cannot be resolved from an unrelated or incomplete first page.
func ResolveCatalogEntry ¶
func ResolveCatalogEntry(entries []CatalogEntry, name, preferredFlavor string) (CatalogEntry, error)
ResolveCatalogEntry selects the newest unambiguous entry with the exact catalog name and, when requested, the preferred archive flavor.
type Config ¶
type Config struct {
Library LibraryConfig `mapstructure:"library"`
Server ServerConfig `mapstructure:"server"`
Search SearchConfig `mapstructure:"search"`
Index IndexConfig `mapstructure:"index"`
}
Config represents application configuration.
func GetConfig ¶
func GetConfig() *Config
GetConfig loads a fresh configuration for legacy callers. Configuration is intentionally not cached; cmd.App owns the configuration used by a run.
func LoadConfig ¶
type ConfigLoader ¶
ConfigLoader owns all inputs used to load configuration. Empty fields use the process defaults; tests can provide every field to avoid global state.
func NewConfigLoader ¶
func NewConfigLoader() ConfigLoader
func (ConfigLoader) Load ¶
func (l ConfigLoader) Load() (*LoadedConfig, error)
type DirectoryEntry ¶
type DirectoryEntry = zim.DirectoryEntry
DirectoryEntry represents a ZIM directory entry
type DownloadAlias ¶
DownloadAlias defines one supported catalog-backed CLI shortcut.
func LookupDownloadAlias ¶
func LookupDownloadAlias(name string) (DownloadAlias, bool)
LookupDownloadAlias returns catalog policy for a supported CLI shortcut.
type IndexConfig ¶
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
Library owns access to the configured ZIM library root.
func NewLibrary ¶
func (*Library) List ¶
func (l *Library) List() ([]LibraryEntry, error)
func (*Library) Remove ¶
Remove deletes a resolved archive only when its canonical path is contained by the configured library root.
func (*Library) Resolve ¶
Resolve finds a CLI archive using the configured library before accepting an explicit path. Explicit paths remain supported for the CLI; web callers must use ResolveWebPath.
func (*Library) ResolveWebPath ¶
ResolveWebPath allows only an existing ZIM under the configured root or the explicit startup file. Canonical paths prevent traversal and symlink escapes.
type LibraryConfig ¶
type LibraryConfig struct {
Path string `mapstructure:"path"`
}
type LibraryEntry ¶
LibraryEntry represents a ZIM file in the library
func ListLibraryFiles ¶
func ListLibraryFiles() ([]LibraryEntry, error)
ListLibraryFiles returns all ZIM files in the library
type LoadedConfig ¶
LoadedConfig records both the merged configuration and the file that supplied it. Source is empty when defaults and environment variables are used alone.
type SearchConfig ¶
type ServerConfig ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package embeddings provides reusable semantic embedding generation using Model2Vec.
|
Package embeddings provides reusable semantic embedding generation using Model2Vec. |