wiki

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: ISC Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CategoryTypeImage is a type of category that tracks which pages use an image.
	CategoryTypeImage CategoryType = "image"

	// CategoryTypeModel is a metacategory that tracks which pages use a model.
	CategoryTypeModel = "model"

	// CategoryTypePage is a metacategory that tracks which pages reference another page.
	CategoryTypePage = "page"
)

Variables

This section is empty.

Functions

func AvailableBaseWikis added in v0.2.14

func AvailableBaseWikis() []string

AvailableBaseWikis returns a list of available embedded base wikis.

func CheckImageMagickAvailable added in v0.2.39

func CheckImageMagickAvailable() error

CheckImageMagickAvailable checks if imagemagick is available

func CheckLibvipsAvailable added in v0.2.39

func CheckLibvipsAvailable() error

CheckLibvipsAvailable checks if libvips is available via vips command

func CreateWiki added in v0.2.14

func CreateWiki(path, basePath string, opts CreateWikiOpts) error

CreateWiki creates a new wiki at the specified path using a base wiki directory.

func CreateWikiFS added in v0.2.14

func CreateWikiFS(path string, fsys fs.FS, opts CreateWikiOpts) error

CreateWiki creates a new wiki at the specified path using a base wiki fs.

func CreateWikiFromResource added in v0.2.14

func CreateWikiFromResource(path, resourceName string, opts CreateWikiOpts) error

CreateWikiFromResource creates a new wiki at the specified path using a base wiki resource.

func DisplayType added in v0.2.22

func DisplayType(display any) string

DisplayType returns the type of display passed. This is useful for JSON encoding, as Display interfaces have no member to indicate their type. The return value is one of: "page", "file", "image", "cat_posts", "error", "redirect".

func GetImageDimensionsFromFile added in v0.2.39

func GetImageDimensionsFromFile(path string) (width, height int, err error)

GetImageDimensionsFromFile efficiently reads image dimensions from file header without loading the full image

func SortAuthor added in v0.2.0

func SortAuthor(p, q Sortable) bool

SortAuthor is a SortFunc for sorting items alphabetically by author.

func SortCreated added in v0.2.0

func SortCreated(p, q Sortable) bool

SortCreated is a SortFunc for sorting items by creation time.

func SortDimensions added in v0.2.0

func SortDimensions(p, q Sortable) bool

SortDimensions is a SortFunc for sorting images by their dimensions.

func SortModified added in v0.2.0

func SortModified(p, q Sortable) bool

SortModified is a SortFunc for sorting items by modification time.

func SortTitle added in v0.2.0

func SortTitle(p, q Sortable) bool

SortTitle is a SortFunc for sorting items alphabetically by title.

Types

type AutoImageProcessor added in v0.2.39

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

AutoImageProcessor tries processors in order: libvips -> imagemagick -> pure go

func NewAutoImageProcessor added in v0.2.39

func NewAutoImageProcessor(opts ImageProcessorOptions) *AutoImageProcessor

NewAutoImageProcessor creates a processor that tries libvips -> imagemagick -> pure go

func (*AutoImageProcessor) GetStats added in v0.2.39

func (c *AutoImageProcessor) GetStats() ProcessorStats

GetStats returns processor usage statistics

func (*AutoImageProcessor) ResizeImageDirect added in v0.2.39

func (c *AutoImageProcessor) ResizeImageDirect(inputPath, outputPath string, width, height, quality int) error

ResizeImageDirect resizes directly from file to file without loading into memory

type Category

type Category struct {

	// category path
	Path string `json:"-"`

	// category filename, including the .cat extension
	File string `json:"file"`

	// category name without extension
	Name   string `json:"name,omitempty"`
	FileNE string `json:"file_ne,omitempty"` // alias for consistency

	// human-readable category title
	Title string `json:"title,omitempty"`

	// number of posts per page when displaying as posts
	// (@category.per_page)
	PerPage int `json:"per_page,omitempty"`

	// time when the category was created
	Created     *time.Time `json:"created,omitempty"`
	CreatedHTTP string     `json:"created_http,omitempty"` // HTTP formatted

	// time when the category was last modified.
	// this is updated when pages are added and deleted
	Modified     *time.Time `json:"modified,omitempty"`
	ModifiedHTTP string     `json:"modified_http,omitempty"` // HTTP formatted

	// time when the category metafile was last read.
	Asof *time.Time `json:"asof,omitempty"`

	// pages in the category. keys are filenames
	Pages map[string]CategoryEntry `json:"pages,omitempty"`

	// when true, the category is preserved even when no pages remain
	Preserve bool `json:"preserve,omitempty"`

	// if applicable, this is the type of special category.
	// for normal categories, this is empty
	Type CategoryType `json:"type,omitempty"`

	// for CategoryTypePage, this is the info for the tracked page
	PageInfo *wikifier.PageInfo `json:"page_info,omitempty"`

	// for CategoryTypeModel, this is the info for the tracked model
	ModelInfo *wikifier.ModelInfo `json:"model_info,omitempty"`

	// for CategoryTypeImage, this is the info for the tracked image
	ImageInfo *struct {
		Width  int `json:"width,omitempty"`
		Height int `json:"height,omitempty"`
	} `json:"image_info,omitempty"`
	// contains filtered or unexported fields
}

