This commit is contained in:
Liang Ding 2019-05-17 01:06:01 +08:00
parent be63fc0d16
commit 4f48e827f6
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
3 changed files with 4 additions and 12 deletions

View File

@ -122,7 +122,7 @@ func NewUser(id, name, avatar, workspace string) *User {
// 2. Replace ${GOPATH} with enviorment variable GOPATH
// 3. Replace "/" with "\\" (Windows)
func (u *User) WorkspacePath() string {
w := strings.Replace(u.Workspace, "{WD}", Wide.WD, 1)
w := u.Workspace
w = strings.Replace(w, "${GOPATH}", os.Getenv("GOPATH"), 1)
return filepath.FromSlash(w)

View File

@ -63,7 +63,6 @@ type conf struct {
StaticResourceVersion string // version of static resources
MaxProcs int // Go max procs
RuntimeMode string // runtime mode (dev/prod)
WD string // current working direcitory, ${pwd}
Locale string // default locale
Playground string // playground directory
Users string // users directory
@ -189,10 +188,6 @@ func initWide(confPath, confUsers, confServer, confLogLevel, confPlayground stri
logger.Debug("Conf: \n" + string(bytes))
// Working Directory
Wide.WD = util.OS.Pwd()
logger.Debugf("${pwd} [%s]", Wide.WD)
// User Home
home, err := util.OS.Home()
if nil != err {
@ -224,7 +219,6 @@ func initWide(confPath, confUsers, confServer, confLogLevel, confPlayground stri
}
// Users' workspaces directory
Wide.UsersWorkspaces = strings.Replace(Wide.UsersWorkspaces, "${WD}", Wide.WD, 1)
Wide.UsersWorkspaces = strings.Replace(Wide.UsersWorkspaces, "${home}", home, 1)
if "" != confUsersWorkspaces {
Wide.UsersWorkspaces = confUsersWorkspaces
@ -238,7 +232,6 @@ func initWide(confPath, confUsers, confServer, confLogLevel, confPlayground stri
}
}
// Server
if "" != confServer {
Wide.Server = confServer
@ -376,8 +369,7 @@ func UpdateCustomizedConf(userId string) {
os.Exit(-1)
}
wd := util.OS.Pwd()
dir := filepath.Clean(wd + "/static/user/" + u.Id)
dir := filepath.Clean(Wide.UsersWorkspaces + "/" + userId + "/static/")
if err := os.MkdirAll(dir, 0755); nil != err {
logger.Error(err)

View File

@ -105,8 +105,8 @@ func main() {
// workspaces
for _, user := range conf.Users {
http.Handle("/workspace/"+user.Name+"/",
http.StripPrefix("/workspace/"+user.Name+"/", http.FileServer(http.Dir(user.WorkspacePath()))))
http.Handle("/workspace/"+user.Id+"/",
http.StripPrefix("/workspace/"+user.Id+"/", http.FileServer(http.Dir(user.WorkspacePath()))))
}
// session