Documentation
¶
Index ¶
- Constants
- Variables
- func ErrNotExist(err error) error
- func FindIndex(arr []string, value string) int
- func GetPathname(folder, name string, share Share) string
- func IsNotExist(err error) bool
- func RemoveIndex(arr []string, index int) []string
- func SafeWrite(w io.Writer, content string)
- func SanitizeName(name string, removeSlash bool) (string, error)
- func SetPrefsCookie(w http.ResponseWriter, request Request)
- func URL(folder, name string, share Share) string
- type Preferences
- type ReadSeekerCloser
- type RenderItem
- type Request
- type Share
- type Storage
- type StorageItem
Constants ¶
const (
// MetadataDirectoryName directory when metadata are stored
MetadataDirectoryName = ".fibr"
)
Variables ¶
var ( // ArchiveExtensions contains extensions of Archive ArchiveExtensions = map[string]bool{".zip": true, ".tar": true, ".gz": true, ".rar": true} // AudioExtensions contains extensions of Audio AudioExtensions = map[string]bool{".mp3": true} // CodeExtensions contains extensions of Code CodeExtensions = map[string]bool{".html": true, ".css": true, ".js": true, ".jsx": true, ".json": true, ".yml": true, ".yaml": true, ".toml": true, ".md": true, ".go": true, ".py": true, ".java": true, ".xml": true} // ExcelExtensions contains extensions of Excel ExcelExtensions = map[string]bool{".xls": true, ".xlsx": true, ".xlsm": true} // ImageExtensions contains extensions of Image ImageExtensions = map[string]bool{".jpg": true, ".jpeg": true, ".png": true, ".gif": true, ".svg": true, ".tiff": true} // PdfExtensions contains extensions of Pdf PdfExtensions = map[string]bool{".pdf": true} // VideoExtensions contains extensions of Video VideoExtensions = map[string]string{".mp4": "video/mp4", ".mov": "video/quicktime", ".avi": "video/x-msvideo"} // WordExtensions contains extensions of Word WordExtensions = map[string]bool{".doc": true, ".docx": true, ".docm": true} )
var ( NoneShare = Share{} )
Functions ¶
func GetPathname ¶
GetPathname computes pathname for given params
func RemoveIndex ¶
RemoveIndex removes element at given index, if valid
func SanitizeName ¶
SanitizeName return sanitized name (remove diacritics)
func SetPrefsCookie ¶ added in v0.4.1
func SetPrefsCookie(w http.ResponseWriter, request Request)
SetPrefsCookie set preferences cookie for given request
Types ¶
type Preferences ¶
type Preferences struct {
ListLayoutPath []string
}
Preferences holds preferences of the user
type ReadSeekerCloser ¶
type ReadSeekerCloser interface {
Read([]byte) (int, error)
Seek(int64, int) (int64, error)
Close() error
}
ReadSeekerCloser is a combination of io.Reader, io.Seeker and io.Closer
type RenderItem ¶
type RenderItem struct {
ID string
URI string
StorageItem
}
RenderItem is a storage item with an id
type Request ¶
type Request struct {
Path string
Display string
Preferences Preferences
CanEdit bool
}
Request from user
func (Request) Description ¶ added in v0.4.1
Description returns description of the page
func (Request) GetFilepath ¶
GetFilepath of request
func (Request) LayoutPath ¶
LayoutPath returns layout of given path based on preferences
type Share ¶
type Share struct {
}
Share stores informations about shared paths
func (Share) CheckPassword ¶
CheckPassword verifies that request has correct password for share
type Storage ¶
type Storage interface {
SetIgnoreFn(ignoreFn func(StorageItem) bool)
Info(pathname string) (StorageItem, error)
List(pathname string) ([]StorageItem, error)
WriterTo(pathname string) (io.WriteCloser, error)
ReaderFrom(pathname string) (ReadSeekerCloser, error)
Walk(pathname string, walkFn func(StorageItem, error) error) error
CreateDir(pathname string) error
Store(pathname string, content io.ReadCloser) error
Rename(oldName, newName string) error
Remove(pathname string) error
}
Storage describe action on a storage provider
type StorageItem ¶
StorageItem describe item on a storage provider
func (StorageItem) Extension ¶
func (s StorageItem) Extension() string
Extension gives extensions of item
func (StorageItem) IsImage ¶
func (s StorageItem) IsImage() bool
IsImage determine if item if an image
func (StorageItem) IsVideo ¶
func (s StorageItem) IsVideo() bool
IsVideo determine if item if a video