A Category is a collection of pages pertaining to a topic.

A page can belong to many categories. Category memberships and metadata are stored in JSON manifests.

func (*Category) AddPage

func (cat *Category) AddPage(page *wikifier.Page)

AddPage adds a page to a category.

If the page already belongs and any information has changed, the category is updated.

func (*Category) Exists

func (cat *Category) Exists() bool

Exists returns whether a category currently exists.

func (*Category) IsSpecial added in v0.3.4

func (cat *Category) IsSpecial() bool

IsSpecial returns true if this is a special category (image, model, or page)

type CategoryEntry

type CategoryEntry struct {

	// time at which the page metadata in this category file was last updated.
	// this is compared against page file modification time
	Asof *time.Time `json:"asof,omitempty"`

	// embedded page info
	// note this info is accurate only as of the Asof time
	wikifier.PageInfo

	// for CategoryTypeImage, an array of image dimensions used on this page.
	// dimensions are guaranteed to be positive integers. the number of elements will
	// always be even, since each occurrence of the image produces two (width and then height)
	Dimensions [][]int `json:"dimensions,omitempty"`

	// for CategoryTypePage, an array of line numbers on which the tracked page is
	// referenced on the page described by this entry
	Lines []int `json:"lines,omitempty"`
}

A CategoryEntry describes a page that belongs to a category.

type CategoryInfo

type CategoryInfo struct {
	*Category
}

CategoryInfo represents metadata associated with a category.

type CategoryManager added in v0.3.4

type CategoryManager interface {
	AddPage(page *wikifier.Page, dimensions [][]int, lines []int)
	AddImage(imageName string, page *wikifier.Page, dimensions [][]int)
	Update()
	Write()
	Exists() bool
	ShouldPurge() bool
}

CategoryManager provides operations for category management

type CategoryType

type CategoryType string

CategoryType describes the type of a Category.

type Check added in v0.2.60

type Check struct {
	PageName string
	Func     func() bool // returns true if validation now passes
	Warning  string
	Pos      wikifier.Position
}

Check represents a validation check to retry later

type CommitOpts added in v0.2.0

type CommitOpts struct {

	// Comment is the commit description.
	Comment string

	// Name is the fullname of the user committing changes.
	Name string

	// Email is the email address of the user committing changes.
	Email string

	// Time is the timestamp to associate with the revision.
	// If unspecified, current time is used.
	Time time.Time
}

CommitOpts describes the options for a wiki revision.

type CreateWikiOpts added in v0.2.14

type CreateWikiOpts struct {
	WikiName     string
	TemplateName string
	MainPage     string
	ErrorPage    string
}

type DisplayCategoryPosts

type DisplayCategoryPosts struct {

	// DisplayPage results
	// overrides the Category Pages field
	Pages []DisplayPage `json:"pages,omitempty"`

	// the page number (first page = 0)
	PageN int `json:"page_n"`

	// the total number of pages
	NumPages int `json:"num_pages"`

	// this is the combined CSS for all pages we're displaying
	CSS string `json:"css,omitempty"`

	// all other fields are inherited from the category itself
	*Category
}

DisplayCategoryPosts represents a category result to display.

type DisplayError

type DisplayError struct {
	// a human-readable error string. sensitive info is never
	// included, so this may be shown to users
	Error string

	// a more detailed human-readable error string that MAY contain
	// sensitive data. can be used for debugging and logging but should
	// not be presented to users
	DetailedError string

	// HTTP status code. if zero, 404 should be used
	Status int

	// if the error occurred during parsing, this is the position.
	// for all non-parsing errors, this is 0:0
	Pos wikifier.Position

	// true if the content cannot be displayed because it has
	// not yet been published for public access
	Draft bool
}

DisplayError represents an error result to display.

func (DisplayError) ErrorAsWarning added in v0.2.13

func (e DisplayError) ErrorAsWarning() wikifier.Warning

type DisplayFile

type DisplayFile struct {

	// file name relative to wiki root.
	// path delimiter '/' is always used, regardless of OS.
	File string `json:"file,omitempty"`

	// absolute file path of the file.
	// OS-specific path delimiter is used.
	Path string `json:"path,omitempty"`

	// the plain text file content
	Content string `json:"-"`

	// time when the file was last modified
	Modified *time.Time `json:"modified,omitempty"`

	// for pages/models/etc, parser warnings and error
	Warnings []wikifier.Warning `json:"parse_warnings,omitempty"`
	Error    *wikifier.Warning  `json:"parse_error,omitempty"`
}

DisplayFile represents a plain text file to display.

type DisplayImage

