Documentation
¶
Index ¶
- Constants
- Variables
- func Dirname(name string) string
- func DoneWriter(isDone func() bool, w io.Writer, content string)
- func EtagMatch(w http.ResponseWriter, r *http.Request, hash string) (etag string, match bool)
- func FindPath(arr []string, value string) int
- func GetIP(r *http.Request) string
- func GetPathname(folder, name string, share Share) string
- func HandleClose(closer io.Closer, err error) error
- func Join(parts ...string) string
- func LoadJSON(ctx context.Context, storageApp absto.Storage, filename string, content any) (err error)
- func LogClose(closer io.Closer, fn, item string)
- func MetadataDirectory(item absto.Item) string
- func RemoveIndex(arr []string, index int) []string
- func RenameDirectory(ctx context.Context, storageApp absto.Storage, renamers []Renamer, ...)
- func SafeWrite(w io.Writer, content string)
- func SanitizeName(name string, removeSlash bool) (string, error)
- func SaveJSON(ctx context.Context, storageApp absto.Storage, filename string, content any) error
- func SendLargeFile(ctx context.Context, storageApp absto.Storage, item absto.Item, ...) (*http.Response, error)
- func SetPrefsCookie(w http.ResponseWriter, request Request)
- func URL(folder, name string, share Share) string
- func WriteToStorage(ctx context.Context, storageApp absto.Storage, output string, size int64, ...) error
- type Aggregate
- type Auth
- type ByHybridSort
- type Crud
- type Event
- func NewAccessEvent(item absto.Item, r *http.Request) Event
- func NewDeleteEvent(request Request, item absto.Item, rendererApp renderer.App) Event
- func NewDescriptionEvent(item absto.Item, shareableURL string, description string, ...) Event
- func NewRenameEvent(old, new absto.Item, shareableURL string, rendererApp renderer.App) Event
- func NewRestartEvent(item absto.Item, subset string) Event
- func NewStartEvent(item absto.Item) Event
- func NewUploadEvent(request Request, item absto.Item, shareableURL string, ...) Event
- type EventBus
- type EventConsumer
- type EventProducer
- type EventType
- type ExifManager
- type ExifResponse
- type Preferences
- type Renamer
- type RenderItem
- type Request
- func (r Request) AbsoluteURL(name string) string
- func (r Request) DeletePreference(path string) Request
- func (r Request) Description() string
- func (r Request) Filepath() string
- func (r Request) IsStory() bool
- func (r Request) LayoutPath(path string) string
- func (r Request) RelativeURL(item absto.Item) string
- func (r Request) SubPath(name string) string
- func (r Request) Title() string
- func (r Request) UpdatePreferences() Request
- type Share
- type ShareByID
- type ShareManager
- type StoryItem
- type Webhook
- type WebhookByID
- type WebhookKind
- type WebhookManager
Constants ¶
const (
// MetadataDirectoryName directory where 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, ".webp": 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/mp4", ".avi": "video/x-msvideo", ".ogg": "video/ogg", ".mkv": "video/x-matroska"} // StreamExtensions contains extensions of streamable content StreamExtensions = map[string]bool{".ts": true} // WordExtensions contains extensions of Word WordExtensions = map[string]bool{".doc": true, ".docx": true, ".docm": true} // ThumbnailExtensions contains extensions of file eligible to thumbnail ThumbnailExtensions = map[string]bool{".jpg": true, ".jpeg": true, ".png": true, ".gif": true, ".tiff": true, ".webp": true, ".pdf": true, ".mp4": true, ".mov": true, ".avi": true, ".ogg": true, ".mkv": true} )
var ( // GridDisplay format GridDisplay = "grid" // ListDisplay format ListDisplay = "list" // StoryDisplay format StoryDisplay = "story" // DefaultDisplay format DefaultDisplay = GridDisplay // LayoutPathsCookieName for saving preferences LayoutPathsCookieName = "layout_paths" )
var ( // BufferPool for io.CopyBuffer BufferPool = sync.Pool{ New: func() any { return bytes.NewBuffer(make([]byte, 4*1024)) }, } // SlowClient allows 5 minutes timeout SlowClient = request.CreateClient(5*time.Minute, request.NoRedirection) )
var WebhookKindValues = []string{"raw", "discord", "slack", "telegram"}
WebhookKindValues string values
Functions ¶
func DoneWriter ¶ added in v0.13.0
DoneWriter writes content to writer with error handling and done checking
func GetPathname ¶
GetPathname computes pathname for given params
func HandleClose ¶ added in v0.11.0
HandleClose closes given closer respecting given err
func LoadJSON ¶ added in v0.11.0
func LoadJSON(ctx context.Context, storageApp absto.Storage, filename string, content any) (err error)
LoadJSON loads JSON content
func MetadataDirectory ¶ added in v0.18.0
MetadataDirectory computes metadata directory for given item
func RemoveIndex ¶
RemoveIndex removes element at given index, if valid
func RenameDirectory ¶ added in v0.18.0
func RenameDirectory(ctx context.Context, storageApp absto.Storage, renamers []Renamer, old, new absto.Item)
RenameDirectory for metadata
func SanitizeName ¶
SanitizeName return sanitized name (remove diacritics)
func SendLargeFile ¶ added in v0.9.0
func SendLargeFile(ctx context.Context, storageApp absto.Storage, item absto.Item, req request.Request) (*http.Response, error)
SendLargeFile in a request with buffered copy
func SetPrefsCookie ¶ added in v0.4.1
func SetPrefsCookie(w http.ResponseWriter, request Request)
SetPrefsCookie set preferences cookie for given request
Types ¶
type Aggregate ¶ added in v0.7.0
type Aggregate struct {
Start time.Time `json:"start,omitempty"`
End time.Time `json:"end,omitempty"`
Location string `json:"location,omitempty"`
Cover string `json:"cover,omitempty"`
}
Aggregate contains aggregated data for a folder
type Auth ¶ added in v0.8.0
type Auth interface {
IsAuthenticated(*http.Request) (ident.Provider, model.User, error)
IsAuthorized(context.Context, string) bool
}
Auth manager user authentication/authorization
type ByHybridSort ¶ added in v0.9.0
ByHybridSort implements Sorter by type then modification time
func (ByHybridSort) Len ¶ added in v0.9.0
func (a ByHybridSort) Len() int
func (ByHybridSort) Less ¶ added in v0.9.0
func (a ByHybridSort) Less(i, j int) bool
func (ByHybridSort) Swap ¶ added in v0.9.0
func (a ByHybridSort) Swap(i, j int)
type Crud ¶ added in v0.8.0
type Crud interface {
Get(http.ResponseWriter, *http.Request, Request) (renderer.Page, error)
Post(http.ResponseWriter, *http.Request, Request)
Create(http.ResponseWriter, *http.Request, Request)
Rename(http.ResponseWriter, *http.Request, Request)
Delete(http.ResponseWriter, *http.Request, Request)
}
Crud for user to interfact with filesystem
type Event ¶ added in v0.7.0
type Event struct {
Time time.Time `json:"time"`
New *absto.Item `json:"new,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
URL string `json:"url,omitempty"`
Item absto.Item `json:"item"`
Type EventType `json:"type"`
}
Event describes an event on fibr
func NewAccessEvent ¶ added in v0.8.0
NewAccessEvent creates a new access event
func NewDeleteEvent ¶ added in v0.7.0
NewDeleteEvent creates a new delete event
func NewDescriptionEvent ¶ added in v0.20.0
func NewDescriptionEvent(item absto.Item, shareableURL string, description string, rendererApp renderer.App) Event
NewDescriptionEvent creates a new description event
func NewRenameEvent ¶ added in v0.7.0
NewRenameEvent creates a new rename event
func NewRestartEvent ¶ added in v0.16.0
NewRestartEvent creates a new restart event
func NewStartEvent ¶ added in v0.7.0
NewStartEvent creates a new start event
func NewUploadEvent ¶ added in v0.7.0
func NewUploadEvent(request Request, item absto.Item, shareableURL string, rendererApp renderer.App) Event
NewUploadEvent creates a new upload event
func (Event) GetMetadata ¶ added in v0.14.0
GetMetadata extracts metadata content
func (Event) IsForcedFor ¶ added in v0.18.0
IsForcedFor check if event is forced for given key
type EventBus ¶ added in v0.7.0
type EventBus struct {
// contains filtered or unexported fields
}
EventBus describes a channel for exchanging Event
func NewEventBus ¶ added in v0.7.0
func NewEventBus(size uint, prometheusRegisterer prometheus.Registerer, tracerApp tracer.App) (EventBus, error)
NewEventBus create an event exchange channel
type EventConsumer ¶ added in v0.7.0
EventConsumer is a func that consume an event
type EventProducer ¶ added in v0.7.0
EventProducer is a func that push an event
type EventType ¶ added in v0.7.0
type EventType uint
EventType is the enumeration of event that can happen
const ( // UploadEvent occurs when someone upload a file UploadEvent EventType = iota // CreateDir occurs when a directory is created CreateDir // RenameEvent occurs when an item is renamed RenameEvent // DeleteEvent occurs when an item is deleted DeleteEvent // StartEvent occurs when fibr start StartEvent // AccessEvent occurs when content is accessed AccessEvent // DescriptionEvent occurs when a description is added DescriptionEvent )
func ParseEventType ¶ added in v0.8.0
ParseEventType parse raw string into an EventType
func (EventType) MarshalJSON ¶ added in v0.8.0
MarshalJSON marshals the enum as a quoted json string
func (*EventType) UnmarshalJSON ¶ added in v0.8.0
UnmarshalJSON unmarshal JSON
type ExifManager ¶ added in v0.16.0
type ExifManager interface {
ListDir(ctx context.Context, item absto.Item) ([]absto.Item, error)
GetAggregateFor(ctx context.Context, item absto.Item) (Aggregate, error)
SaveAggregateFor(ctx context.Context, item absto.Item, aggregate Aggregate) error
GetExifFor(ctx context.Context, item absto.Item) (exas.Exif, error)
SaveExifFor(ctx context.Context, item absto.Item, exif exas.Exif) error
}
ExifManager description
type ExifResponse ¶ added in v0.10.0
ExifResponse from AMQP
type Preferences ¶
Preferences holds preferences of the user
func ParsePreferences ¶ added in v0.16.0
func ParsePreferences(value string) Preferences
ParsePreferences for a given string value
func (Preferences) AddLayout ¶ added in v0.16.0
func (p Preferences) AddLayout(path, display string) Preferences
AddLayout display for given path
func (Preferences) RemoveLayout ¶ added in v0.16.0
func (p Preferences) RemoveLayout(path string) Preferences
RemoveLayout display for given path
type RenderItem ¶
type RenderItem struct {
Aggregate
URL string
Path string
absto.Item
HasThumbnail bool
IsCover bool
}
RenderItem is a storage item with some metadatas
func StorageToRender ¶ added in v0.12.0
func StorageToRender(item absto.Item, request Request) RenderItem
StorageToRender converts Item to RenderItem
func (RenderItem) IsImage ¶ added in v0.14.0
func (r RenderItem) IsImage() bool
IsImage check if item is an image
func (RenderItem) IsVideo ¶ added in v0.14.0
func (r RenderItem) IsVideo() bool
IsVideo check if item is an image
func (RenderItem) IsZero ¶ added in v0.15.0
func (r RenderItem) IsZero() bool
IsZero checks if instance is valued or not
func (RenderItem) Mime ¶ added in v0.13.0
func (r RenderItem) Mime() string
Mime gives Mime Type of item
type Request ¶
type Request struct {
Path string
Item string
Display string
Preferences Preferences
CanEdit bool
CanWebhook bool
}
Request from user
func (Request) AbsoluteURL ¶ added in v0.12.0
AbsoluteURL compute absolute URL for the given name
func (Request) DeletePreference ¶ added in v0.16.0
DeletePreference remove given path from preferences
func (Request) Description ¶ added in v0.4.1
Description returns description of the page
func (Request) LayoutPath ¶
LayoutPath returns layout of given path based on preferences
func (Request) RelativeURL ¶ added in v0.12.0
RelativeURL compute relative URL of item for that request
func (Request) UpdatePreferences ¶ added in v0.16.0
UpdatePreferences based on current request
type Share ¶
type Share struct {
}
Share stores informations about shared paths
func (Share) CheckPassword ¶
CheckPassword verifies that request has correct password for share
type StoryItem ¶ added in v0.16.0
type StoryItem struct {
Exif model.Exif
RenderItem
}
StoryItem is a render item with
type Webhook ¶ added in v0.8.0
type Webhook struct {
ID string `json:"id"`
Pathname string `json:"pathname"`
URL string `json:"url"`
Types []EventType `json:"types"`
Kind WebhookKind `json:"kind"`
Recursive bool `json:"recursive"`
}
Webhook stores informations about webhook
type WebhookByID ¶ added in v0.15.0
type WebhookByID []Webhook
WebhookByID sort Webhook by ID
func (WebhookByID) Len ¶ added in v0.15.0
func (a WebhookByID) Len() int
func (WebhookByID) Less ¶ added in v0.15.0
func (a WebhookByID) Less(i, j int) bool
func (WebhookByID) Swap ¶ added in v0.15.0
func (a WebhookByID) Swap(i, j int)
type WebhookKind ¶ added in v0.12.0
type WebhookKind int
WebhookKind defines constant for webhook kind
const ( // Raw webhook Raw WebhookKind = iota // Discord webhook Discord // Slack webhook Slack // Telegram webhook Telegram )
func ParseWebhookKind ¶ added in v0.12.0
func ParseWebhookKind(value string) (WebhookKind, error)
ParseWebhookKind parse raw string into a WebhookKind
func (WebhookKind) MarshalJSON ¶ added in v0.12.0
func (r WebhookKind) MarshalJSON() ([]byte, error)
MarshalJSON marshals the enum as a quoted json string
func (WebhookKind) String ¶ added in v0.12.0
func (r WebhookKind) String() string
func (*WebhookKind) UnmarshalJSON ¶ added in v0.12.0
func (r *WebhookKind) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshal JSON