render

package
v1.7.9 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package render provides the file content rendering for the web server.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBuffer    = errors.New("buffer is nil")
	ErrDownload  = errors.New("download file cannot be stat")
	ErrFileModel = errors.New("file model is nil")
	ErrFilename  = errors.New("file model filename is empty")
	ErrUUID      = errors.New("file model uuid is empty")
)

Functions

func Diz added in v1.5.1

func Diz(art *models.File, extra dir.Directory) ([]byte, error)

Diz returns the content of the FILE_ID.DIZ file. The text is intended to be used as a readme, preview or an in-browser viewer.

If the FILE_ID.DIZ file is missing then it will return nil. TODO: this should be removed in the future.

func DizPool added in v1.7.7

func DizPool(buf *bytes.Buffer, art *models.File, extra dir.Directory) error

DizPool returns the content of the FILE_ID.DIZ file. The text is intended to be used as a readme, preview or an in-browser viewer.

func Encoder

func Encoder(art *models.File, r io.Reader) encoding.Encoding

Encoder returns the encoding for the model file entry. Based on the platform and section. Otherwise it will attempt to determine the encoding from the file byte content.

func InsertDiz added in v1.5.1

func InsertDiz(b []byte, diz []byte) []byte

InsertDiz inserts the FILE_ID.DIZ content into the extisting byte content.

func NoScreenshot

func NoScreenshot(art *models.File, previewPath string) bool

NoScreenshot returns true when the file entry should not attempt to display a screenshot. This is based on the platform, section or if the screenshot is missing on the server.

func Read

func Read(art *models.File, download, extra dir.Directory) ([]byte, []rune, error)

Read returns the content of either the file download or an extracted text file. The text is intended to be used as a readme, preview or an in-browser viewer. TODO: this might be removed in the future.

func ReadmePool added in v1.7.7

func ReadmePool(buf, ruf *bytes.Buffer, art *models.File, download, extra dir.Directory) error

ReadmePool writes the content of either the file download or an extracted text file to the buffers. The text is intended to be used as a readme, preview or an in-browser viewer.

Both the buf buffer and the ruf rune buffer are reset before writing.

func Viewer

func Viewer(art *models.File) bool

Viewer returns true if the file entry should display the file download in the browser plain text viewer. The result is based on the platform and section such as "text" or "textamiga" will return true. If the filename is "file_id.diz" then it will return false.

Types

This section is empty.

Jump to

Keyboard shortcuts

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