type DisplayImage struct {

	// basename of the scaled image file
	File string `json:"file,omitempty"`

	// absolute path to the scaled image.
	// this file should be served to the user
	Path string `json:"path,omitempty"`

	// absolute path to the full-size image.
	// if the full-size image is being displayed, same as Path
	FullsizePath string `json:"fullsize_path,omitempty"`

	// image type
	// 'png' or 'jpeg'
	ImageType string `json:"image_type,omitempty"`

	// mime 'image/png' or 'image/jpeg'
	// suitable for the Content-Type header
	Mime string `json:"mime,omitempty"`

	// bytelength of image data
	// suitable for use in the Content-Length header
	Length int64 `json:"length,omitempty"`

	// time when the image was last modified.
	// if Generated is true, this is the current time.
	// if FromCache is true, this is the modified date of the cache file.
	// otherwise, this is the modified date of the image file itself.
	Modified     *time.Time `json:"modified,omitempty"`
	ModifiedHTTP string     `json:"modified_http,omitempty"` // HTTP format for Last-Modified

	// true if the content being sered was read from a cache file.
	// opposite of Generated
	FromCache bool `json:"cached,omitempty"`

	// true if the content being served was just generated.
	// opposite of FromCache
	Generated bool `json:"generated,omitempty"`

	// true if the content generated in order to fulfill this request was
	// written to cache. this can only been true when Generated is true
	CacheGenerated bool `json:"cache_gen,omitempty"`
}

DisplayImage represents an image to display.

type DisplayPage

type DisplayPage struct {

	// name of the page relative to the pages dir, with the extension; e.g. some/page.page
	File string `json:"file,omitempty"`

	// name of the page without the extension; e.g. some/page
	Name string `json:"name,omitempty"`

	// absolute file path of the page
	Path string `json:"path,omitempty"`

	// the page content (HTML)
	Content wikifier.HTML `json:"-"`

	// time when the page was last modified.
	// if Generated is true, this is the current time.
	// if FromCache is true, this is the modified date of the cache file.
	// otherwise, this is the modified date of the page file itself.
	Modified     *time.Time `json:"modified,omitempty"`
	ModifiedHTTP string     `json:"modified_http,omitempty"` // HTTP formatted for Last-Modified

	// CSS generated for the page from style{} blocks
	CSS string `json:"css,omitempty"`

	// true if this content was read from a cache file. opposite of Generated
	FromCache bool `json:"cached,omitempty"`

	// true if the content being served was just generated on the fly.
	// opposite of FromCache
	Generated bool `json:"generated,omitempty"`

	// true if this request resulted in the writing of a new cache file.
	// this can only be true if Generated is true
	CacheGenerated bool `json:"cache_gen,omitempty"`

	// true if this request resulted in the writing of a text file.
	// this can only be true if Generated is true
	TextGenerated bool `json:"text_gen,omitempty"`

	// true if the page has not yet been published for public viewing.
	// this only occurs when it is specified that serving drafts is OK,
	// since normally a draft page instead results in a DisplayError.
	Draft bool `json:"draft,omitempty"`

	// warnings and errors produced by the parser
	Warnings []wikifier.Warning `json:"warnings,omitempty"`

	// time when the page was created, as extracted from
	// the special @page.created variable
	Created     *time.Time `json:"created,omitempty"`
	CreatedHTTP string     `json:"created_http,omitempty"` // HTTP formatted

	// name of the page author, as extracted from the special @page.author
	// variable
	Author string `json:"author,omitempty"`

	// list of categories the page belongs to, without the '.cat' extension
	Categories []string `json:"categories,omitempty"`

	// page title as extracted from the special @page.title variable, including
	// any possible HTML-encoded formatting
	FmtTitle wikifier.HTML `json:"fmt_title,omitempty"`

	// like FmtTitle except that all text formatting has been stripped.
	// suitable for use in the <title> tag
	Title string `json:"title,omitempty"`

	// page description as extracted from the special @page.desc variable.
	Description string `json:"desc,omitempty"`

	// page keywords as extracted from the special @page.keywords variable
	Keywords []string `json:"keywords,omitempty"`

	// first formatting-stripped 25 words of page, up to 150 chars
	Preview string `json:"preview,omitempty"`
}

DisplayPage represents a page result to display.

type DisplayRedirect

type DisplayRedirect struct {

	// a relative or absolute URL to which the request should redirect,
	// suitable for use in a Location header
	Redirect string
}

DisplayRedirect represents a page redirect to follow.

type ImageInfo

type ImageInfo struct {
	File       string     `json:"file"`               // filename
	Base       string     `json:"base,omitempty"`     // base name
	Width      int        `json:"width,omitempty"`    // full-size width
	Height     int        `json:"height,omitempty"`   // full-size height
	Created    *time.Time `json:"created,omitempty"`  // creation time
	Modified   *time.Time `json:"modified,omitempty"` // modify time
	Dimensions [][]int    `json:"-"`                  // dimensions used throughout the wiki
}

ImageInfo represents a full-size image on the wiki.

type ImageMagickOptions added in v0.2.39

type ImageMagickOptions struct {
	MaxConcurrent int           // max concurrent image operations
	Timeout       time.Duration // max time per image operation
	ConvertPath   string        // path to convert binary (empty = auto-detect)
	Quality       int           // JPEG quality (1-100, 0 = default)
	MaxPixels     int64         // max pixels to prevent zip bombs
}

ImageMagickOptions configures the imagemagick processor

func DefaultImageMagickOptions added in v0.2.39

func DefaultImageMagickOptions() ImageMagickOptions

DefaultImageMagickOptions returns sensible defaults

type ImageMagickProcessor added in v0.2.39

type ImageMagickProcessor struct {
	*ImageProcessor // embed for common functionality
	// contains filtered or unexported fields
}

ImageMagickProcessor handles image processing using imagemagick convert command

func NewImageMagickProcessor added in v0.2.39

func NewImageMagickProcessor(opts ImageMagickOptions) (*ImageMagickProcessor, error)

