wittyintegratedfilebrowser

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

README

WittyIntegratedFileBrowser

Choose folders on a server from any device.
A folder browser in a window, for apps whose files live on another computer: a phone, a TV or a laptop can pick a media server's folders.

Read-only

Read-only mirror of modules/wittyintegratedfilebrowser in WittyMediaServer, where development happens. Please open issues and pull requests there.

A browser's own "choose folder" window only sees the device the browser runs on. WittyIntegratedFileBrowser lists the server's drives and folders instead, so any device can choose them. It has two halves:

Half Where Does
Go this folder lists drives (with free space), usual folders, a folder's folders and files, and what's in it
React web/ the window: places, back/forward/up, a path bar you can click or type into, filtering, sorting, several folders at once

What it does

💽 Places drives with their label and free space, Home, Desktop, Videos, Music and the rest, plus places of your own (folders already in use, for example)
🧭 Getting around back, forward, up, a clickable path that turns into a text box (network paths too, such as \NAS\Media or /mnt/nas), recently chosen folders
🔎 Seeing what's there files with their kind (video, audio, book, disc image, subtitles, picture), DVD and Blu-ray folders marked, sizes, dates, a count of what's inside, hidden items on request
✅ Choosing the folder you're in, or tick several folders and use them all
⌨️ Every way of using it keyboard (arrows, Enter, Space, Backspace, / to filter, Ctrl+L for the path), touch, mouse and screen readers; a full-screen layout on phones
🔒 Safe it only reads: nothing is created, renamed or deleted. Put the Go half behind your app's sign-in

Go

import fb "github.com/wittywilla/wittyintegratedfilebrowser"

places := fb.Places(fb.Place{Name: "Movies", Path: `D:\Movies`, Group: "libraries"})
l, err := fb.List(`D:\Movies`, fb.Options{ShowHidden: false})
// l.Entries: folders first, then files; l.Counts: {"folder": 12, "video": 30, "disc": 4}
Call Does
Places(extra...) where to start: drives (label, free and total space), the user's folders, then extra
List(path, Options) a folder's folders and files (ErrNotFound, ErrDenied)
FileKind(name), DiscFolder(path), IsHidden(name) the helpers it uses

Options.Kind replaces the file classifier, MaxEntries limits very large folders (3,000 by default). No cgo; its only dependency is golang.org/x/sys. Serve both as JSON: List's result is what the window reads.

React

import FileBrowser from '@wittywilla/wittyintegratedfilebrowser'

<FileBrowser
  list={(path, hidden) => fetch(`/api/fs?path=${encodeURIComponent(path)}&hidden=${hidden ? 1 : 0}`).then((r) => r.json())}
  onPick={(paths) => addFolders(paths)}
  onClose={() => setOpen(false)}
/>

list('') returns { places }; any other path returns a List result. It uses your app's theme variables (--bg, --fg, --accent and the rest) and .btn/.input styles when they exist, and has its own when they don't.

The Witty family

Project Role
WittyMediaServer the media server it was made for
WittyDVD · WittyBluray · WittyDisc disc engines
WittyEbook · WittyPDF · WittyComics · WittyInk readers

Licence

Apache-2.0, the same licence as WittyMediaServer. © 2026 WittyWilla and contributors. Use, change and share it; if you redistribute it or build on it, keep the NOTICE attribution, “WittyIntegratedFileBrowser, developed by WittyWilla”, in your NOTICE file, documentation or About screen.

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

This section is empty.

Variables

View Source
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")
)
View Source
var ManifestJSON []byte

ManifestJSON is this module's manifest (docs/MODULES.md, "The manifest").

Functions

func DiscFolder

func DiscFolder(p string) string

DiscFolder says whether a folder holds a disc's structure: "dvd" for a VIDEO_TS folder (or one holding it), "bluray" for BDMV, else "".

func FileKind

func FileKind(name string) string

FileKind classifies a file by its extension: video, audio, book, disc, subtitle, image or other.

func IsHidden

func IsHidden(name string) bool

IsHidden: dot-files, $-folders and Windows system folders nobody keeps media in.

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 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.

func List

func List(path string, o Options) (*Listing, error)

List returns a folder's folders and files, folders first, by name. A path to a file lists the folder holding it; "D:" means the drive's root.

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).

func Places

func Places(extra ...Place) []Place

Places lists where to start: the drives (with their free space), the user's usual folders, then extra in the order given. Only places that exist are returned.

Jump to

Keyboard shortcuts

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