Close #172
Former-commit-id: d89982644eb2fde52436a4709227b3c68477bad0 [formerly ecef4fca1df20baff25c87edde6a3165953946e0] [formerly acd3363cf88346c69564ce902d8470a55b2865f0 [formerly 011a154f1f
]]
Former-commit-id: 925e264736253dbcc1be8e7c31de9ebf2e5d2975 [formerly 23310a7c1fb9208d6519955194b31623bb927209]
Former-commit-id: 85e9ae5be30392151a709322c3574ac91dc5b52c
This commit is contained in:
parent
16c8b86241
commit
0a4e119bc5
|
@ -12,6 +12,8 @@ import (
|
|||
|
||||
lumberjack "gopkg.in/natefinch/lumberjack.v2"
|
||||
|
||||
"github.com/hacdias/filemanager/plugins"
|
||||
|
||||
"github.com/hacdias/filemanager"
|
||||
"github.com/hacdias/fileutils"
|
||||
flag "github.com/spf13/pflag"
|
||||
|
@ -25,6 +27,7 @@ var (
|
|||
scope string
|
||||
commands string
|
||||
logfile string
|
||||
plugin string
|
||||
port int
|
||||
allowCommands bool
|
||||
allowEdit bool
|
||||
|
@ -42,6 +45,7 @@ func init() {
|
|||
flag.BoolVar(&allowCommands, "allow-commands", true, "Default allow commands option for new users")
|
||||
flag.BoolVar(&allowEdit, "allow-edit", true, "Default allow edit option for new users")
|
||||
flag.BoolVar(&allowNew, "allow-new", true, "Default allow new option for new users")
|
||||
flag.StringVar(&plugin, "plugin", "", "Plugin you want to enable")
|
||||
}
|
||||
|
||||
func setupViper() {
|
||||
|
@ -54,6 +58,7 @@ func setupViper() {
|
|||
viper.SetDefault("AllowCommmands", true)
|
||||
viper.SetDefault("AllowEdit", true)
|
||||
viper.SetDefault("AllowNew", true)
|
||||
viper.SetDefault("Plugin", "")
|
||||
|
||||
viper.BindPFlag("Port", flag.Lookup("port"))
|
||||
viper.BindPFlag("Address", flag.Lookup("address"))
|
||||
|
@ -64,6 +69,7 @@ func setupViper() {
|
|||
viper.BindPFlag("AllowCommands", flag.Lookup("allow-commands"))
|
||||
viper.BindPFlag("AllowEdit", flag.Lookup("allow-edit"))
|
||||
viper.BindPFlag("AlowNew", flag.Lookup("allow-new"))
|
||||
viper.BindPFlag("Plugin", flag.Lookup("plugin"))
|
||||
|
||||
viper.SetConfigName("filemanager")
|
||||
viper.AddConfigPath(".")
|
||||
|
@ -118,6 +124,25 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if viper.GetString("Plugin") == "hugo" {
|
||||
// Initialize the default settings for Hugo.
|
||||
hugo := &plugins.Hugo{
|
||||
Root: viper.GetString("Scope"),
|
||||
Public: filepath.Join(viper.GetString("Scope"), "public"),
|
||||
Args: []string{},
|
||||
CleanPublic: true,
|
||||
}
|
||||
|
||||
// Try to find the Hugo executable path.
|
||||
if err = hugo.Find(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err = fm.ActivatePlugin("hugo", hugo); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Builds the address and a listener.
|
||||
laddr := viper.GetString("Address") + ":" + viper.GetString("Port")
|
||||
listener, err := net.Listen("tcp", laddr)
|
||||
|
|
Loading…
Reference in New Issue