NewImageMagickProcessor creates a new imagemagick-based processor

func (*ImageMagickProcessor) GetImageDimensions added in v0.2.39

func (p *ImageMagickProcessor) GetImageDimensions(path string) (width, height int, err error)

GetImageDimensions gets image dimensions using ImageMagick identify

func (*ImageMagickProcessor) ResizeImage added in v0.2.39

func (p *ImageMagickProcessor) ResizeImage(inputPath, outputPath string, width, height int, quality int) error

ResizeImage resizes an image using ImageMagick convert

func (*ImageMagickProcessor) ResizeImageDirect added in v0.2.39

func (p *ImageMagickProcessor) ResizeImageDirect(inputPath, outputPath string, width, height, quality int) error

ResizeImageDirect implements ImageProcessorInterface - direct file-to-file processing

type ImageProcessor added in v0.2.25

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

ImageProcessor handles safe, concurrent image processing with resource limits

func GetImageProcessor added in v0.2.25

func GetImageProcessor() *ImageProcessor

GetImageProcessor returns the global image processor instance

func GetPureGoImageProcessorForWiki added in v0.2.39

func GetPureGoImageProcessorForWiki(w *Wiki) *ImageProcessor

GetPureGoImageProcessorForWiki returns an image processor configured for a specific wiki

func NewImageProcessor added in v0.2.25

func NewImageProcessor(opts ImageProcessorOptions) *ImageProcessor

NewImageProcessor creates a new image processor with the given options

func (*ImageProcessor) GetImageDimensionsSafe added in v0.2.25

func (p *ImageProcessor) GetImageDimensionsSafe(path string) (width, height int, err error)

GetImageDimensionsSafe safely gets image dimensions without loading the full image

func (*ImageProcessor) ResizeImageDirect added in v0.2.39

func (p *ImageProcessor) ResizeImageDirect(inputPath, outputPath string, width, height, quality int) error

ResizeImageDirect implements ImageProcessorInterface - file-to-file resize using pure go

type ImageProcessorInterface added in v0.2.39

type ImageProcessorInterface interface {
	// direct file-to-file processing (avoids loading into memory)
	ResizeImageDirect(inputPath, outputPath string, width, height, quality int) error
}

ImageProcessorInterface defines the common interface for all image processors

func GetImageProcessorForWiki added in v0.2.25

func GetImageProcessorForWiki(w *Wiki) ImageProcessorInterface

GetImageProcessorForWiki returns a processor configured for a specific wiki

type ImageProcessorOptions added in v0.2.25

type ImageProcessorOptions struct {
	MaxConcurrent int           // max concurrent image operations
	MaxMemoryMB   int64         // max memory per image (width * height * 4 bytes)
	Timeout       time.Duration // max time per image operation
}

ImageProcessorOptions configures the image processor

func DefaultImageProcessorOptions added in v0.2.25

func DefaultImageProcessorOptions() ImageProcessorOptions

DefaultImageProcessorOptions returns sensible defaults for cheap VPS

type MemoryMonitor added in v0.2.62

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

MemoryMonitor provides application-wide protection against memory exhaustion

func GetMemoryMonitor added in v0.2.62

func GetMemoryMonitor() *MemoryMonitor

func NewMemoryMonitor added in v0.2.62

func NewMemoryMonitor(maxConcurrency int) *MemoryMonitor

func (*MemoryMonitor) GetStats added in v0.2.62

func (m *MemoryMonitor) GetStats() (availableMB int64, activeWorkers int, maxWorkers int)

GetStats returns current memory statistics for monitoring

type ProcessorStats added in v0.2.39

type ProcessorStats struct {
	VipsSuccess        int
	VipsFailed         int
	ImageMagickSuccess int
	ImageMagickFailed  int
	PureGoUsed         int
	TotalProcessed     int
}

ProcessorStats tracks which processor is being used

type RevisionInfo added in v0.2.16

type RevisionInfo struct {
	Id      string    `json:"id"`
	Author  string    `json:"author"`
	Date    time.Time `json:"date"`
	Message string    `json:"message"`
}

RevisionInfo contains information about a specific revision.

type SizedImage

type SizedImage struct {
	// for example mydir/[email protected]
	Width, Height int    // 100, 200 (dimensions as requested)
	Scale         int    // 3 (scale as requested)
	Prefix        string // mydir
	RelNameNE     string // myimage (name without extension)
	Ext           string // png (extension)
	// contains filtered or unexported fields
}

SizedImage represents an image in specific dimensions.

func SizedImageFromName

func SizedImageFromName(name string) SizedImage

SizedImageFromName returns a SizedImage given an image name.

func (SizedImage) FullSizeName

func (img SizedImage) FullSizeName() string

FullSizeName returns the name of the full-size image.

func (SizedImage) ScaleName

func (img SizedImage) ScaleName() string

ScaleName returns the image name with dimensions and scale.

func (SizedImage) TrueHeight

func (img SizedImage) TrueHeight() int

TrueHeight returns the actual image height when the Scale is taken into consideration.

func (SizedImage) TrueName added in v0.2.0

func (img SizedImage) TrueName() string

TrueName returns the image name with true dimensions.

func (SizedImage) TrueNameNE added in v0.2.0

func (img SizedImage) TrueNameNE() string

