Add locale to cofnig

This commit is contained in:
Henrique Dias 2017-08-01 14:12:06 +01:00
parent 4ce297b8bb
commit b39e8edc27
No known key found for this signature in database
GPG Key ID: 936F5EB68D786730
4 changed files with 12 additions and 2321 deletions

View File

@ -27,9 +27,9 @@
</template> </template>
<script> <script>
import Forbidden from '@/components/errors/403' import Forbidden from './errors/403'
import NotFound from '@/components/errors/404' import NotFound from './errors/404'
import InternalError from '@/components/errors/500' import InternalError from './errors/500'
import Preview from '@/components/files/Preview' import Preview from '@/components/files/Preview'
import Listing from '@/components/files/Listing' import Listing from '@/components/files/Listing'
import Editor from '@/components/files/Editor' import Editor from '@/components/files/Editor'

View File

@ -28,6 +28,7 @@ var (
commands string commands string
logfile string logfile string
plugin string plugin string
locale string
port int port int
allowCommands bool allowCommands bool
allowEdit bool allowEdit bool
@ -47,6 +48,7 @@ func init() {
flag.BoolVar(&allowCommands, "allow-commands", true, "Default allow commands option for new users") 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(&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.BoolVar(&allowNew, "allow-new", true, "Default allow new option for new users")
flag.StringVar(&locale, "locale", "en", "Default locale for new users")
flag.StringVar(&plugin, "plugin", "", "Plugin you want to enable") flag.StringVar(&plugin, "plugin", "", "Plugin you want to enable")
flag.BoolVarP(&showVer, "version", "v", false, "Show version") flag.BoolVarP(&showVer, "version", "v", false, "Show version")
} }
@ -62,6 +64,7 @@ func setupViper() {
viper.SetDefault("AllowEdit", true) viper.SetDefault("AllowEdit", true)
viper.SetDefault("AllowNew", true) viper.SetDefault("AllowNew", true)
viper.SetDefault("Plugin", "") viper.SetDefault("Plugin", "")
viper.SetDefault("Locale", "en")
viper.BindPFlag("Port", flag.Lookup("port")) viper.BindPFlag("Port", flag.Lookup("port"))
viper.BindPFlag("Address", flag.Lookup("address")) viper.BindPFlag("Address", flag.Lookup("address"))
@ -72,6 +75,7 @@ func setupViper() {
viper.BindPFlag("AllowCommands", flag.Lookup("allow-commands")) viper.BindPFlag("AllowCommands", flag.Lookup("allow-commands"))
viper.BindPFlag("AllowEdit", flag.Lookup("allow-edit")) viper.BindPFlag("AllowEdit", flag.Lookup("allow-edit"))
viper.BindPFlag("AlowNew", flag.Lookup("allow-new")) viper.BindPFlag("AlowNew", flag.Lookup("allow-new"))
viper.BindPFlag("Locale", flag.Lookup("locale"))
viper.BindPFlag("Plugin", flag.Lookup("plugin")) viper.BindPFlag("Plugin", flag.Lookup("plugin"))
viper.SetConfigName("filemanager") viper.SetConfigName("filemanager")
@ -133,6 +137,7 @@ func main() {
AllowNew: viper.GetBool("AllowNew"), AllowNew: viper.GetBool("AllowNew"),
Commands: viper.GetStringSlice("Commands"), Commands: viper.GetStringSlice("Commands"),
Rules: []*filemanager.Rule{}, Rules: []*filemanager.Rule{},
Locale: viper.GetString("Locale"),
CSS: "", CSS: "",
FileSystem: fileutils.Dir(viper.GetString("Scope")), FileSystem: fileutils.Dir(viper.GetString("Scope")),
}) })

View File

@ -143,6 +143,9 @@ type User struct {
// Custom styles for this user. // Custom styles for this user.
CSS string `json:"css"` CSS string `json:"css"`
// Locale is the language of the user.
Locale string `json:"locale"`
// These indicate if the user can perform certain actions. // These indicate if the user can perform certain actions.
AllowNew bool `json:"allowNew"` // Create files and folders AllowNew bool `json:"allowNew"` // Create files and folders
AllowEdit bool `json:"allowEdit"` // Edit/rename files AllowEdit bool `json:"allowEdit"` // Edit/rename files
@ -212,6 +215,7 @@ var DefaultUser = User{
Rules: []*Rule{}, Rules: []*Rule{},
CSS: "", CSS: "",
Admin: true, Admin: true,
Locale: "en",
FileSystem: fileutils.Dir("."), FileSystem: fileutils.Dir("."),
} }

File diff suppressed because one or more lines are too long