|
|
@ -15,17 +15,14 @@ import ( |
|
|
|
"github.com/gogits/gogs/models" |
|
|
|
"github.com/gogits/gogs/models" |
|
|
|
"github.com/gogits/gogs/modules/auth" |
|
|
|
"github.com/gogits/gogs/modules/auth" |
|
|
|
"github.com/gogits/gogs/modules/base" |
|
|
|
"github.com/gogits/gogs/modules/base" |
|
|
|
|
|
|
|
"github.com/gogits/gogs/utils/log" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func Create(req *http.Request, r render.Render, data base.TmplData, session sessions.Session) { |
|
|
|
func Create(req *http.Request, r render.Render, data base.TmplData, session sessions.Session) { |
|
|
|
data["Title"] = "Create repository" |
|
|
|
data["Title"] = "Create repository" |
|
|
|
|
|
|
|
|
|
|
|
if req.Method == "GET" { |
|
|
|
if req.Method == "GET" { |
|
|
|
r.HTML(200, "repo/create", map[string]interface{}{ |
|
|
|
r.HTML(200, "repo/create", data) |
|
|
|
"UserName": auth.SignedInName(session), |
|
|
|
|
|
|
|
"UserId": auth.SignedInId(session), |
|
|
|
|
|
|
|
"IsSigned": auth.IsSignedIn(session), |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -42,56 +39,49 @@ func Create(req *http.Request, r render.Render, data base.TmplData, session sess |
|
|
|
_, err = models.CreateRepository(u, req.FormValue("name")) |
|
|
|
_, err = models.CreateRepository(u, req.FormValue("name")) |
|
|
|
} |
|
|
|
} |
|
|
|
if err == nil { |
|
|
|
if err == nil { |
|
|
|
r.HTML(200, "repo/created", map[string]interface{}{ |
|
|
|
data["RepoName"] = u.Name + "/" + req.FormValue("name") |
|
|
|
"RepoName": u.Name + "/" + req.FormValue("name"), |
|
|
|
r.HTML(200, "repo/created", data) |
|
|
|
"IsSigned": auth.IsSignedIn(session), |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
r.HTML(200, "base/error", map[string]interface{}{ |
|
|
|
data["ErrorMsg"] = err |
|
|
|
"Error": fmt.Sprintf("%v", err), |
|
|
|
log.Error("repo.Create: %v", err) |
|
|
|
"IsSigned": auth.IsSignedIn(session), |
|
|
|
r.HTML(200, "base/error", data) |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func Delete(req *http.Request, r render.Render, session sessions.Session) { |
|
|
|
func Delete(req *http.Request, r render.Render, data base.TmplData, session sessions.Session) { |
|
|
|
|
|
|
|
data["Title"] = "Delete repository" |
|
|
|
|
|
|
|
|
|
|
|
if req.Method == "GET" { |
|
|
|
if req.Method == "GET" { |
|
|
|
r.HTML(200, "repo/delete", map[string]interface{}{ |
|
|
|
r.HTML(200, "repo/delete", data) |
|
|
|
"Title": "Delete repository", |
|
|
|
|
|
|
|
"IsSigned": auth.IsSignedIn(session), |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
u := &models.User{} |
|
|
|
u := &models.User{} |
|
|
|
err := models.DeleteRepository(u, "") |
|
|
|
err := models.DeleteRepository(u, "") |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
r.HTML(200, "base/error", map[string]interface{}{ |
|
|
|
data["ErrorMsg"] = err |
|
|
|
"Error": fmt.Sprintf("%v", err), |
|
|
|
log.Error("repo.Delete: %v", err) |
|
|
|
"IsSigned": auth.IsSignedIn(session), |
|
|
|
r.HTML(200, "base/error", data) |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func List(req *http.Request, r render.Render, session sessions.Session) { |
|
|
|
func List(req *http.Request, r render.Render, data base.TmplData, session sessions.Session) { |
|
|
|
|
|
|
|
data["Title"] = "Repositories" |
|
|
|
|
|
|
|
|
|
|
|
u := auth.SignedInUser(session) |
|
|
|
u := auth.SignedInUser(session) |
|
|
|
repos, err := models.GetRepositories(u) |
|
|
|
repos, err := models.GetRepositories(u) |
|
|
|
fmt.Println("repos", repos) |
|
|
|
fmt.Println("repos", repos) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
r.HTML(200, "base/error", map[string]interface{}{ |
|
|
|
data["ErrorMsg"] = err |
|
|
|
"Error": fmt.Sprintf("%v", err), |
|
|
|
log.Error("repo.List: %v", err) |
|
|
|
"IsSigned": auth.IsSignedIn(session), |
|
|
|
r.HTML(200, "base/error", data) |
|
|
|
}) |
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
r.HTML(200, "repo/list", map[string]interface{}{ |
|
|
|
data["Repos"] = repos |
|
|
|
"Title": "repositories", |
|
|
|
r.HTML(200, "repo/list", data) |
|
|
|
"Repos": repos, |
|
|
|
|
|
|
|
"IsSigned": auth.IsSignedIn(session), |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|