TrueNameNE is like TrueName but without the extension.

func (SizedImage) TrueWidth

func (img SizedImage) TrueWidth() int

TrueWidth returns the actual image width when the Scale is taken into consideration.

type SortFunc added in v0.2.0

type SortFunc func(p, q Sortable) bool

SortFunc is a type for functions that can sort items.

type SortInfo added in v0.2.0

type SortInfo struct {
	Title      string
	Author     string
	Created    time.Time
	Modified   time.Time
	Dimensions []int
}

SortInfo is the data returned from Sortable items for sorting wiki resources.

type Sortable added in v0.2.0

type Sortable interface {
	SortInfo() SortInfo
}

Sortable is the interface that allows quiki to sort wiki resources.

type VipsOptions added in v0.2.39

type VipsOptions struct {
	MaxConcurrent int           // max concurrent image operations
	Timeout       time.Duration // max time per image operation
	Quality       int           // JPEG quality (1-100)
	MaxPixels     int64         // max pixels to prevent issues
}

VipsOptions configures the libvips processor

func DefaultVipsOptions added in v0.2.39

func DefaultVipsOptions() VipsOptions

DefaultVipsOptions returns sensible defaults

type VipsProcessor added in v0.2.39

type VipsProcessor struct {
	*ImageProcessor // embed for common functionality
	// contains filtered or unexported fields
}

VipsProcessor handles image processing using libvips (requires libvips installation)

func NewVipsProcessor added in v0.2.39

func NewVipsProcessor(opts VipsOptions) (*VipsProcessor, error)

NewVipsProcessor creates a new libvips-based processor

func (*VipsProcessor) ResizeImageDirect added in v0.2.39

func (p *VipsProcessor) ResizeImageDirect(inputPath, outputPath string, width, height, quality int) error

ResizeImageDirect implements ImageProcessorInterface - direct file-to-file processing

func (*VipsProcessor) ResizeImageVips added in v0.2.39

func (p *VipsProcessor) ResizeImageVips(inputPath, outputPath string, width, height int, quality int) error

ResizeImageVips resizes an image using libvips

type Wiki

type Wiki struct {
	ConfigFile string
	Opt        wikifier.PageOpt
	Auth       *authenticator.Authenticator
	// contains filtered or unexported fields
}

A Wiki represents a quiki website.

func NewWiki

func NewWiki(path string) (*Wiki, error)

NewWiki creates a Wiki given its directory path.

func (*Wiki) AbsFilePath added in v0.2.0

func (w *Wiki) AbsFilePath(relPath string) string

AbsFilePath takes a relative path to a file within the wiki (e.g. `pages/mypage.page`), joins it with the wiki directory, and evaluates it with `filepath.Abs()`. The result is an absolute path which may or may not exist.

If the file is a symlink, it is followed. Thus, it is possible for the resulting path to exist outside the wiki directory. If that is not desired, use unresolvedAbsFilePath instead.

func (*Wiki) AddCheck added in v0.2.60

func (w *Wiki) AddCheck(pageName, warning string, pos wikifier.Position, validateFunc func() bool)

AddCheck adds a validation check - either executes immediately or defers based on pregeneration mode

func (*Wiki) AllImageFiles added in v0.2.32

func (w *Wiki) AllImageFiles() []string

AllImageFiles returns all image files in the wiki.

func (*Wiki) AllPageFiles added in v0.2.25

func (w *Wiki) AllPageFiles() []string

AllPageFiles returns all page files (public method for interfaces)

func (*Wiki) BranchNames added in v0.2.0

func (w *Wiki) BranchNames() ([]string, error)

BranchNames returns the revision branches available.

func (*Wiki) Categories

func (w *Wiki) Categories() []CategoryInfo

Categories returns info about all the models in the wiki.

func (*Wiki) CategoriesSorted added in v0.2.0

func (w *Wiki) CategoriesSorted(descend bool, sorters ...SortFunc) []CategoryInfo

CategoriesSorted returns info about all the categories in the wiki, sorted as specified. Accepted sort functions are SortTitle, SortCreated, and SortModified.

func (*Wiki) CategoryInfo

func (w *Wiki) CategoryInfo(name string) (info CategoryInfo)

CategoryInfo is an inexpensive request for info on a category.

func (*Wiki) CategoryMap

func (w *Wiki) CategoryMap() map[string]CategoryInfo

CategoryMap returns a map of model name to CategoryInfo for all models in the wiki.

func (*Wiki) CreateImageFolder added in v0.2.24

func (w *Wiki) CreateImageFolder(where, name string) (string, error)

CreateImageFolder creates a new image folder.

func (*Wiki) CreateModel added in v0.2.16

func (w *Wiki) CreateModel(title string, content []byte, commit CommitOpts) (string, error)

CreateModel creates a new model file.

func (*Wiki) CreateModelFolder added in v0.2.24

func (w *Wiki) CreateModelFolder(where, name string) (string, error)

CreateModelFolder creates a new model folder.

func (*Wiki) CreatePage added in v0.2.16

func (w *Wiki) CreatePage(where string, title string, content []byte, commit CommitOpts) (string, error)

CreatePage creates a new page file. If content is empty, a default page is created.

func (*Wiki) CreatePageFolder added in v0.2.16

