updates
This commit is contained in:
parent
986e0d5176
commit
f9c4de6dc5
12
README.md
12
README.md
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
# filebrowser
|
# filebrowser
|
||||||
|
|
||||||
[](https://travis-ci.org/hacdias/filemanager)
|
[](https://travis-ci.org/filebrowser/filebrowser)
|
||||||
[](https://goreportcard.com/report/hacdias/filemanager)
|
[](https://goreportcard.com/report/github.com/filebrowser/filebrowser)
|
||||||
[](http://godoc.org/github.com/filebrowser/filebrowser)
|
[](http://godoc.org/github.com/filebrowser/filebrowser)
|
||||||
[](https://github.com/filebrowser/filebrowser/releases/latest)
|
[](https://github.com/filebrowser/filebrowser/releases/latest)
|
||||||
|
|
||||||
filemanager provides a file managing interface within a specified directory and it can be used to upload, delete, preview, rename and edit your files. It allows the creation of multiple users and each user can have its own directory. It can be used as a standalone app or as a middleware.
|
filebrowser provides a file managing interface within a specified directory and it can be used to upload, delete, preview, rename and edit your files. It allows the creation of multiple users and each user can have its own directory. It can be used as a standalone app or as a middleware.
|
||||||
|
|
||||||
# Table of contents
|
# Table of contents
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ filemanager provides a file managing interface within a specified directory and
|
|||||||
|
|
||||||
# Getting started
|
# Getting started
|
||||||
|
|
||||||
You can find the Getting Started guide on the [documentation](https://henriquedias.com/filemanager/quick-start/).
|
You can find the Getting Started guide on the [documentation](https://filebrowser.github.io/quick-start/).
|
||||||
|
|
||||||
# Features
|
# Features
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ We support multiple users and each user can have its own scope and custom styles
|
|||||||
|
|
||||||
## Search
|
## Search
|
||||||
|
|
||||||
FileManager allows you to search through your files and it has some options. By default, your search will be something like this:
|
File Browser allows you to search through your files and it has some options. By default, your search will be something like this:
|
||||||
|
|
||||||
```
|
```
|
||||||
this are keywords
|
this are keywords
|
||||||
|
|||||||
@ -50,7 +50,7 @@ func init() {
|
|||||||
flag.StringVarP(&config, "config", "c", "", "Configuration file")
|
flag.StringVarP(&config, "config", "c", "", "Configuration file")
|
||||||
flag.IntVarP(&port, "port", "p", 0, "HTTP Port (default is random)")
|
flag.IntVarP(&port, "port", "p", 0, "HTTP Port (default is random)")
|
||||||
flag.StringVarP(&addr, "address", "a", "", "Address to listen to (default is all of them)")
|
flag.StringVarP(&addr, "address", "a", "", "Address to listen to (default is all of them)")
|
||||||
flag.StringVarP(&database, "database", "d", "./filemanager.db", "Database file")
|
flag.StringVarP(&database, "database", "d", "./filebrowser.db", "Database file")
|
||||||
flag.StringVarP(&logfile, "log", "l", "stdout", "Errors logger; can use 'stdout', 'stderr' or file")
|
flag.StringVarP(&logfile, "log", "l", "stdout", "Errors logger; can use 'stdout', 'stderr' or file")
|
||||||
flag.StringVarP(&scope, "scope", "s", ".", "Default scope option for new users")
|
flag.StringVarP(&scope, "scope", "s", ".", "Default scope option for new users")
|
||||||
flag.StringVarP(&baseurl, "baseurl", "b", "", "Base URL")
|
flag.StringVarP(&baseurl, "baseurl", "b", "", "Base URL")
|
||||||
@ -72,7 +72,7 @@ func init() {
|
|||||||
func setupViper() {
|
func setupViper() {
|
||||||
viper.SetDefault("Address", "")
|
viper.SetDefault("Address", "")
|
||||||
viper.SetDefault("Port", "0")
|
viper.SetDefault("Port", "0")
|
||||||
viper.SetDefault("Database", "./filemanager.db")
|
viper.SetDefault("Database", "./filebrowser.db")
|
||||||
viper.SetDefault("Scope", ".")
|
viper.SetDefault("Scope", ".")
|
||||||
viper.SetDefault("Logger", "stdout")
|
viper.SetDefault("Logger", "stdout")
|
||||||
viper.SetDefault("Commands", []string{"git", "svn", "hg"})
|
viper.SetDefault("Commands", []string{"git", "svn", "hg"})
|
||||||
@ -85,7 +85,7 @@ func setupViper() {
|
|||||||
viper.SetDefault("NoAuth", false)
|
viper.SetDefault("NoAuth", false)
|
||||||
viper.SetDefault("BaseURL", "")
|
viper.SetDefault("BaseURL", "")
|
||||||
viper.SetDefault("PrefixURL", "")
|
viper.SetDefault("PrefixURL", "")
|
||||||
viper.SetDefault("ViewMode", filemanager.MosaicViewMode)
|
viper.SetDefault("ViewMode", filebrowser.MosaicViewMode)
|
||||||
viper.SetDefault("ReCaptchaKey", "")
|
viper.SetDefault("ReCaptchaKey", "")
|
||||||
viper.SetDefault("ReCaptchaSecret", "")
|
viper.SetDefault("ReCaptchaSecret", "")
|
||||||
|
|
||||||
@ -108,12 +108,12 @@ func setupViper() {
|
|||||||
viper.BindPFlag("ReCaptchaKey", flag.Lookup("recaptcha-key"))
|
viper.BindPFlag("ReCaptchaKey", flag.Lookup("recaptcha-key"))
|
||||||
viper.BindPFlag("ReCaptchaSecret", flag.Lookup("recaptcha-secret"))
|
viper.BindPFlag("ReCaptchaSecret", flag.Lookup("recaptcha-secret"))
|
||||||
|
|
||||||
viper.SetConfigName("filemanager")
|
viper.SetConfigName("filebrowser")
|
||||||
viper.AddConfigPath(".")
|
viper.AddConfigPath(".")
|
||||||
}
|
}
|
||||||
|
|
||||||
func printVersion() {
|
func printVersion() {
|
||||||
fmt.Println("filemanager version", filemanager.Version)
|
fmt.Println("filebrowser version", filebrowser.Version)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,31 +186,31 @@ func handler() http.Handler {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fm := &filemanager.FileManager{
|
fm := &filebrowser.FileBrowser{
|
||||||
NoAuth: viper.GetBool("NoAuth"),
|
NoAuth: viper.GetBool("NoAuth"),
|
||||||
BaseURL: viper.GetString("BaseURL"),
|
BaseURL: viper.GetString("BaseURL"),
|
||||||
PrefixURL: viper.GetString("PrefixURL"),
|
PrefixURL: viper.GetString("PrefixURL"),
|
||||||
ReCaptchaKey: viper.GetString("ReCaptchaKey"),
|
ReCaptchaKey: viper.GetString("ReCaptchaKey"),
|
||||||
ReCaptchaSecret: viper.GetString("ReCaptchaSecret"),
|
ReCaptchaSecret: viper.GetString("ReCaptchaSecret"),
|
||||||
DefaultUser: &filemanager.User{
|
DefaultUser: &filebrowser.User{
|
||||||
AllowCommands: viper.GetBool("AllowCommands"),
|
AllowCommands: viper.GetBool("AllowCommands"),
|
||||||
AllowEdit: viper.GetBool("AllowEdit"),
|
AllowEdit: viper.GetBool("AllowEdit"),
|
||||||
AllowNew: viper.GetBool("AllowNew"),
|
AllowNew: viper.GetBool("AllowNew"),
|
||||||
AllowPublish: viper.GetBool("AllowPublish"),
|
AllowPublish: viper.GetBool("AllowPublish"),
|
||||||
Commands: viper.GetStringSlice("Commands"),
|
Commands: viper.GetStringSlice("Commands"),
|
||||||
Rules: []*filemanager.Rule{},
|
Rules: []*filebrowser.Rule{},
|
||||||
Locale: viper.GetString("Locale"),
|
Locale: viper.GetString("Locale"),
|
||||||
CSS: "",
|
CSS: "",
|
||||||
Scope: viper.GetString("Scope"),
|
Scope: viper.GetString("Scope"),
|
||||||
FileSystem: fileutils.Dir(viper.GetString("Scope")),
|
FileSystem: fileutils.Dir(viper.GetString("Scope")),
|
||||||
ViewMode: viper.GetString("ViewMode"),
|
ViewMode: viper.GetString("ViewMode"),
|
||||||
},
|
},
|
||||||
Store: &filemanager.Store{
|
Store: &filebrowser.Store{
|
||||||
Config: bolt.ConfigStore{DB: db},
|
Config: bolt.ConfigStore{DB: db},
|
||||||
Users: bolt.UsersStore{DB: db},
|
Users: bolt.UsersStore{DB: db},
|
||||||
Share: bolt.ShareStore{DB: db},
|
Share: bolt.ShareStore{DB: db},
|
||||||
},
|
},
|
||||||
NewFS: func(scope string) filemanager.FileSystem {
|
NewFS: func(scope string) filebrowser.FileSystem {
|
||||||
return fileutils.Dir(scope)
|
return fileutils.Dir(scope)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -107,7 +107,7 @@ var commandEvents = []string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Command is a command function.
|
// Command is a command function.
|
||||||
type Command func(r *http.Request, m *FileManager, u *User) error
|
type Command func(r *http.Request, m *FileBrowser, u *User) error
|
||||||
|
|
||||||
// FSBuilder is the File System Builder.
|
// FSBuilder is the File System Builder.
|
||||||
type FSBuilder func(scope string) FileSystem
|
type FSBuilder func(scope string) FileSystem
|
||||||
@ -115,7 +115,7 @@ type FSBuilder func(scope string) FileSystem
|
|||||||
// Setup loads the configuration from the database and configures
|
// Setup loads the configuration from the database and configures
|
||||||
// the Assets and the Cron job. It must always be run after
|
// the Assets and the Cron job. It must always be run after
|
||||||
// creating a File Manager object.
|
// creating a File Manager object.
|
||||||
func (m *FileManager) Setup() error {
|
func (m *FileBrowser) Setup() error {
|
||||||
// Creates a new File Manager instance with the Users
|
// Creates a new File Manager instance with the Users
|
||||||
// map and Assets box.
|
// map and Assets box.
|
||||||
m.Assets = rice.MustFindBox("./assets/dist")
|
m.Assets = rice.MustFindBox("./assets/dist")
|
||||||
@ -229,13 +229,13 @@ func (m *FileManager) Setup() error {
|
|||||||
|
|
||||||
// RootURL returns the actual URL where
|
// RootURL returns the actual URL where
|
||||||
// File Manager interface can be accessed.
|
// File Manager interface can be accessed.
|
||||||
func (m FileManager) RootURL() string {
|
func (m FileBrowser) RootURL() string {
|
||||||
return m.PrefixURL + m.BaseURL
|
return m.PrefixURL + m.BaseURL
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPrefixURL updates the prefixURL of a File
|
// SetPrefixURL updates the prefixURL of a File
|
||||||
// Manager object.
|
// Manager object.
|
||||||
func (m *FileManager) SetPrefixURL(url string) {
|
func (m *FileBrowser) SetPrefixURL(url string) {
|
||||||
url = strings.TrimPrefix(url, "/")
|
url = strings.TrimPrefix(url, "/")
|
||||||
url = strings.TrimSuffix(url, "/")
|
url = strings.TrimSuffix(url, "/")
|
||||||
url = "/" + url
|
url = "/" + url
|
||||||
@ -244,7 +244,7 @@ func (m *FileManager) SetPrefixURL(url string) {
|
|||||||
|
|
||||||
// SetBaseURL updates the baseURL of a File Manager
|
// SetBaseURL updates the baseURL of a File Manager
|
||||||
// object.
|
// object.
|
||||||
func (m *FileManager) SetBaseURL(url string) {
|
func (m *FileBrowser) SetBaseURL(url string) {
|
||||||
url = strings.TrimPrefix(url, "/")
|
url = strings.TrimPrefix(url, "/")
|
||||||
url = strings.TrimSuffix(url, "/")
|
url = strings.TrimSuffix(url, "/")
|
||||||
url = "/" + url
|
url = "/" + url
|
||||||
@ -252,7 +252,7 @@ func (m *FileManager) SetBaseURL(url string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Attach attaches a static generator to the current File Manager.
|
// Attach attaches a static generator to the current File Manager.
|
||||||
func (m *FileManager) Attach(s StaticGen) error {
|
func (m *FileBrowser) Attach(s StaticGen) error {
|
||||||
if reflect.TypeOf(s).Kind() != reflect.Ptr {
|
if reflect.TypeOf(s).Kind() != reflect.Ptr {
|
||||||
return errors.New("data should be a pointer to interface, not interface")
|
return errors.New("data should be a pointer to interface, not interface")
|
||||||
}
|
}
|
||||||
@ -274,7 +274,7 @@ func (m *FileManager) Attach(s StaticGen) error {
|
|||||||
|
|
||||||
// ShareCleaner removes sharing links that are no longer active.
|
// ShareCleaner removes sharing links that are no longer active.
|
||||||
// This function is set to run periodically.
|
// This function is set to run periodically.
|
||||||
func (m FileManager) ShareCleaner() {
|
func (m FileBrowser) ShareCleaner() {
|
||||||
// Get all links.
|
// Get all links.
|
||||||
links, err := m.Store.Share.Gets()
|
links, err := m.Store.Share.Gets()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -294,7 +294,7 @@ func (m FileManager) ShareCleaner() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Runner runs the commands for a certain event type.
|
// Runner runs the commands for a certain event type.
|
||||||
func (m FileManager) Runner(event string, path string, destination string, user *User) error {
|
func (m FileBrowser) Runner(event string, path string, destination string, user *User) error {
|
||||||
commands := []string{}
|
commands := []string{}
|
||||||
|
|
||||||
// Get the commands from the File Manager instance itself.
|
// Get the commands from the File Manager instance itself.
|
||||||
@ -530,7 +530,7 @@ type FileSystem interface {
|
|||||||
|
|
||||||
// Context contains the needed information to make handlers work.
|
// Context contains the needed information to make handlers work.
|
||||||
type Context struct {
|
type Context struct {
|
||||||
*FileManager
|
*FileBrowser
|
||||||
User *User
|
User *User
|
||||||
File *File
|
File *File
|
||||||
// On API handlers, Router is the APi handler we want.
|
// On API handlers, Router is the APi handler we want.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user