more updates

Former-commit-id: 8c19eda25f60e0fc5587dde8c19a8428befc3e0d
This commit is contained in:
Henrique Dias
2017-06-19 18:23:57 +01:00
parent 8d4981fcb8
commit bd7184d5df
16 changed files with 79 additions and 83 deletions

View File

@@ -11,14 +11,14 @@ import (
"github.com/mholt/caddy/caddyhttp/httpserver"
)
// A Listing is the context used to fill out a template.
type Listing struct {
// A listing is the context used to fill out a template.
type listing struct {
// The name of the directory (the last element of the path)
Name string
// The full path of the request relatively to a File System
Path string
// The items (files and folders) in the path
Items []file
Items []fileInfo
// The number of directories in the listing
NumDirs int
// The number of files (items that aren't directories) in the listing
@@ -32,8 +32,8 @@ type Listing struct {
httpserver.Context `json:"-"`
}
// GetListing gets the information about a specific directory and its files.
func GetListing(u *User, filePath string, baseURL string) (*Listing, error) {
// getListing gets the information about a specific directory and its files.
func getListing(u *User, filePath string, baseURL string) (*listing, error) {
// Gets the directory information using the Virtual File System of
// the user configuration.
file, err := u.FileSystem.OpenFile(context.TODO(), filePath, os.O_RDONLY, 0)
@@ -49,7 +49,7 @@ func GetListing(u *User, filePath string, baseURL string) (*Listing, error) {
}
var (
fileinfos []*file
fileinfos []fileInfo
dirCount, fileCount int
)
@@ -71,7 +71,7 @@ func GetListing(u *User, filePath string, baseURL string) (*Listing, error) {
// Absolute URL
url := url.URL{Path: baseURL + name}
i := &file{
i := fileInfo{
Name: f.Name(),
Size: f.Size(),
ModTime: f.ModTime(),
@@ -85,7 +85,7 @@ func GetListing(u *User, filePath string, baseURL string) (*Listing, error) {
fileinfos = append(fileinfos, i)
}
return &Listing{
return &listing{
Name: path.Base(filePath),
Path: filePath,
Items: fileinfos,
@@ -95,7 +95,7 @@ func GetListing(u *User, filePath string, baseURL string) (*Listing, error) {
}
// ApplySort applies the sort order using .Order and .Sort
func (l Listing) ApplySort() {
func (l listing) ApplySort() {
// Check '.Order' to know how to sort
if l.Order == "desc" {
switch l.Sort {
@@ -124,10 +124,10 @@ func (l Listing) ApplySort() {
}
}
// Implement sorting for Listing
type byName Listing
type bySize Listing
type byTime Listing
// Implement sorting for listing
type byName listing
type bySize listing
type byTime listing
// By Name
func (l byName) Len() int {