func (w *Wiki) CreatePageFolder(where, name string) (string, error)

CreatePageFolder creates a new page folder.

func (*Wiki) Debug added in v0.2.0

func (w *Wiki) Debug(i ...any)

Debug logs debug info for a wiki.

func (*Wiki) Debugf added in v0.2.0

func (w *Wiki) Debugf(format string, i ...any)

Debugf logs debug info for a wiki.

func (*Wiki) DeleteFile added in v0.2.0

func (w *Wiki) DeleteFile(name string, commit CommitOpts) error

DeleteFile deletes a file in the wiki.

The filename must be relative to the wiki directory. If the file does not exist, an error is returned. If the file exists and is a symbolic link, the link itself is deleted, not the target file.

This is a low-level API that allows deleting any file within the wiki directory, so it should not be utilized directly by frontends. Use DeletePage, DeleteModel, or DeleteImage instead.

func (*Wiki) DeleteImage added in v0.3.5

func (w *Wiki) DeleteImage(name string, commit CommitOpts) error

DeleteImage deletes an image file.

func (*Wiki) DeleteModel added in v0.3.5

func (w *Wiki) DeleteModel(name string, commit CommitOpts) error

DeleteModel deletes a model file.

func (*Wiki) DeletePage added in v0.3.5

func (w *Wiki) DeletePage(name string, commit CommitOpts) error

DeletePage deletes a page file and triggers regeneration of referencing pages.

func (*Wiki) Diff added in v0.2.25

func (w *Wiki) Diff(from, to string) (*object.Patch, error)

Diff returns the diff between two revisions. NOTE: For now, this includes all changes, not just those to a specific file.

func (*Wiki) Dir added in v0.2.0

func (w *Wiki) Dir(dirs ...string) string

Dir returns the absolute path to the resolved wiki directory. If the wiki directory is a symlink, it is followed.

Optional path components can be passed as arguments to be joined with the wiki root by the path separator.

func (*Wiki) DisplayCategoryPosts

func (w *Wiki) DisplayCategoryPosts(catName string, pageN int) any

DisplayCategoryPosts returns the display result for a category.

func (*Wiki) DisplayFile

func (w *Wiki) DisplayFile(path string) any

DisplayFile returns the display result for a plain text file.

func (*Wiki) DisplayImage

func (w *Wiki) DisplayImage(name string) any

DisplayImage returns the display result for an image.

func (*Wiki) DisplayPage

func (w *Wiki) DisplayPage(name string) any

DisplayPage returns the display result for a page.

func (*Wiki) DisplayPageDraft

func (w *Wiki) DisplayPageDraft(name string, draftOK bool) any

DisplayPageDraft returns the display result for a page.

Unlike DisplayPage, if draftOK is true, the content is served even if it is marked as draft.

func (*Wiki) DisplaySizedImage

func (w *Wiki) DisplaySizedImage(img SizedImage) any

DisplaySizedImage returns the display result for an image in specific dimensions.

func (*Wiki) DisplaySizedImageGenerate

func (w *Wiki) DisplaySizedImageGenerate(img SizedImage, generateOK bool) any

DisplaySizedImageGenerate returns the display result for an image in specific dimensions and allows images to be generated in any dimension.

func (*Wiki) DisplaySizedImageGenerateInternal added in v0.2.57

func (w *Wiki) DisplaySizedImageGenerateInternal(img SizedImage, generateOK bool, needLock bool, nonBlocking bool) any

DisplaySizedImageGenerateInternal is the internal implementation that can skip locking

func (*Wiki) FindPage

func (w *Wiki) FindPage(name string) (p *wikifier.Page)

FindPage attempts to find a page on this wiki given its name, regardless of the file format or filename case.

If a page by this name exists, the returned page represents it. Otherwise, a new page representing the lowercased, normalized .page file is returned in the standard quiki filename format.

func (*Wiki) GetCategory

func (w *Wiki) GetCategory(name string) *Category

GetCategory loads or creates a category.

func (*Wiki) GetImageLock added in v0.2.25

func (w *Wiki) GetImageLock(imageName string) *sync.Mutex

GetImageLock returns the mutex for a specific image, creating it if necessary.

func (*Wiki) GetLatestCommitHash added in v0.2.13

func (w *Wiki) GetLatestCommitHash() (string, error)

GetLatestCommitHash returns the most recent commit hash.

func (*Wiki) GetPageLock added in v0.2.25

func (w *Wiki) GetPageLock(pageName string) *sync.Mutex

GetPageLock returns the mutex for a specific page, creating it if necessary.

func (*Wiki) GetReferencingPages added in v0.3.5

func (w *Wiki) GetReferencingPages(pageName string) []string

GetReferencingPages returns a list of page names that reference the given page.

func (*Wiki) GetSpecialCategory

func (w *Wiki) GetSpecialCategory(name string, typ CategoryType) *Category

GetSpecialCategory loads or creates a special category given the type.

func (*Wiki) ImageInfo

func (w *Wiki) ImageInfo(name string) (info ImageInfo)

ImageInfo returns info for an image given its full-size name.

func (*Wiki) ImageMap

func (w *Wiki) ImageMap() map[string]ImageInfo

ImageMap returns a map of image filename to ImageInfo for all images in the wiki.

func (*Wiki) Images

func (w *Wiki) Images() []ImageInfo

