directory

package
Version: v0.0.0-...-c65c995 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2016 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFrontMatterRune

func AppendFrontMatterRune(frontmatter []byte, language string) []byte

AppendFrontMatterRune appends the frontmatter rune to a file

func CanBeEdited

func CanBeEdited(filename string) bool

CanBeEdited checks if the extension of a file is supported by the editor

func HasFrontMatterRune

func HasFrontMatterRune(file []byte) bool

HasFrontMatterRune checks if the file has the frontmatter rune

func ParseCompleteFile

func ParseCompleteFile(data map[string]interface{}, filename string, frontmatter string) ([]byte, int, error)

ParseCompleteFile parses a complete file

func ParseFrontMatter

func ParseFrontMatter(data interface{}, frontmatter string) ([]byte, int, error)

ParseFrontMatter is the frontmatter parser

func ParseFrontMatterOnlyFile

func ParseFrontMatterOnlyFile(data interface{}, filename string) ([]byte, int, error)

ParseFrontMatterOnlyFile parses a frontmatter only file

func SimplifyMimeType

func SimplifyMimeType(name string) string

SimplifyMimeType returns the base type of a file

Types

type Editor

type Editor struct {
	Class       string
	Mode        string
	Content     string
	FrontMatter *frontmatter.Content
}

Editor contains the information for the editor page

type Info

type Info struct {
	IsDir    bool
	Name     string
	Size     int64
	URL      string
	Path     string // The relative Path of the file/directory relative to Caddyfile.
	RootPath string // The Path of the file/directory on http.FileSystem.
	ModTime  time.Time
	Mode     os.FileMode
	Mimetype string
	Content  string
	Raw      []byte
	Type     string
}

Info is the information about a particular file or directory

func GetInfo

func GetInfo(url *url.URL, c *config.Config) (*Info, int, error)

GetInfo gets the file information and, in case of error, returns the respective HTTP error code

func (*Info) Delete

func (i *Info) Delete() (int, error)

Delete handles the delete requests

func (*Info) GetEditor

func (i *Info) GetEditor() (*Editor, error)

GetEditor gets the editor based on a FileInfo struct

func (*Info) GetExtendedInfo

func (i *Info) GetExtendedInfo() error

GetExtendedInfo is used to get extra parameters for FileInfo struct

func (Info) HumanModTime

func (i Info) HumanModTime(format string) string

HumanModTime returns the modified time of the file as a human-readable string.

func (Info) HumanSize

func (i Info) HumanSize() string

HumanSize returns the size of the file as a human-readable string in IEC format (i.e. power of 2 or base 1024).

func (*Info) Read

func (i *Info) Read() error

Read is used to read a file and store its content

func (*Info) Rename

func (i *Info) Rename(w http.ResponseWriter, r *http.Request) (int, error)

Rename function is used tor rename a file or a directory

func (*Info) ServeAsHTML

func (i *Info) ServeAsHTML(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error)

ServeAsHTML is used to serve single file pages

func (*Info) ServeRawFile

func (i *Info) ServeRawFile(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error)

ServeRawFile serves raw files

func (*Info) Update

func (i *Info) Update(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error)

Update is used to update a file that was edited

type Listing

type Listing struct {
	// The name of the directory (the last element of the path)
	Name string
	// The full path of the request
	Path string
	// The items (files and folders) in the path
	Items []Info
	// The number of directories in the listing
	NumDirs int
	// The number of files (items that aren't directories) in the listing
	NumFiles int
	// Which sorting order is used
	Sort string
	// And which order
	Order string
	// If ≠0 then Items have been limited to that many elements
	ItemsLimitedTo     int
	httpserver.Context `json:"-"`
}

A Listing is the context used to fill out a template.

Jump to

Keyboard shortcuts

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