This commit is contained in:
parent
b5aa4f9a7d
commit
003354ffe4
|
@ -76,7 +76,7 @@ type editor struct {
|
|||
TabSize string
|
||||
}
|
||||
|
||||
// Save saves the user's configurations in conf/users/{username}.json.
|
||||
// Save saves the user's configurations in conf/users/{userId}.json.
|
||||
func (u *User) Save() bool {
|
||||
bytes, err := json.MarshalIndent(u, "", " ")
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ var Docker bool
|
|||
// Docker image to run user's program
|
||||
const DockerImageGo = "golang"
|
||||
|
||||
// Load loads the Wide configurations from wide.json and users' configurations from users/{username}.json.
|
||||
// Load loads the Wide configurations from wide.json and users' configurations from users/{userId}.json.
|
||||
func Load(confPath, confUsers, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel, confPlayground string, confUsersWorkspaces string) {
|
||||
initWide(confPath, confUsers, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel, confPlayground, confUsersWorkspaces)
|
||||
initUsers()
|
||||
|
@ -391,7 +391,7 @@ func initCustomizedConfs() {
|
|||
|
||||
// UpdateCustomizedConf creates (if not exists) or updates user customized configuration files.
|
||||
//
|
||||
// 1. /static/user/{username}/style.css
|
||||
// 1. /static/user/{userId}/style.css
|
||||
func UpdateCustomizedConf(userId string) {
|
||||
var u *User
|
||||
for _, user := range Users { // maybe it is a beauty of the trade-off of the another world between design and implementation
|
||||
|
|
|
@ -40,7 +40,7 @@ func GoFmtHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
return
|
||||
}
|
||||
username := session.Values["username"].(string)
|
||||
uid := session.Values["uid"].(string)
|
||||
|
||||
var args map[string]interface{}
|
||||
|
||||
|
@ -85,7 +85,7 @@ func GoFmtHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
result.Data = data
|
||||
|
||||
fmt := conf.GetGoFmt(username)
|
||||
fmt := conf.GetGoFmt(uid)
|
||||
|
||||
argv := []string{filePath}
|
||||
cmd := exec.Command(fmt, argv...)
|
||||
|
|
|
@ -204,8 +204,8 @@ func GetFileHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
data["mode"] = "img"
|
||||
|
||||
username := conf.GetOwner(path)
|
||||
if "" == username {
|
||||
userId := conf.GetOwner(path)
|
||||
if "" == userId {
|
||||
logger.Warnf("The path [%s] has no owner", path)
|
||||
data["path"] = ""
|
||||
|
||||
|
|
|
@ -155,8 +155,6 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
// logger.Debugf("User [%s, %s] is building [id=%d, dir=%s]", username, sid, runningId, curDir)
|
||||
|
||||
channelRet["cmd"] = "build"
|
||||
channelRet["executable"] = executable
|
||||
|
||||
|
|
|
@ -155,8 +155,6 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) {
|
|||
defer util.Recover()
|
||||
defer cmd.Wait()
|
||||
|
||||
// logger.Debugf("User [%s, %s] is building [id=%d, dir=%s]", username, sid, runningId, curDir)
|
||||
|
||||
// read all
|
||||
buf, _ := ioutil.ReadAll(reader)
|
||||
|
||||
|
@ -235,8 +233,6 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
if nil != session.OutputWS[sid] {
|
||||
// logger.Debugf("User [%s, %s] 's build [id=%d, dir=%s] has done", username, sid, runningId, curDir)
|
||||
|
||||
wsChannel := session.OutputWS[sid]
|
||||
err := wsChannel.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
|
|
|
@ -43,7 +43,7 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
|
|||
httpSession, _ := session.HTTPSession.Get(r, "wide-session")
|
||||
if httpSession.IsNew {
|
||||
httpSession.Values["id"] = strconv.Itoa(rand.Int())
|
||||
httpSession.Values["username"] = "playground"
|
||||
httpSession.Values["uid"] = "playground"
|
||||
}
|
||||
|
||||
httpSession.Options.MaxAge = conf.Wide.HTTPSessionMaxAge
|
||||
|
|
|
@ -111,7 +111,7 @@ func GithubCallbackHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// create a HTTP session
|
||||
httpSession, _ := HTTPSession.Get(r, "wide-session")
|
||||
httpSession.Values["username"] = userName
|
||||
httpSession.Values["uid"] = githubId
|
||||
|
||||
httpSession.Values["id"] = strconv.Itoa(rand.Int())
|
||||
httpSession.Options.MaxAge = conf.Wide.HTTPSessionMaxAge
|
||||
|
@ -120,7 +120,7 @@ func GithubCallbackHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
httpSession.Save(r, w)
|
||||
|
||||
logger.Debugf("Created a HTTP session [%s] for user [%s]", httpSession.Values["id"].(string), userName)
|
||||
logger.Debugf("Created a HTTP session [%s] for user [%s]", httpSession.Values["id"].(string), githubId)
|
||||
}
|
||||
|
||||
// GitHubUserInfo returns GitHub user info specified by the given access token.
|
||||
|
|
|
@ -122,7 +122,7 @@ func FixedTimeRelease() {
|
|||
|
||||
// Online user statistic report.
|
||||
type userReport struct {
|
||||
username string
|
||||
userId string
|
||||
sessionCnt int
|
||||
processCnt int
|
||||
updated time.Time
|
||||
|
@ -130,7 +130,7 @@ type userReport struct {
|
|||
|
||||
// report returns a online user statistics in pretty format.
|
||||
func (u *userReport) report() string {
|
||||
return "[" + u.username + "] has [" + strconv.Itoa(u.sessionCnt) + "] sessions and [" + strconv.Itoa(u.processCnt) +
|
||||
return "[" + u.userId + "] has [" + strconv.Itoa(u.sessionCnt) + "] sessions and [" + strconv.Itoa(u.processCnt) +
|
||||
"] running processes, latest activity [" + u.updated.Format("2006-01-02 15:04:05") + "]"
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ func FixedTimeReport() {
|
|||
report.sessionCnt++
|
||||
report.processCnt += processCnt
|
||||
} else {
|
||||
users = append(users, &userReport{username: s.UserId, sessionCnt: 1, processCnt: processCnt, updated: s.Updated})
|
||||
users = append(users, &userReport{userId: s.UserId, sessionCnt: 1, processCnt: processCnt, updated: s.Updated})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,9 +174,9 @@ func FixedTimeReport() {
|
|||
}()
|
||||
}
|
||||
|
||||
func contains(reports []*userReport, username string) (*userReport, bool) {
|
||||
func contains(reports []*userReport, userId string) (*userReport, bool) {
|
||||
for _, ur := range reports {
|
||||
if username == ur.username {
|
||||
if userId == ur.userId {
|
||||
return ur, true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue