diff --git a/cmd/serve/httplib/serve/data/data.go b/cmd/serve/httplib/serve/data/data.go index 629835d05..e4840f8ed 100644 --- a/cmd/serve/httplib/serve/data/data.go +++ b/cmd/serve/httplib/serve/data/data.go @@ -9,9 +9,47 @@ import ( "time" "github.com/pkg/errors" + "github.com/spf13/pflag" + "github.com/rclone/rclone/fs" + "github.com/rclone/rclone/fs/config/flags" ) +// Help describes the options for the serve package +var Help = `--template allows a user to specify a custom markup template for http +and webdav serve functions. The server exports the following markup +to be used within the template to server pages: + +| Parameter | Description | +| :---------- | :---------- | +| .Name | The full path of a file/directory. | +| .Title | Directory listing of .Name | +| .Sort | The current sort used. This is changeable via ?sort= parameter | +| | Sort Options: namedirfirst,name,size,time (default namedirfirst) | +| .Order | The current ordering used. This is changeable via ?order= parameter | +| | Order Options: asc,desc (default asc) | +| .Query | Currently unused. | +| .Breadcrumb | Allows for creating a relative navigation | +|-- .Link | The relative to the root link of the Text. | +|-- .Text | The Name of the directory. | +| .Entries | Information about a specific file/directory. | +|-- .URL | The 'url' of an entry. | +|-- .Leaf | Currently same as 'URL' but intended to be 'just' the name. | +|-- .IsDir | Boolean for if an entry is a directory or not. | +|-- .Size | Size in Bytes of the entry. | +|-- .ModTime | The UTC timestamp of an entry. | +` + +// Options for the templating functionality +type Options struct { + Template string +} + +// AddFlags for the templating functionality +func AddFlags(flagSet *pflag.FlagSet, prefix string, Opt *Options) { + flags.StringVarP(flagSet, &Opt.Template, prefix+"template", "", Opt.Template, "User Specified Template.") +} + // AfterEpoch returns the time since the epoch for the given time func AfterEpoch(t time.Time) bool { return t.After(time.Time{})