Images returns info about all the images in the wiki.

func (*Wiki) ImagesAndDirs added in v0.2.19

func (w *Wiki) ImagesAndDirs(where string) ([]ImageInfo, []string)

ImagesAndDirs returns info about all the images and directories in a directory.

func (*Wiki) ImagesAndDirsSorted added in v0.2.19

func (w *Wiki) ImagesAndDirsSorted(where string, descend bool, sorters ...SortFunc) ([]ImageInfo, []string)

ImagesAndDirsSorted returns info about all the images and directories in a directory, sorted as specified. Accepted sort functions are SortTitle, SortAuthor, SortCreated, SortModified, and SortDimensions. Directories are always sorted alphabetically (but still respect the descend flag).

func (*Wiki) ImagesInDir added in v0.2.19

func (w *Wiki) ImagesInDir(where string) []ImageInfo

ImagesInDir returns info about all the images in the specified directory.

func (*Wiki) ImagesSorted added in v0.2.0

func (w *Wiki) ImagesSorted(descend bool, sorters ...SortFunc) []ImageInfo

ImagesSorted returns info about all the images in the wiki, sorted as specified. Accepted sort functions are SortTitle, SortAuthor, SortCreated, SortModified, and SortDimensions.

func (*Wiki) IsDeferringChecks added in v0.2.60

func (w *Wiki) IsDeferringChecks() bool

IsDeferringChecks returns whether we're currently postponing checks

func (*Wiki) LockPage added in v0.2.25

func (w *Wiki) LockPage(pageName string) error

LockPage acquires both in-memory and file-based locks for a specific page

func (*Wiki) LockWiki added in v0.2.25

func (w *Wiki) LockWiki() error

LockWiki acquires a wiki-wide lock for bulk operations

func (*Wiki) Log added in v0.2.0

func (w *Wiki) Log(i ...any)

Log logs info for a wiki.

func (*Wiki) Logf added in v0.2.0

func (w *Wiki) Logf(format string, i ...any)

Logf logs info for a wiki.

func (*Wiki) ModelInfo

func (w *Wiki) ModelInfo(name string) (info wikifier.ModelInfo)

ModelInfo is an inexpensive request for info on a model. It uses cached metadata rather than generating the model and extracting variables.

func (*Wiki) ModelMap

func (w *Wiki) ModelMap() map[string]wikifier.ModelInfo

ModelMap returns a map of model name to wikifier.ModelInfo for all models in the wiki.

func (*Wiki) Models

func (w *Wiki) Models() []wikifier.ModelInfo

Models returns info about all the models in the wiki.

func (*Wiki) ModelsAndDirs added in v0.2.24

func (w *Wiki) ModelsAndDirs(where string) ([]wikifier.ModelInfo, []string)

ModelsAndDirs returns info about all the models and directories in a directory.

func (*Wiki) ModelsAndDirsSorted added in v0.2.24

func (w *Wiki) ModelsAndDirsSorted(where string, descend bool, sorters ...SortFunc) ([]wikifier.ModelInfo, []string)

ModelsAndDirsSorted returns info about all the models and directories in a directory, sorted as specified. Accepted sort functions are SortTitle, SortAuthor, SortCreated, and SortModified. Directories are always sorted alphabetically (but still respect the descend flag).

func (*Wiki) ModelsInDir added in v0.2.24

func (w *Wiki) ModelsInDir(where string) []wikifier.ModelInfo

ModelsInDir returns info about all the models in the specified directory.

func (*Wiki) ModelsSorted added in v0.2.0

func (w *Wiki) ModelsSorted(descend bool, sorters ...SortFunc) []wikifier.ModelInfo

ModelsSorted returns info about all the models in the wiki, sorted as specified. Accepted sort functions are SortTitle, SortAuthor, SortCreated, and SortModified.

func (*Wiki) Name added in v0.2.25

func (w *Wiki) Name() string

Name returns the wiki's name based on its directory.

func (*Wiki) PageInfo

func (w *Wiki) PageInfo(name string) (info wikifier.PageInfo)

PageInfo is an inexpensive request for info on a page. It uses cached metadata rather than generating the page and extracting variables.

func (*Wiki) PageMap

func (w *Wiki) PageMap() map[string]wikifier.PageInfo

PageMap returns a map of page name to PageInfo for all pages in the wiki.

func (*Wiki) Pages

func (w *Wiki) Pages() []wikifier.PageInfo

Pages returns info about all the pages in the wiki.

func (*Wiki) PagesAndDirs added in v0.2.16

func (w *Wiki) PagesAndDirs(where string) ([]wikifier.PageInfo, []string)

PagesAndDirs returns info about all the pages and directories in a directory.

func (*Wiki) PagesAndDirsSorted added in v0.2.16

func (w *Wiki) PagesAndDirsSorted(where string, descend bool, sorters ...SortFunc) ([]wikifier.PageInfo, []string)

PagesAndDirsSorted returns info about all the pages and directories in a directory, sorted as specified. Accepted sort functions are SortTitle, SortAuthor, SortCreated, and SortModified. Directories are always sorted alphabetically (but still respect the descend flag).

func (*Wiki) PagesInDir added in v0.2.16

func (w *Wiki) PagesInDir(where string) []wikifier.PageInfo

