This commit is contained in:
parent
28d8f99f85
commit
23f299f0bf
|
@ -9,4 +9,5 @@
|
|||
/**/.DS_Store
|
||||
|
||||
/node_modules
|
||||
/nbproject
|
||||
/nbproject
|
||||
/workspaces
|
17
conf/wide.go
17
conf/wide.go
|
@ -69,6 +69,7 @@ type conf struct {
|
|||
WD string // current working direcitory, ${pwd}
|
||||
Locale string // default locale
|
||||
Playground string // playground directory
|
||||
UsersWorkspaces string // users' workspaces directory (admin defaults to ${GOPATH}, others using this)
|
||||
AllowRegister bool // allow register or not
|
||||
Autocomplete bool // default autocomplete
|
||||
}
|
||||
|
@ -87,11 +88,11 @@ var Docker bool
|
|||
|
||||
// Load loads the Wide configurations from wide.json and users' configurations from users/{username}.json.
|
||||
func Load(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel,
|
||||
confPlayground string, confDocker bool) {
|
||||
confPlayground string, confDocker bool, confUsersWorkspaces string) {
|
||||
// XXX: ugly args list....
|
||||
|
||||
initWide(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel,
|
||||
confPlayground, confDocker)
|
||||
confPlayground, confDocker, confUsersWorkspaces)
|
||||
initUsers()
|
||||
}
|
||||
|
||||
|
@ -144,7 +145,7 @@ func initUsers() {
|
|||
}
|
||||
|
||||
func initWide(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel,
|
||||
confPlayground string, confDocker bool) {
|
||||
confPlayground string, confDocker bool, confUsersWorkspaces string) {
|
||||
bytes, err := ioutil.ReadFile(confPath)
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
|
@ -190,6 +191,16 @@ func initWide(confPath, confIP, confPort, confServer, confLogLevel, confStaticSe
|
|||
Wide.Playground = confPlayground
|
||||
}
|
||||
|
||||
// Users' workspaces Directory
|
||||
logger.Debug(Wide.UsersWorkspaces)
|
||||
|
||||
Wide.UsersWorkspaces = strings.Replace(Wide.UsersWorkspaces, "${WD}", Wide.WD, 1)
|
||||
Wide.UsersWorkspaces = strings.Replace(Wide.UsersWorkspaces, "${home}", home, 1)
|
||||
if "" != confUsersWorkspaces {
|
||||
Wide.UsersWorkspaces = confUsersWorkspaces
|
||||
}
|
||||
Wide.UsersWorkspaces = filepath.Clean(Wide.UsersWorkspaces)
|
||||
|
||||
if !util.File.IsExist(Wide.Playground) {
|
||||
if err := os.Mkdir(Wide.Playground, 0775); nil != err {
|
||||
logger.Errorf("Create Playground [%s] error", err)
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"WD": "${pwd}",
|
||||
"Locale": "en_US",
|
||||
"Playground": "${home}/playground",
|
||||
"UsersWorkspaces": "${WD}/workspaces",
|
||||
"AllowRegister": true,
|
||||
"Autocomplete": true
|
||||
}
|
3
main.go
3
main.go
|
@ -57,6 +57,7 @@ func init() {
|
|||
confStat := flag.Bool("stat", false, "whether report statistics periodically")
|
||||
confDocker := flag.Bool("docker", false, "whether run in a docker container")
|
||||
confPlayground := flag.String("playground", "", "this will overwrite Wide.Playground if specified")
|
||||
confUsersWorkspaces := flag.String("users_workspaces", "", "this will overwrite Wide.UsersWorkspaces if specified")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
|
@ -75,7 +76,7 @@ func init() {
|
|||
event.Load()
|
||||
|
||||
conf.Load(*confPath, *confIP, *confPort, *confServer, *confLogLevel, *confStaticServer, *confContext, *confChannel,
|
||||
*confPlayground, *confDocker)
|
||||
*confPlayground, *confDocker, *confUsersWorkspaces)
|
||||
|
||||
conf.FixedTimeCheckEnv()
|
||||
|
||||
|
|
|
@ -224,11 +224,8 @@ func SignUpUserHandler(w http.ResponseWriter, r *http.Request) {
|
|||
if "GET" == r.Method {
|
||||
// show the user sign up page
|
||||
|
||||
firstUserWorkspace := conf.GetUserWorkspace(conf.Users[0].Name)
|
||||
dir := filepath.Dir(firstUserWorkspace)
|
||||
|
||||
model := map[string]interface{}{"conf": conf.Wide, "i18n": i18n.GetAll(conf.Wide.Locale),
|
||||
"locale": conf.Wide.Locale, "ver": conf.WideVersion, "dir": dir,
|
||||
"locale": conf.Wide.Locale, "ver": conf.WideVersion, "dir": conf.Wide.UsersWorkspaces,
|
||||
"pathSeparator": conf.PathSeparator, "year": time.Now().Year()}
|
||||
|
||||
t, err := template.ParseFiles("views/sign_up.html")
|
||||
|
@ -374,9 +371,7 @@ func addUser(username, password, email string) string {
|
|||
}
|
||||
}
|
||||
|
||||
firstUserWorkspace := conf.GetUserWorkspace(conf.Users[0].Name)
|
||||
dir := filepath.Dir(firstUserWorkspace)
|
||||
workspace := filepath.Join(dir, username)
|
||||
workspace := filepath.Join(conf.Wide.UsersWorkspaces, username)
|
||||
|
||||
newUser := conf.NewUser(username, password, email, workspace)
|
||||
conf.Users = append(conf.Users, newUser)
|
||||
|
|
Loading…
Reference in New Issue