Documentation
¶
Overview ¶
Package wittyintegratedfilebrowser lists a computer's drives, folders and files for a folder browser shown in a web page, so folders can be chosen from another device than the one holding them. It only reads: nothing is created, renamed or deleted.
Index ¶
Constants ¶
const PlacesSource = "wittyintegratedfilebrowser.places"
PlacesSource is the source's type.
Variables ¶
var ( // ErrNotFound: the path does not exist (or cannot be seen). ErrNotFound = errors.New("folder not found") // ErrDenied: the folder exists but cannot be opened. ErrDenied = errors.New("not allowed to open this folder") )
var InContainer = func() bool { if os.Getenv("WITTYMODULE_CONTAINER") != "" || os.Getenv("WMS_DOCKER") == "1" { return true } return exists("/.dockerenv") || exists("/run/.containerenv") }
InContainer says whether this runs in a container (Docker, Podman and the like), where a folder the server can't read is most often a user and group mapping that doesn't match the folder's owner. The host may say so (WITTYMODULE_CONTAINER, or WMS_DOCKER from WittyMediaServer's image); a helper isn't given those today, so the files container engines leave at the root tell it instead. A variable, so tests can say either.
var ManifestJSON []byte
ManifestJSON is this module's manifest (docs/MODULES.md, "The manifest").
Functions ¶
func DiscFolder ¶
DiscFolder says whether a folder holds a disc's structure: "dvd" for a VIDEO_TS folder (or one holding it), "bluray" for BDMV, else "".
Types ¶
type Entry ¶
type Entry struct {
Name string `json:"name"`
Path string `json:"path"`
Dir bool `json:"dir"`
Kind string `json:"kind,omitempty"` // files: what Options.Kind says (video, audio, book, disc, subtitle, image, other)
Disc string `json:"disc,omitempty"` // folders holding a DVD (VIDEO_TS) or Blu-ray (BDMV): "dvd" or "bluray"
Size int64 `json:"size,omitempty"`
Modified int64 `json:"modified,omitempty"` // Unix seconds
Hidden bool `json:"hidden,omitempty"`
}
Entry is one folder or file in a listing.
type Item ¶ added in v0.3.0
type Item struct {
ID string `json:"id"`
Kind string `json:"kind"`
Title string `json:"title"`
Subtitle string `json:"subtitle,omitempty"`
Icon string `json:"icon,omitempty"`
}
Item is one card, in the server's SDUI item shape.
type ItemsAnswer ¶ added in v0.3.0
type ItemsAnswer struct {
Items []Item `json:"items"`
More bool `json:"more"`
Total int `json:"total"`
}
ItemsAnswer is the answer to sdui.items.
func PlaceItems ¶ added in v0.3.0
func PlaceItems(r ItemsRequest, places []Place) (ItemsAnswer, error)
PlaceItems answers the places source. Where folders are on the server is for its administrators only, so anyone else is answered with nothing.
type ItemsRequest ¶ added in v0.3.0
type ItemsRequest struct {
Source map[string]any `json:"source"`
Offset int `json:"offset"`
Limit int `json:"limit"`
Viewer struct {
Admin bool `json:"admin"`
} `json:"viewer"`
}
ItemsRequest is the part of the server's sdui.items call this module reads.
func ParseItemsRequest ¶ added in v0.3.0
func ParseItemsRequest(raw json.RawMessage) (ItemsRequest, error)
ParseItemsRequest reads an sdui.items call's parameters.
type Listing ¶
type Listing struct {
Path string `json:"path"`
Parent *string `json:"parent"` // nil at a drive's root
Sep string `json:"sep"`
Entries []Entry `json:"entries"`
Counts map[string]int `json:"counts"` // "folder" and each file kind
Truncated bool `json:"truncated"`
}
Listing is a folder's contents.
type Note ¶ added in v0.3.0
type Note struct {
// Why: "denied" when the folder can't be opened, "empty-mount" when it is a
// mount point that looks empty to the server.
Why string `json:"why"`
// Folder is the one in the way: the folder asked for, or a folder above it
// that the server isn't allowed to go through.
Folder string `json:"folder"`
UID int `json:"uid"`
GID int `json:"gid"`
Groups []int `json:"groups,omitempty"` // the server's other groups
OwnerUID int `json:"ownerUid"`
OwnerGID int `json:"ownerGid"`
}
Note says why a folder may not be readable when the server runs in a container: the user and group the server runs as, and who owns the folder in the way, so the two can be compared. It holds numbers only; the page words it and links to the fix.
type Options ¶
type Options struct {
ShowHidden bool // include dot-files and system folders
MaxEntries int // 0 = 3000
Kind func(name string) string // classifies files; nil = FileKind
}
Options change a listing.
type Place ¶
type Place struct {
Name string `json:"name"`
Path string `json:"path"`
Group string `json:"group"` // drives, folders, or the host's own group name
Label string `json:"label,omitempty"`
Free uint64 `json:"free,omitempty"`
Total uint64 `json:"total,omitempty"`
}
Place is somewhere to start browsing: a drive, a usual folder, or one the host adds (such as folders already in use).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
wittyintegratedfilebrowser-module
command
Command wittyintegratedfilebrowser-module is WittyIntegratedFileBrowser as a helper process, so a new version can reach a server without a new server.
|
Command wittyintegratedfilebrowser-module is WittyIntegratedFileBrowser as a helper process, so a new version can reach a server without a new server. |