PagesInDir returns info about all the pages in the specified directory.

func (*Wiki) PagesSorted added in v0.2.0

func (w *Wiki) PagesSorted(descend bool, sorters ...SortFunc) []wikifier.PageInfo

PagesSorted returns info about all the pages in the wiki, sorted as specified. Accepted sort functions are SortTitle, SortAuthor, SortCreated, and SortModified.

func (*Wiki) ParseThumbnailSizes added in v0.2.31

func (w *Wiki) ParseThumbnailSizes(config string, origWidth, origHeight int) [][2]int

ParseThumbnailSizes parses the PregenThumbnails config string into a list of dimensions format: "250,400x300,150" where numbers are max dimension and NxN are exact dimensions

func (*Wiki) PathForCategory added in v0.2.13

func (w *Wiki) PathForCategory(catName string, createOK bool) string

PathForCategory returns the absolute path for a category. If createOK is true, it creates directories for the path components that do not exist.

func (*Wiki) PathForImage added in v0.2.13

func (w *Wiki) PathForImage(imageName string) string

PathForImage returns the absolute path for an image.

func (*Wiki) PathForMetaCategory added in v0.2.13

func (w *Wiki) PathForMetaCategory(catName string, catType CategoryType, createOK bool) string

PathForMetaCategory returns the absolute path for a meta category. Meta categories are used for internal categorization and not exposed in the wiki.

If createOK is true, it creates directories for the path components that do not exist.

func (*Wiki) PathForModel added in v0.2.13

func (w *Wiki) PathForModel(modelName string) string

PathForModel returns the absolute path for a model.

func (*Wiki) PathForPage added in v0.2.13

func (w *Wiki) PathForPage(pageName string) string

PathForPage returns the absolute path for a page.

func (*Wiki) ProcessChecks added in v0.2.60

func (w *Wiki) ProcessChecks()

ProcessChecks runs all deferred validation checks and adds warnings for those that still fail

func (*Wiki) RegeneratePage added in v0.2.25

func (w *Wiki) RegeneratePage(pageName string) error

RegeneratePage clears the cache for a page to force regeneration

func (*Wiki) RelPath added in v0.2.0

func (w *Wiki) RelPath(absPath string) string

RelPath takes an absolute file path and attempts to make it relative to the wiki directory, regardless of whether the path exists.

If the path can be made relative without following symlinks, this is preferred. If that fails, symlinks in absPath are followed and a second attempt is made.

In any case the path cannot be made relative to the wiki directory, an empty string is returned.

func (*Wiki) RevisionsMatchingFile added in v0.3.7

func (w *Wiki) RevisionsMatchingFile(relPath string) ([]RevisionInfo, error)

RevisionsMatchingFile returns a list of commit infos matching any file by relative path.

func (*Wiki) RevisionsMatchingPage added in v0.2.16

func (w *Wiki) RevisionsMatchingPage(nameOrPath string) ([]RevisionInfo, error)

RevisionsMatchingPage returns a list of commit infos matching a page file.

func (*Wiki) SetDeferringChecks added in v0.2.60

func (w *Wiki) SetDeferringChecks(scoped bool)

SetDeferringChecks sets whether we're postponing checks until after a bulk operation (e.g., pregenerating)

func (*Wiki) Shutdown added in v0.3.7

func (w *Wiki) Shutdown()

Shutdown closes the wiki active filehandles.

func (*Wiki) UnlockPage added in v0.2.25

func (w *Wiki) UnlockPage(pageName string) error

UnlockPage releases both file-based and in-memory locks for a specific page

func (*Wiki) UnlockWiki added in v0.2.25

func (w *Wiki) UnlockWiki() error

UnlockWiki releases the wiki-wide lock

func (*Wiki) UnresolvedAbsFilePath added in v0.2.0

func (w *Wiki) UnresolvedAbsFilePath(relPath string) string

UnresolvedAbsFilePath takes a relative path to a file within the wiki (e.g. `pages/mypage.page`) and joins it with the absolute path to the wiki directory. The result is an absolute path which may or may not exist.

Symlinks are not followed. If that is desired, use absoluteFilePath instead.

func (*Wiki) WithCategoryBatching added in v0.3.4

func (w *Wiki) WithCategoryBatching(fn func())

WithCategoryBatching executes a function with category batching enabled. All category operations within the function will be batched and written at the end.

func (*Wiki) WithWikiLock added in v0.2.25

func (w *Wiki) WithWikiLock(fn func() error) error

WithWikiLock executes a function while holding the wiki-wide lock

func (*Wiki) WriteConfig added in v0.2.13

func (w *Wiki) WriteConfig(content []byte, commit CommitOpts) error

WriteConfig writes the wiki configuration file.

func (*Wiki) WriteImage added in v0.2.13

func (w *Wiki) WriteImage(name string, content []byte, createOK bool, commit CommitOpts) error

WriteImage writes an image file.

func (*Wiki) WriteModel added in v0.2.13

func (w *Wiki) WriteModel(name string, content []byte, createOK bool, commit CommitOpts) error

WriteModel writes a model file.

func (*Wiki) WritePage added in v0.2.13

func (w *Wiki) WritePage(name string, content []byte, createOK bool, commit CommitOpts) error

WritePage writes a page file.

Jump to

Keyboard shortcuts

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