|
@@ -10,19 +10,21 @@ import (
|
|
"strconv"
|
|
"strconv"
|
|
|
|
|
|
"github.com/martini-contrib/render"
|
|
"github.com/martini-contrib/render"
|
|
|
|
+ "github.com/martini-contrib/sessions"
|
|
|
|
|
|
"github.com/gogits/gogs/models"
|
|
"github.com/gogits/gogs/models"
|
|
- "github.com/gogits/gogs/routers/user"
|
|
|
|
- "github.com/martini-contrib/sessions"
|
|
|
|
|
|
+ "github.com/gogits/gogs/modules/auth"
|
|
|
|
+ "github.com/gogits/gogs/modules/base"
|
|
)
|
|
)
|
|
|
|
|
|
-func Create(req *http.Request, r render.Render, session sessions.Session) {
|
|
|
|
|
|
+func Create(req *http.Request, r render.Render, data base.TmplData, session sessions.Session) {
|
|
|
|
+ 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", map[string]interface{}{
|
|
- "Title": "Create repository",
|
|
|
|
- "UserName": user.SignedInName(session),
|
|
|
|
- "UserId": user.SignedInId(session),
|
|
|
|
- "IsSigned": user.IsSignedIn(session),
|
|
|
|
|
|
+ "UserName": auth.SignedInName(session),
|
|
|
|
+ "UserId": auth.SignedInId(session),
|
|
|
|
+ "IsSigned": auth.IsSignedIn(session),
|
|
})
|
|
})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -42,7 +44,7 @@ func Create(req *http.Request, r render.Render, session sessions.Session) {
|
|
if err == nil {
|
|
if err == nil {
|
|
r.HTML(200, "repo/created", map[string]interface{}{
|
|
r.HTML(200, "repo/created", map[string]interface{}{
|
|
"RepoName": u.Name + "/" + req.FormValue("name"),
|
|
"RepoName": u.Name + "/" + req.FormValue("name"),
|
|
- "IsSigned": user.IsSignedIn(session),
|
|
|
|
|
|
+ "IsSigned": auth.IsSignedIn(session),
|
|
})
|
|
})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -51,7 +53,7 @@ func Create(req *http.Request, r render.Render, session sessions.Session) {
|
|
if err != nil {
|
|
if err != nil {
|
|
r.HTML(200, "base/error", map[string]interface{}{
|
|
r.HTML(200, "base/error", map[string]interface{}{
|
|
"Error": fmt.Sprintf("%v", err),
|
|
"Error": fmt.Sprintf("%v", err),
|
|
- "IsSigned": user.IsSignedIn(session),
|
|
|
|
|
|
+ "IsSigned": auth.IsSignedIn(session),
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -60,7 +62,7 @@ func Delete(req *http.Request, r render.Render, session sessions.Session) {
|
|
if req.Method == "GET" {
|
|
if req.Method == "GET" {
|
|
r.HTML(200, "repo/delete", map[string]interface{}{
|
|
r.HTML(200, "repo/delete", map[string]interface{}{
|
|
"Title": "Delete repository",
|
|
"Title": "Delete repository",
|
|
- "IsSigned": user.IsSignedIn(session),
|
|
|
|
|
|
+ "IsSigned": auth.IsSignedIn(session),
|
|
})
|
|
})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -70,19 +72,19 @@ func Delete(req *http.Request, r render.Render, session sessions.Session) {
|
|
if err != nil {
|
|
if err != nil {
|
|
r.HTML(200, "base/error", map[string]interface{}{
|
|
r.HTML(200, "base/error", map[string]interface{}{
|
|
"Error": fmt.Sprintf("%v", err),
|
|
"Error": fmt.Sprintf("%v", err),
|
|
- "IsSigned": user.IsSignedIn(session),
|
|
|
|
|
|
+ "IsSigned": auth.IsSignedIn(session),
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
func List(req *http.Request, r render.Render, session sessions.Session) {
|
|
func List(req *http.Request, r render.Render, session sessions.Session) {
|
|
- u := user.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{}{
|
|
r.HTML(200, "base/error", map[string]interface{}{
|
|
"Error": fmt.Sprintf("%v", err),
|
|
"Error": fmt.Sprintf("%v", err),
|
|
- "IsSigned": user.IsSignedIn(session),
|
|
|
|
|
|
+ "IsSigned": auth.IsSignedIn(session),
|
|
})
|
|
})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -90,6 +92,6 @@ func List(req *http.Request, r render.Render, session sessions.Session) {
|
|
r.HTML(200, "repo/list", map[string]interface{}{
|
|
r.HTML(200, "repo/list", map[string]interface{}{
|
|
"Title": "repositories",
|
|
"Title": "repositories",
|
|
"Repos": repos,
|
|
"Repos": repos,
|
|
- "IsSigned": user.IsSignedIn(session),
|
|
|
|
|
|
+ "IsSigned": auth.IsSignedIn(session),
|
|
})
|
|
})
|
|
}
|
|
}
|